marcusgreen / moodle-qtype_gapfill

Fill in the blanks question type with very easy to learn syntax
6 stars 20 forks source link

Students unable to drag and drop using gapfill question #110

Open kiratskitizing opened 9 months ago

kiratskitizing commented 9 months ago

Describe the bug When a quiz uses the setting: Extra restrictions on attempts / Browser security = Full screen pop-up with some Javascript Security. A student attempting the quiz is not able to drag and drop

To Reproduce Steps to reproduce the behavior:

  1. Create a course.
  2. Turn edit mode to On.
  3. Add a Quiz activity and set Extra restrictions on attempts / Browser security = Full screen pop-up with some Javascript Security.
  4. Add a Gap Fill question
    • Name: Gap Fill Example
    • Question text: [correct]
    • Distractors: incorrect
    • Delimit characters: []
    • Display Answers: dragdrop
    • tick Fixed Gap size
  5. Save.
  6. Log directly as a student user, attempt the quiz and try to perform drag and drop.
  7. RESULT: Drag and drop does not work

Expected behavior Student should be able to drag and drop.

Desktop (please complete the following information):

marcusgreen commented 9 months ago

Thanks for letting me know and for all the detail. That doesn't surprise me greatly, it is probably the javascript security bit that is causing the problem. I will investigate.

cdipe commented 9 months ago

Can confirm the problem, when javascript security is activated the words cannot be dragged by students. Moodle 4.1.7 and Gapfill 2.138, OSX, Chrome and Firefox

marcusgreen commented 9 months ago

I have investigated this further and had discussions with the senior developers at Moodle HQ (This should take you to the link in telegram) https://t.me/moodledev/132631

Two of the people who responded were Brett Dalton and also Tim Hunt who is the main architect of the Moodle Quiz module. My interpretation of the responses is that other quiz questions do not use standard HTML drag and drop so the security mode does not interfere. My code uses standard HTML drag and drop capabilities and so is broken by that security mode.

I have spent some time to work around this but without success and I suspect I may never get it to work in that mode with core Moodle. My apologies for not being able to find a solution, but I will leave this ticket open for the moment in the hope of finding a way around this problem.

cdipe commented 9 months ago

@marcusgreen ah, what a pity! This is a great question type, and easy to setup. You've done great! I suggest adding admin settings to disable the drag-and-drop option, since many use the "Full screen pop-up with some Javascript Security" setting and Gapfill now might mess things up. It should be made so that all the already existing questions will use the drop-down menu instead when drag/drop has been deactivated.

marcusgreen commented 9 months ago

Yes, there should be some mitigation/warning. I would not have thought of switching to the dropdowns as an option. That is a good idea, I will see if I can think of a way of implementing it. I am currently very focussed on this https://fosstodon.org/@marcusgreen/111643206243001461 until the end of February.

cdipe commented 9 months ago

@marcusgreen I understand. Do you know what/where would need to be changed in the database to change all old dragdrop questions to work as dropdown? I have found the table mdl_question_gapfill and tested just changing the value for answerdisplay from dragdrop to dropdown in a test question, but that wasn't enough.

marcusgreen commented 9 months ago

answerdisplay should work, but only for a new attempt at a quiz.

cdipe commented 9 months ago

Sorry... I created a dragdrop question and changed the value for answerdisplay from dragdrop to dropdown in table mdl_question_gapfill. Added the question to a new quiz, but the answer options was still dragdrop. So, there's something more that need change.