Source: http://www.businessethicsalliance.org/blog/pop-quiz-how-would-you-define-community-responsibility/ |
How would you like to transform your humble Quiz Navigation section into a mini Information System?
Now you can, thanks to Michael Weston and Tim Hunt, who bounced this brilliant idea around from conception to fruition. Michael asked if the Quiz Navigation question links could display the quiz question text on mouseover:
"I'm using Moodle 2.3. I have a quiz that is 120 questions long, and it is setup to display 1 question per page so the student never sees the full list of questions on one page.
The question number navigation shows the numbers of the questions and the color changes indicating which questions have been answered.
If I put my mouse over the number it either tells me "Answer saved" or "Not yet answered" Because of the number of questions in my quiz, it would be helpful to give a little more feedback to the students.
Is it possible to have the mouseover text bring up the question text? If a student navigates to question 70 of the quiz and wants to quickly review certain questions, it would be nice if they didn't have to click on each number to find out what the question was."
In Moodle 2.5, refer to the image below and edit function get_state_string() that is found inside the file moodle/mod/quiz/attemptlib.php.
The code uses the PHP function shorten_text(...,200) to reduce the mouseover display of a question to 200 characters. Otherwise, by default, shorten_text() works on reducing the string to 30 characters. For your convenience, here's the code in softcopy.
protected function get_state_string(question_attempt $qa, $showcorrectness) {
if ($qa->get_question()->length > 0) {
//return $qa->get_state_string($showcorrectness);
/* Added by Frankie on 26th Sept 2013 */
$question = $qa->get_question();
return shorten_text($question->html_to_text($question->questiontext,
$question->questiontextformat),200);
}
// Special case handling for 'information' items.
if ($qa->get_state() == question_state::$todo) {
return get_string('notyetviewed', 'quiz');
} else {
return get_string('viewed', 'quiz');
}
}
Here's the glorious outcome of this hack. Isn't she a beauty? Simple gorgeous!
In my opinion, this feature breathes life into the, otherwise dull, Quiz Navigation section links. It's a wonder why this isn't part of Moodle core 2.x. Here's to making quiz making an art form!
If you have found this post to be most useful and intend to incorporate the short but potent hack in your site's Moodle 2.x code, do let me know by commenting on this post.
Regards
Frankie Kam
No comments:
Post a Comment