mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-16263 A way for students to flag/bookmark, particular questions during a quiz attempt for later review.
This is an initial implementation that is now at a working state, but with a few things left to do. It seemed like a good idea to commit it before leaving work on Friday night.
This commit is contained in:
parent
57f43d239a
commit
62e76c6766
18 changed files with 340 additions and 29 deletions
38
question/qengine.js
Normal file
38
question/qengine.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
// This script, and the YUI libraries that it needs, are inluded by
|
||||
// the require_js calls in get_html_head_contributions in lib/questionlib.php.
|
||||
|
||||
question_flag_changer = {
|
||||
init_flag: function(checkboxid, postdata) {
|
||||
var checkbox = document.getElementById(checkboxid);
|
||||
checkbox.ajaxpostdata = postdata;
|
||||
checkbox.className += ' jsworking';
|
||||
question_flag_changer.update_image(checkbox);
|
||||
YAHOO.util.Event.addListener(checkbox, 'change', this.checkbox_state_change);
|
||||
YAHOO.util.Event.addListener(checkbox, 'focus', 'blur()');
|
||||
},
|
||||
|
||||
checkbox_state_change: function(e) {
|
||||
var checkbox = e.target ? e.target : e.srcElement;
|
||||
question_flag_changer.update_image(checkbox);
|
||||
var postdata = checkbox.ajaxpostdata
|
||||
if (checkbox.checked) {
|
||||
postdata += '&newstate=1'
|
||||
} else {
|
||||
postdata += '&newstate=0'
|
||||
}
|
||||
YAHOO.util.Connect.asyncRequest('POST', qengine_config.wwwroot + '/question/toggleflag.php', null, postdata);
|
||||
},
|
||||
|
||||
update_image: function(checkbox) {
|
||||
var img = document.getElementById(checkbox.id + 'img');
|
||||
if (checkbox.checked) {
|
||||
img.src = qengine_config.pixpath + '/i/flagged.png';
|
||||
img.alt = qengine_config.flaggedalt;
|
||||
img.title = qengine_config.unflagtooltip;
|
||||
} else {
|
||||
img.src = qengine_config.pixpath + '/i/unflagged.png';
|
||||
img.alt = qengine_config.unflaggedalt;
|
||||
img.title = qengine_config.flagtooltip;
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue