maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
142 stars 149 forks source link

Allow blocks and PRTs to move information around the question text. #801

Open sangwinc opened 2 years ago

sangwinc commented 2 years ago

Currently each PRT can only insert text into the question in one place, i.e. the [[feedback:prt]] tag is sometimes replaced by the prt feedback. This is a proposal to allow blocks to move information around the question text in more flexible ways. This is a proposal for two new blocks

[[ tag name="tagname" ]]

[[ replace name="tagname" ]] Stuff [[/replace]]

Once any [[feedback:prt]] tags have been replaced (and no changes in how this is done), we then process any replace tags. This means any replacements are still under the control of the quiz settings etc. One PRT can then insert feedback in lots of places if appropriate. E.g. a compact "tick" next to an input, when there are lots of inputs but one PRT.

Notes/suggestions.

  1. Replace may not be nested.
  2. Tags may appear more than once (why not?) but replace can only replace one tag name (why? but for now).
  3. Replace is the last step in the castext chain once any PRTs have been substituted into the castext.
  4. Tags may also occur in other PRT feedback (why not!).
  5. Any "unused" replace tags (i.e. can't find the tag name) generates an error.
  6. Any "unused" tags are just dropped quietly.
  7. Replace does not affect the general solution (for now).
aharjula commented 2 years ago

Interesting, the new CASText2 system could do this (with a suitable processor) if we would not have that pesky little specific feedback field in our question model. That field leads to the CASText being separated into two parts and therefore this would need to happen as a separate step above those, i.e. as you suggest.

I would suggest that the "tag" would use the same syntax as input, validation and parts i.e. [[tag:tagname]] or maybe something as silly as [[output:tagname]] and allow anything wanting to output something to output through that. Replace seems somewhat odd, but it does work having a pair like import/export might also be an option, but those might get mixed with something else.

Also, consider multiple PRTs that would each want to highlight some particular bit of the question text, they might target the same "tag" and in that case, we might want to consider being able to concatenate multiple values from varying sources into that position. Maybe that would be a bad thing, so probably we should guide towards a single source for a single tag.

What would really be interesting would be for the custom-validation in input2 to be able to output stuff like this as well, your numeric input fields actually throwing a big red mark next to the bit in the question text that says how many digits one should input could be somewhat aggressive, but the message would go through. However, then this would need to work with instant validation and would connect to the reveal-block as one of those things requiring client-side scripting.

Point 4 is the one where things get really fun though, then we will probably end up in a situation where a tag is in a branch that often triggers but eventually the student ends up in a branch that never triggers. We would probably need to ensure that the tag is present in all the possible branches if there is a tag. The trickier bit is the tag being in another PRTs feedback, maybe the whole PRT does not trigger...