Ordering/"Drag-and-Drop" Question Trouble

Ordering/"Drag-and-Drop" Question Trouble

by William Michael -
Number of replies: 14

Blessings all.

We have students complaining that drag-and-drop quiz questions are not working.  Students can neither "drag" nor "drop" the choices.

Any suggestions how we can remedy this?

Thanks, as always,

William Michael
Classical Liberal Arts Academy

Average of ratings: -
In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Just moving this to the Quiz forum... do you mean all drag and drop question types, such as drag and drop markers, drag and drop into text? What browser/devices are they using?

In reply to Mary Cooch

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

The only drag-and-drop activity type I'm using is the simple Ordering quiz question type here:  https://moodle.org/plugins/view/qtype_ordering

I'm not blaming the plugin, which was working previously and has not been updated or changed.  

I'm interested in learning what might cause the plugin to no longer allow the users to select, drag and/or drop items.  

Thanks,
WM

In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

The drag/drop functionality depends on Javascript. There may be some other Javascript that is interacting with it. Most web browsers allow you to look at the "console", which may be displaying errors that might give information about what is happening. Some browsers (Chrome) will display the console if you press the F12 key, but check out whatever browser you are using.

You should also run  /admin/purgecaches.php which as the name implies will purge caches.




In reply to Marcus Green

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

Console in Google Chrome contains:

  • Uncaught TypeError: $(...).sortable is not a function


I'm unaware of any changes to any code related to the plugin, so it has to be coming from some other source.

WM

In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

That looks like a JQuery issue, which might be due to something else loading a different version of Jquery (a bit unlikely) or it might be some files missing, notable the four files you can see here.

https://github.com/gbateson/moodle-qtype_ordering/tree/master/jquery

Did you do the purge caches thing?

Average of ratings: Useful (1)
In reply to Marcus Green

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

Thank you very much for your help, Marcus.

1.  Yes, ran the cache purge in Moodle Site Admin.
2.  Four files seem to be there:




In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

Problem solved.  Looks like you nailed it, Marcus:

"might be due to something else loading a different version of Jquery"

I'm not sure what might have done that, but I don't have time to worry about that right now. ;)

In the "Additional HTML" settings in Site Admin >> Appearance, I changed the jquery version in the Header from

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
to 

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

That was it.  

Thank you all again.  I hope this helps someone.

William Michael
Classical Liberal Arts Academy
In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

FYI...

I tried 1.11.3

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
...and it didn't work.  

WM
In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by Don Hinkelman -
Picture of Particularly helpful Moodlers Picture of Plugin developers

If you are referring to the drag-and-drop ordering question type, we also found that this question type did not work on mobile devices in 2.8 and perhaps other versions. Since we are highly dependant on them, and students are increasingly using smartphones for homework, we were forced to re-program the question types with a local programming firm.  Here is the latest code I received and it works in all desktop, android and iOS browsers for 2.8 and now we have tested it OK for 2.9.  I do not know if there is a github location, so I will check and post that later if I find it.

In reply to Don Hinkelman

Re: Ordering/"Drag-and-Drop" Question Trouble

by William Michael -

We found a second cause of trouble this morning...while the Jquery version solved the problem at the system level, a problem remained at the individual quiz level.

In the quiz settings for individual quizzes, under "Extra Restrictions on Attempts" there is a "Browser Security" setting that is intended to block copy-and-paste functionality to prevent cheating.  Unfortunately, this seems to block drag and drop activity in quizzes.  If you use a drag-and-drop question, set that setting to "None" (see below):

Hope that helps,

William Michael
Classical Liberal Arts Academy


Average of ratings: Useful (1)
In reply to William Michael

Re: Ordering/"Drag-and-Drop" Question Trouble

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I think you have something happening unrelated to the ordering question.  To give a little background the ordering question is maintained by Gordon Bateson. For me Gordon is somewhat of a Moodle deity, his HotPot module has been downloaded 270,000 odd times, so he knows what he is doing.  I recently had the good fortune to meet him, excellent chap. 

Anyway, when I was updating my Gapfill question type for compatibility with Moodle 2.9 I was inspired by Gordons Javascript code (OK, I copied it and mentioned him in the release notes).

So when I read that you were having problems with Ordering I was concerned that my Gapfill question type might have similar problems. Yesterday I tested my Gapfill and the latest of the Ordering type with Windows, Android and an iPad with "browser security" turned on and I did not see any error.

If your setup appears to be working now, then I would advise not fixing a non broken thing, but whatever the issue, I don't think it was the Ordering question type.

Let's see if I can sneak an advert in here....

I will be talking about Fill in the Blanks style questions at the mini iMoot (all online) this Friday. Apart from the fabulousness of hearing from me, there are some other excellent other presentations. Check it out at 

http://2015mini.imoot.org/



In reply to Marcus Green

Re: Ordering/"Drag-and-Drop" Question Trouble

by Don Hinkelman -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Note that there are two ordering question types.  There is the "ordering" question type maintained by Gordon Bateson and used primarily in the quizzes of the MoodleReader activity module--I see William is using that one. And there is also the "drag-and-drop ordering" question type which I am not certain who maintains it. For this last mobile phone compatibility fix, I guess you can say I was the one who got it maintained.  Our school uses both ordering types.

In reply to Don Hinkelman

Re: Ordering/"Drag-and-Drop" Question Trouble

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Ahh I understand now Don. It would be great if you could find a home on Github for your version. 

In reply to Marcus Green

Re: Ordering/"Drag-and-Drop" Question Trouble

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

William,

I have seen a situation before where a theme was including JQuery script itself and overwriting the JavaScript of other plugins such as the Ordering plugin, "qtype_ordering". 

  • layout/frontapage.php
  • layout/general.php

In that case, the solution was to amend the theme files to include JQuery using the Moodle API, as follows:

if (method_exists($PAGE->theme, 'get_theme_name')) {
// Moodle >= 2.2
$name = $PAGE->theme->get_theme_name();
} else {
// Moodle >= 2.0
$name = $PAGE->theme->name;
} if (method_exists($PAGE->requires, 'jquery')) {
// Moodle >= 2.5
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('cycle_lite', 'theme_'.$name);
$PAGE->requires->jquery_plugin('picfade', 'theme_'.$name);
} else {
// Moodle <= 2.4
$PAGE->requires->js('/theme/'.$name.'/jquery/jquery.js', true);
$PAGE->requires->js('/theme/'.$name.'/jquery/cycle_lite.js', true);
$PAGE->requires->js('/theme/'.$name.'/jquery/picfade.js', true);
}

And the theme should then put all its jquery files into a subfolder, "jquery", of the theme, along with a plugins.php formatted as per the Moodle docs page: JQuery

For example, here is the plugins.php for the above theme's JQuery folder:

$plugins = array(
    'cycle_lite' => array('files' => array('cycle_lite.js')),
    'picfade'    => array('files' => array('picfade.js'))
);

As long as all plugins are including JQuery using the Moodle API, then as far as I know, the Ordering question type works on all standard Moodle Themes, in all Moodle versions, on all common devices, i.e. PC's, tablets and Smartphones. If you find a situation where the Ordering plugin doesn't work, I would be grateful if you could tell me your Moodle version, theme, device and browser, so that I can investigate and fix the issue.

regards
Gordon