Discussions started by Ray Morris

Moodle in English -> Quiz -> Farewell

by Ray Morris -

After contributing a bit to the quiz module and other parts of Moodle, and making available some quiz related plugins, I am now moving to a different job, where Moodle isn't used. (I'm going back into the information security field). I've enjoyed meeting everyone and working with some of you.


If anything comes up with modules I've published here or whatever feel free to create new versions or whatever, don't wait for me to reply on any tracker issues I've been involved in, etc.  The new person who replaces me at my job may or may not be involved in the Moodle community very much, I don't know.

Average of ratings: -

If question attempts have answers recorded, but they are the "needsgrading" state, which function(s) need to be called to get them graded?  Or should they be graded at the time that answers are saved?


Background:

I am updating the papercopy module to work with Using Moodle 2.8, and making some improvements.  The module follows roughly this series of steps:


$usage = question_engine::make_questions_usage_by_activity

foreach($quiz_questions

    $usage->add_question($question);

}

...


//enter the student's answers for each of the questions

foreach($slotsas$slot){

$usage->process_action($slot, array('answer' =>$set['Question'.$slot]-1));

}

...


question_engine::save_questions_usage_by_activity($usage);

$attempt=newstdClass();

$attempt->quiz =$this->quiz->id; ...

$attempt_object=new quiz_attempt($attempt, $this->quiz, $this->cm, $this->course, true);

$attempt_object->process_finish(time(), true);


The full code is here:

https://github.com/MorrisR2/moodle-quiz_papercopy/blob/create_user_if_not_exist/report.php


What we end up with is a quiz attempt shows in the reports, and clicking on "Review attempt" shows which answers were selected for the questions, but the questions are as-yet ungraded.  The "state" of the question attempts == $needsgrading. What needs to be done to have the questions / quiz graded?




Average of ratings: -

Using Moodle 2.8, we'd like to use a work flow in which people can edit/revise/correct questions outside of Moodle, then import the new version of the question bank.   We'd like the import to work much as restore works - existing questions shouldn't be duplicated, but updated. 


So in other words, we could export the questions, send them off to Joe Bob for revision, then import the changes into Moodle.  At first glance, I don't see a way to do that within the export/import functions. Is that correct, or is there a way to accomplish this which I haven't seen?


If that functionality does not currently exist, does anyone have any thoughts on the possibility of adding it?  I see that the question ID is already included as a comment in at least the GIFT and Moodle XML export files, so it seems trivial to say "if we know the question ID, call update_record(), else call insert_record".  As I recall, question restore does essentially that (though with question.stamp rather than question.id), so I suppose that validates the concept.

Average of ratings: -

The multilang filter is nice in that it allows users to enter text in multiple languages at once.  However, it's slow and rather limited. I just tested a VERY simple solution that makes multilang:

  • Much faster
  • More comprehensive (it works _anywhere_ on the page)
  • More flexible (even use images, such as <img class="multilang" lang="en" src="stop_sign.en.jpg">)


The documentation warns that enabling the multilang filter for headers makes your site slower. 

In fact, enabling it for content requires the server to do a lot of work, slowing things down.  As some of us know, it also doesn't work everywhere- there are plenty of tracker issues about "multilang doesn't work here, and there, and it was forgotten over here".  I'm sure there are plenty more remaining.

It occurs to me that since IE7 (in 2006), browsers have been able to handle multilang tags in the same form Moodle uses, without Moodle needing to process every bit of text.  Moodle now requires IE9 or above, so we can use the functionality of "modern" browsers to make this far more efficient and flexible. Users don't really need to do anything different.  By changing the PHP code a bit we could just make it much, much faster by letting the browser do it's job - and the browser won't forget to handle it in names of things or the other dozens of places where multilang support is missing in Moodle.


Leveraging the fact that it's 2015 and we don't have to support browsers from 1997 anymore, just those made in the last ten years or so, multilang doesn't need to be limited to just span, either. The browser can easily handle div class="multilang" or img class="multilang", to show images of signs or other images that include language.  This could be achieved by simply having Moodle emit small bit of CSS:


.multilang[lang]{visibility: hidden; height: 0px; width: 0px; }
.multilang[lang~="en-us"],.multilang[lang~="en"]{visibility: visible; height: auto; width: auto; }


That's it, to completely replace almost all of the multilang filter. Just tell the browser to not display any multilang chunks other than the current language. All that parsing and processing replaced by one CSS statement. 

To replace the bit of multilang that allows for either a specific language dialect like "en-us" OR the parent type "en", we place the most specific first and add this line to hide the more general version if the specific version is already present:

.multilang[lang~="en-us"] ~ .multilang{visibilityhiddenheight0pxwidth0px}


What are your thoughts on doing this in this much faster, more efficient, and more flexible way eventually?  The one tradeoff I can think of is that as the old multilang which parses all of the html is deprecated, we'd add an instruction to put the most specific language first (the en-us version would come before the generic en version, unless they are one and the same).

I started to post this in the language support forum, but it occurred to me that wouldn't give a representative sample of opinions.  Those users and devs focused on language support may well be more willing to sacrifice much performance in order to avoid the slight change of having the most specific listed first.  Moodle users and devs in general may be more supportive of the increased performance and flexibility, and less concerned about the "cost" of needing to put the en-uk version before the generic en version.




Average of ratings: -

There is a new plugin available that allows you to filter your Quiz questions to see which questions have been used and which are unused.   It adds a drop down to the standard question bank view that you I use to manage questions and the one you use to add questions to a quiz.


https://moodle.org/plugins/view/local_unusedquestions

Average of ratings: Useful (2)