apluslms/a-plus-rst-tools

Adding a general description in a questionnaire with the `pick_randomly` option generates an empty question

Opened this issue · 4 comments

The following code will generate an empty question

.. questionnaire:: pick_randomly_1
  :title: Pick question randomly from a pool of questions
  :submissions: 4
  :points-to-pass: 10
  :pick_randomly: 1
  :category: Pool

  This is a questionnaire with the key `1` that grants at maximum 70 points of difficulty A. 
  Students can make at most 4 submissions.
  This exercise is marked passed when 0 points are reached (the default).

  .. include:: pool_of_questions.rst

The yaml file will have something like this

...
- fields:
  - more: '<p>This is a questionnaire with the key <cite>1</cite> that grants at maximum
      70 points

      of difficulty A. Students can make at most 4 submissions.

      This exercise is marked passed when 0 points are reached (the default).</p>

      <blockquote>

      <div>'
...
    - more: '</div></blockquote>

      '
    title: ''
    type: static
...

The UI looks like this

image

The text in the questionnaire description is not accurate, this is just an example.

The pool_of_questions.rst looks like this:

.. freetext:: 10 regexp

  This question accepts either "red" or "blue" as the correct answer.
  The model solution is a regular expression.

  red|blue

.. pick-one:: 10
  :required:
  :dropdown:

  What is 1+2?

  +0. 0
  1. 1
  2. 2
  *3. 3

.. freetext:: 10 string-ignorews-ignorequotes-requirecase
  :length: 10

  A textual input can be compared with the model solution as integer, float or string.
  Here the correct answer is "test". Surrounding quotes are ignored in the solution
  as well as whitespace everywhere (modifiers ignorequotes and ignorews).

  test
  !test § Follow the instruction.
  regexp:Test|TEST § Use the lower case!

The actual problem here could be that pick_randomly does not understand the difference of static text and real questions. The static text block is treated as one of the questions and if you select only one question randomly, that one question may be a text block. If you log in with a different user or increase the parameter of pick_randomly from just one, then do you see real questions? (The static text block could disappear completely while another question is shown.) At any rate, I remember that pick_randomly does not work with the static text blocks (since it thinks they are part of the question pool), so at the moment we would instruct users that they can't use static text blocks inside the questionnaire with pick_randomly. Of course, it is possible to fix that bug/"feature".

Another thing to test: use the include directive, but remove all static text blocks. Does pick_randomly work correctly when the include directive and all other questionnaire content only consist of question directives?

Note that questions may still have their own descriptions (text). By static text block, I mean text that is outside any question directive, but inside the questionnaire directive. In the config.yaml, you can see that the text blocks are their own items in the fields list and they have type static.

Yes, you are right, the static text causes this problem. I removed the static text

This is a questionnaire with the key `1` that grants at maximum 70 points
of difficulty A. Students can make at most 4 submissions.
This exercise is marked passed when 0 points are reached (the default).

and that solved the problem.

Then this issue can be about fixing the random choice of questions in the MOOC-Grader graded form code so that static text blocks would not be part of the question pool.

Code around here and elsewhere in the file:
https://github.com/apluslms/mooc-grader/blob/42f1a810c0c19b07ebefe73cce73ef182a99cf47/access/types/forms.py#L80