mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-71305-master' of git://github.com/rezaies/moodle
This commit is contained in:
commit
2431f7bff8
5 changed files with 71 additions and 52 deletions
|
@ -79,3 +79,4 @@ loggedoffdescription,core_message
|
||||||
sendingvia,core_message
|
sendingvia,core_message
|
||||||
sendingviawhen,core_message
|
sendingviawhen,core_message
|
||||||
close,core_contentbank
|
close,core_contentbank
|
||||||
|
notflagged,core_question
|
||||||
|
|
|
@ -253,7 +253,6 @@ $string['notagfiltersapplied'] = 'No tag filters applied';
|
||||||
$string['notenoughanswers'] = 'This type of question requires at least {$a} answers';
|
$string['notenoughanswers'] = 'This type of question requires at least {$a} answers';
|
||||||
$string['notenoughdatatoeditaquestion'] = 'Neither a question id, nor a category id and question type, was specified.';
|
$string['notenoughdatatoeditaquestion'] = 'Neither a question id, nor a category id and question type, was specified.';
|
||||||
$string['notenoughdatatomovequestions'] = 'You need to provide the question ids of questions you want to move.';
|
$string['notenoughdatatomovequestions'] = 'You need to provide the question ids of questions you want to move.';
|
||||||
$string['notflagged'] = 'Not flagged';
|
|
||||||
$string['novirtualquestiontype'] = 'No virtual question type for question type {$a}';
|
$string['novirtualquestiontype'] = 'No virtual question type for question type {$a}';
|
||||||
$string['numqas'] = 'No. question attempts';
|
$string['numqas'] = 'No. question attempts';
|
||||||
$string['numquestions'] = 'No. questions';
|
$string['numquestions'] = 'No. questions';
|
||||||
|
@ -356,8 +355,6 @@ $string['defaultmark'] = 'Default mark';
|
||||||
$string['errorsavingflags'] = 'Error saving the flag state.';
|
$string['errorsavingflags'] = 'Error saving the flag state.';
|
||||||
$string['feedback'] = 'Feedback';
|
$string['feedback'] = 'Feedback';
|
||||||
$string['fillincorrect'] = 'Fill in correct responses';
|
$string['fillincorrect'] = 'Fill in correct responses';
|
||||||
$string['flagged'] = 'Flagged';
|
|
||||||
$string['flagthisquestion'] = 'Flag this question';
|
|
||||||
$string['generalfeedback'] = 'General feedback';
|
$string['generalfeedback'] = 'General feedback';
|
||||||
$string['generalfeedback_help'] = 'General feedback is shown to the student after they have completed the question. Unlike specific feedback, which depends on the question type and what response the student gave, the same general feedback text is shown to all students.
|
$string['generalfeedback_help'] = 'General feedback is shown to the student after they have completed the question. Unlike specific feedback, which depends on the question type and what response the student gave, the same general feedback text is shown to all students.
|
||||||
|
|
||||||
|
@ -390,7 +387,6 @@ $string['markoutofmax'] = 'Mark {$a->mark} out of {$a->max}';
|
||||||
$string['marks'] = 'Marks';
|
$string['marks'] = 'Marks';
|
||||||
$string['noresponse'] = '[No response]';
|
$string['noresponse'] = '[No response]';
|
||||||
$string['notanswered'] = 'Not answered';
|
$string['notanswered'] = 'Not answered';
|
||||||
$string['notflagged'] = 'Not flagged';
|
|
||||||
$string['notgraded'] = 'Not graded';
|
$string['notgraded'] = 'Not graded';
|
||||||
$string['notshown'] = 'Not shown';
|
$string['notshown'] = 'Not shown';
|
||||||
$string['notyetanswered'] = 'Not yet answered';
|
$string['notyetanswered'] = 'Not yet answered';
|
||||||
|
@ -455,7 +451,6 @@ $string['restoremultipletopcats'] = 'The backup file contains more than one top-
|
||||||
$string['rightanswer'] = 'Right answer';
|
$string['rightanswer'] = 'Right answer';
|
||||||
$string['rightanswer_help'] = 'An automatically generated summary of the correct response. This can be limited, so you may wish to consider explaining the correct solution in the general feedback for the question, and turning this option off.';
|
$string['rightanswer_help'] = 'An automatically generated summary of the correct response. This can be limited, so you may wish to consider explaining the correct solution in the general feedback for the question, and turning this option off.';
|
||||||
$string['saved'] = 'Saved: {$a}';
|
$string['saved'] = 'Saved: {$a}';
|
||||||
$string['saveflags'] = 'Save the state of the flags';
|
|
||||||
$string['settingsformultipletries'] = 'Multiple tries';
|
$string['settingsformultipletries'] = 'Multiple tries';
|
||||||
$string['showhidden'] = 'Also show old questions';
|
$string['showhidden'] = 'Also show old questions';
|
||||||
$string['showmarkandmax'] = 'Show mark and max';
|
$string['showmarkandmax'] = 'Show mark and max';
|
||||||
|
@ -501,3 +496,6 @@ $string['yougotnright'] = 'You have correctly selected {$a->num}.';
|
||||||
$string['qbanknotfound'] = 'The \'{$a}\' question bank plugin doesn\'t exist or is not recognised.';
|
$string['qbanknotfound'] = 'The \'{$a}\' question bank plugin doesn\'t exist or is not recognised.';
|
||||||
$string['noquestionbanks'] = 'No question bank plugin found.';
|
$string['noquestionbanks'] = 'No question bank plugin found.';
|
||||||
$string['questionloaderror'] = 'Could not load the question options.';
|
$string['questionloaderror'] = 'Could not load the question options.';
|
||||||
|
|
||||||
|
// Deprecated since Moodle 4.0.
|
||||||
|
$string['notflagged'] = 'Not flagged';
|
||||||
|
|
|
@ -747,26 +747,22 @@ abstract class question_flags {
|
||||||
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
|
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
|
||||||
);
|
);
|
||||||
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
|
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
|
||||||
$flagtext = array(
|
|
||||||
0 => get_string('clickflag', 'question'),
|
|
||||||
1 => get_string('clickunflag', 'question')
|
|
||||||
);
|
|
||||||
$flagattributes = array(
|
$flagattributes = array(
|
||||||
0 => array(
|
0 => array(
|
||||||
'src' => $OUTPUT->image_url('i/unflagged') . '',
|
'src' => $OUTPUT->image_url('i/unflagged') . '',
|
||||||
'title' => get_string('clicktoflag', 'question'),
|
'title' => get_string('clicktoflag', 'question'),
|
||||||
'alt' => get_string('notflagged', 'question'),
|
'alt' => get_string('flagged', 'question'), // Label on toggle should not change.
|
||||||
// 'text' => get_string('clickflag', 'question'),
|
'text' => get_string('clickflag', 'question'),
|
||||||
),
|
),
|
||||||
1 => array(
|
1 => array(
|
||||||
'src' => $OUTPUT->image_url('i/flagged') . '',
|
'src' => $OUTPUT->image_url('i/flagged') . '',
|
||||||
'title' => get_string('clicktounflag', 'question'),
|
'title' => get_string('clicktounflag', 'question'),
|
||||||
'alt' => get_string('flagged', 'question'),
|
'alt' => get_string('flagged', 'question'),
|
||||||
// 'text' => get_string('clickunflag', 'question'),
|
'text' => get_string('clickunflag', 'question'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$PAGE->requires->js_init_call('M.core_question_flags.init',
|
$PAGE->requires->js_init_call('M.core_question_flags.init',
|
||||||
array($actionurl, $flagattributes, $flagtext), false, $module);
|
array($actionurl, $flagattributes), false, $module);
|
||||||
$done = true;
|
$done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,8 +256,6 @@ class core_question_renderer extends plugin_renderer_base {
|
||||||
* @param int $flagsoption the option that says whether flags should be displayed.
|
* @param int $flagsoption the option that says whether flags should be displayed.
|
||||||
*/
|
*/
|
||||||
protected function question_flag(question_attempt $qa, $flagsoption) {
|
protected function question_flag(question_attempt $qa, $flagsoption) {
|
||||||
global $CFG;
|
|
||||||
|
|
||||||
$divattributes = array('class' => 'questionflag');
|
$divattributes = array('class' => 'questionflag');
|
||||||
|
|
||||||
switch ($flagsoption) {
|
switch ($flagsoption) {
|
||||||
|
@ -283,17 +281,14 @@ class core_question_renderer extends plugin_renderer_base {
|
||||||
|
|
||||||
$flagcontent = html_writer::empty_tag('input',
|
$flagcontent = html_writer::empty_tag('input',
|
||||||
array('type' => 'hidden', 'name' => $id, 'value' => 0)) .
|
array('type' => 'hidden', 'name' => $id, 'value' => 0)) .
|
||||||
html_writer::empty_tag('input', $checkboxattributes) .
|
|
||||||
html_writer::empty_tag('input',
|
html_writer::empty_tag('input',
|
||||||
array('type' => 'hidden', 'value' => $postdata, 'class' => 'questionflagpostdata')) .
|
array('type' => 'hidden', 'value' => $postdata, 'class' => 'questionflagpostdata')) .
|
||||||
|
html_writer::empty_tag('input', $checkboxattributes) .
|
||||||
html_writer::tag('label', $this->get_flag_html($qa->is_flagged(), $id . 'img'),
|
html_writer::tag('label', $this->get_flag_html($qa->is_flagged(), $id . 'img'),
|
||||||
array('id' => $id . 'label', 'for' => $id . 'checkbox')) . "\n";
|
array('id' => $id . 'label', 'for' => $id . 'checkbox')) . "\n";
|
||||||
|
|
||||||
$divattributes = array(
|
$divattributes = array(
|
||||||
'class' => 'questionflag editable',
|
'class' => 'questionflag editable',
|
||||||
'aria-atomic' => 'true',
|
|
||||||
'aria-relevant' => 'text',
|
|
||||||
'aria-live' => 'assertive',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -315,18 +310,16 @@ class core_question_renderer extends plugin_renderer_base {
|
||||||
protected function get_flag_html($flagged, $id = '') {
|
protected function get_flag_html($flagged, $id = '') {
|
||||||
if ($flagged) {
|
if ($flagged) {
|
||||||
$icon = 'i/flagged';
|
$icon = 'i/flagged';
|
||||||
$alt = get_string('flagged', 'question');
|
|
||||||
$label = get_string('clickunflag', 'question');
|
$label = get_string('clickunflag', 'question');
|
||||||
} else {
|
} else {
|
||||||
$icon = 'i/unflagged';
|
$icon = 'i/unflagged';
|
||||||
$alt = get_string('notflagged', 'question');
|
|
||||||
$label = get_string('clickflag', 'question');
|
$label = get_string('clickflag', 'question');
|
||||||
}
|
}
|
||||||
$attributes = array(
|
$attributes = [
|
||||||
'src' => $this->image_url($icon),
|
'src' => $this->image_url($icon),
|
||||||
'alt' => $alt,
|
'alt' => '',
|
||||||
'class' => 'questionflagimage',
|
'class' => 'questionflagimage',
|
||||||
);
|
];
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$attributes['id'] = $id;
|
$attributes['id'] = $id;
|
||||||
}
|
}
|
||||||
|
@ -336,10 +329,14 @@ class core_question_renderer extends plugin_renderer_base {
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function edit_question_link(question_attempt $qa,
|
/**
|
||||||
question_display_options $options) {
|
* Generate the display of the edit question link.
|
||||||
global $CFG;
|
*
|
||||||
|
* @param question_attempt $qa The question attempt to display.
|
||||||
|
* @param question_display_options $options controls what should and should not be displayed.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function edit_question_link(question_attempt $qa, question_display_options $options) {
|
||||||
if (empty($options->editquestionparams)) {
|
if (empty($options->editquestionparams)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,11 @@
|
||||||
M.core_question_flags = {
|
M.core_question_flags = {
|
||||||
flagattributes: null,
|
flagattributes: null,
|
||||||
actionurl: null,
|
actionurl: null,
|
||||||
flagtext: null,
|
|
||||||
listeners: [],
|
listeners: [],
|
||||||
|
|
||||||
init: function(Y, actionurl, flagattributes, flagtext) {
|
init: function(Y, actionurl, flagattributes) {
|
||||||
M.core_question_flags.flagattributes = flagattributes;
|
M.core_question_flags.flagattributes = flagattributes;
|
||||||
M.core_question_flags.actionurl = actionurl;
|
M.core_question_flags.actionurl = actionurl;
|
||||||
M.core_question_flags.flagtext = flagtext;
|
|
||||||
|
|
||||||
Y.all('div.questionflag').each(function(flagdiv, i) {
|
Y.all('div.questionflag').each(function(flagdiv, i) {
|
||||||
var checkbox = flagdiv.one('input[type=checkbox]');
|
var checkbox = flagdiv.one('input[type=checkbox]');
|
||||||
|
@ -47,38 +45,67 @@ M.core_question_flags = {
|
||||||
input.set('name', checkbox.get('name'));
|
input.set('name', checkbox.get('name'));
|
||||||
input.set('value', checkbox.get('checked') ? 1 : 0);
|
input.set('value', checkbox.get('checked') ? 1 : 0);
|
||||||
|
|
||||||
// Create an image input to replace the img tag.
|
var ariaPressed = checkbox.get('checked') ? 'true' : 'false';
|
||||||
var image = Y.Node.create('<input type="image" class="questionflagimage" />');
|
var toggle = Y.Node.create('<a ' +
|
||||||
var flagtext = Y.Node.create('<span class="questionflagtext">.</span>');
|
'tabindex="0" ' +
|
||||||
M.core_question_flags.update_flag(input, image, flagtext);
|
'class="aabtn" ' +
|
||||||
|
'role="button" ' +
|
||||||
|
'aria-pressed="' + ariaPressed + '">' +
|
||||||
|
'.' +
|
||||||
|
'</a>');
|
||||||
|
M.core_question_flags.update_flag(input, toggle);
|
||||||
|
|
||||||
checkbox.remove();
|
checkbox.remove();
|
||||||
flagdiv.one('label').remove();
|
flagdiv.one('label').remove();
|
||||||
flagdiv.append(input);
|
flagdiv.append(input);
|
||||||
flagdiv.append(image);
|
flagdiv.append(toggle);
|
||||||
flagdiv.append(flagtext);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Y.delegate('click', function(e) {
|
Y.delegate('click', function(e) {
|
||||||
var input = this.one('input.questionflagvalue');
|
|
||||||
input.set('value', 1 - input.get('value'));
|
|
||||||
M.core_question_flags.update_flag(input, this.one('input.questionflagimage'),
|
|
||||||
this.one('span.questionflagtext'));
|
|
||||||
var postdata = this.one('input.questionflagpostdata').get('value') +
|
|
||||||
input.get('value');
|
|
||||||
|
|
||||||
e.halt();
|
e.halt();
|
||||||
Y.io(M.core_question_flags.actionurl , {method: 'POST', 'data': postdata});
|
M.core_question_flags.process(this);
|
||||||
M.core_question_flags.fire_listeners(postdata);
|
|
||||||
}, document.body, 'div.questionflag');
|
}, document.body, 'div.questionflag');
|
||||||
|
Y.delegate('key', function(e) {
|
||||||
|
e.halt();
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
M.core_question_flags.process(this);
|
||||||
|
}
|
||||||
|
}, document.body, 'down:enter, space', 'div.questionflag');
|
||||||
|
Y.delegate('key', function(e) {
|
||||||
|
e.halt();
|
||||||
|
M.core_question_flags.process(this);
|
||||||
|
}, document.body, 'up:space', 'div.questionflag');
|
||||||
},
|
},
|
||||||
|
|
||||||
update_flag: function(input, image, flagtext) {
|
update_flag: function(input, toggle) {
|
||||||
var value = input.get('value');
|
var value = input.get('value');
|
||||||
image.setAttrs(M.core_question_flags.flagattributes[value]);
|
toggle.setContent(
|
||||||
flagtext.replaceChild(flagtext.create(M.core_question_flags.flagtext[value]),
|
'<img class="questionflagimage" src="' + M.core_question_flags.flagattributes[value].src + '" alt="" />' +
|
||||||
flagtext.get('firstChild'));
|
M.core_question_flags.flagattributes[value].text
|
||||||
flagtext.set('title', M.core_question_flags.flagattributes[value].title);
|
);
|
||||||
|
toggle.set('aria-pressed', parseInt(value) ? 'true' : 'false');
|
||||||
|
toggle.set('aria-label', M.core_question_flags.flagattributes[value].alt);
|
||||||
|
if (M.core_question_flags.flagattributes[value].title != M.core_question_flags.flagattributes[value].text) {
|
||||||
|
toggle.set('title', M.core_question_flags.flagattributes[value].title);
|
||||||
|
} else {
|
||||||
|
toggle.removeAttribute('title');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the change of flag status.
|
||||||
|
*
|
||||||
|
* @param {Y.Node} target The root element
|
||||||
|
*/
|
||||||
|
process: function(target) {
|
||||||
|
var input = target.one('input.questionflagvalue');
|
||||||
|
input.set('value', 1 - input.get('value'));
|
||||||
|
M.core_question_flags.update_flag(input, target.one('[aria-pressed]'));
|
||||||
|
var postdata = target.one('input.questionflagpostdata').get('value') +
|
||||||
|
input.get('value');
|
||||||
|
|
||||||
|
Y.io(M.core_question_flags.actionurl, {method: 'POST', 'data': postdata});
|
||||||
|
M.core_question_flags.fire_listeners(postdata);
|
||||||
},
|
},
|
||||||
|
|
||||||
add_listener: function(listener) {
|
add_listener: function(listener) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue