Permalink
Browse files

Merge branch 'MDL-28471' of git://github.com/timhunt/moodle

  • Loading branch information...
2 parents 48fa0c7 + 22c97c6 commit 74b0ad6a4d4af80dd8398355f89515194363547a @skodak skodak committed Aug 2, 2011
View
@@ -65,8 +65,10 @@
$string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of them may be old, hidden, questions that are still in use in some existing quizzes). Please choose another category to move them to.';
$string['categorymoveto'] = 'Save in category';
$string['categorynamecantbeblank'] = 'The category name cannot be blank.';
-$string['clicktoflag'] = 'Click to flag this question';
-$string['clicktounflag'] = 'Click to un-flag this question';
+$string['clickflag'] = 'Flag question';
+$string['clicktoflag'] = 'Flag this question for future reference';
+$string['clicktounflag'] = 'Remove flag';
+$string['clickunflag'] = 'Remove flag';
$string['contexterror'] = 'You shouldn\'t have got here if you\'re not moving a category to another context.';
$string['copy'] = 'Copy from {$a} and change links.';
$string['created'] = 'Created';
@@ -298,8 +300,6 @@
$string['changeoptions'] = 'Change options';
$string['check'] = 'Check';
$string['clearwrongparts'] = 'Clear incorrect responses';
-$string['clicktoflag'] = 'Click to flag this question';
-$string['clicktounflag'] = 'Click to un-flag this question';
$string['closepreview'] = 'Close preview';
$string['combinedfeedback'] = 'Combined feedback';
$string['commented'] = 'Commented: {$a}';
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -632,20 +632,26 @@ public static function initialise_js() {
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
);
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
+ $flagtext = array(
+ 0 => get_string('clickflag', 'question'),
+ 1 => get_string('clickunflag', 'question')
+ );
$flagattributes = array(
0 => array(
'src' => $OUTPUT->pix_url('i/unflagged') . '',
'title' => get_string('clicktoflag', 'question'),
'alt' => get_string('notflagged', 'question'),
+ // 'text' => get_string('clickflag', 'question'),
),
1 => array(
'src' => $OUTPUT->pix_url('i/flagged') . '',
'title' => get_string('clicktounflag', 'question'),
'alt' => get_string('flagged', 'question'),
+ // 'text' => get_string('clickunflag', 'question'),
),
);
$PAGE->requires->js_init_call('M.core_question_flags.init',
- array($actionurl, $flagattributes), false, $module);
+ array($actionurl, $flagattributes, $flagtext), false, $module);
$done = true;
}
}
@@ -243,16 +243,25 @@ protected function question_flag(question_attempt $qa, $flagsoption) {
* @return string the img tag.
*/
protected function get_flag_html($flagged, $id = '') {
+ if ($flagged) {
+ $icon = 'i/flagged';
+ $alt = get_string('flagged', 'question');
+ } else {
+ $icon = 'i/unflagged';
+ $alt = get_string('notflagged', 'question');
+ }
+ $attributes = array(
+ 'src' => $this->pix_url($icon),
+ 'alt' => $alt,
+ );
if ($id) {
- $id = 'id="' . $id . '" ';
+ $attributes['id'] = $id;
}
+ $img = html_writer::empty_tag('img', $attributes);
if ($flagged) {
- $img = 'flagged';
- } else {
- $img = 'unflagged';
+ $img .= ' ' . get_string('flagged', 'question');
}
- return '<img ' . $id . 'src="' . $this->pix_url('/i/' . $img) .
- '" alt="' . get_string('flagthisquestion', 'question') . '" />';
+ return $img;
}
protected function edit_question_link(question_attempt $qa,
View
@@ -28,48 +28,57 @@
M.core_question_flags = {
flagattributes: null,
actionurl: null,
+ flagtext: null,
listeners: [],
- init: function(Y, actionurl, flagattributes) {
+ init: function(Y, actionurl, flagattributes, flagtext) {
M.core_question_flags.flagattributes = flagattributes;
M.core_question_flags.actionurl = actionurl;
+ M.core_question_flags.flagtext = flagtext;
Y.all('div.questionflag').each(function(flagdiv, i) {
var checkbox = flagdiv.one('input[type=checkbox]');
if (!checkbox) {
return;
}
- var input = Y.Node.create('<input type="hidden" />');
+ var input = Y.Node.create('<input type="hidden" class="questionflagvalue" />');
input.set('id', checkbox.get('id'));
input.set('name', checkbox.get('name'));
input.set('value', checkbox.get('checked') ? 1 : 0);
// Create an image input to replace the img tag.
var image = Y.Node.create('<input type="image" class="questionflagimage" />');
- M.core_question_flags.update_flag(input, image);
+ var flagtext = Y.Node.create('<span class="questionflagtext">.</span>');
+ M.core_question_flags.update_flag(input, image, flagtext);
checkbox.remove();
flagdiv.one('label').remove();
flagdiv.append(input);
flagdiv.append(image);
+ flagdiv.append(flagtext);
});
Y.delegate('click', function(e) {
- var input = this.previous('input');
+ var input = this.one('input.questionflagvalue');
input.set('value', 1 - input.get('value'));
- M.core_question_flags.update_flag(input, this);
- var postdata = this.previous('input.questionflagpostdata').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();
Y.io(M.core_question_flags.actionurl , {method: 'POST', 'data': postdata});
M.core_question_flags.fire_listeners(postdata);
- }, document.body, 'input.questionflagimage');
+ }, document.body, 'div.questionflag');
},
- update_flag: function(input, image) {
- image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
+ update_flag: function(input, image, flagtext) {
+ var value = input.get('value');
+ image.setAttrs(M.core_question_flags.flagattributes[value]);
+ flagtext.replaceChild(flagtext.create(M.core_question_flags.flagtext[value]),
+ flagtext.get('firstChild'));
+ flagtext.set('title', M.core_question_flags.flagattributes[value].title);
},
add_listener: function(listener) {
@@ -38,15 +38,17 @@ body.jsenabled #qtypechoicecontainer {display: block;}
.que {clear: left;text-align: left;margin: 0 auto 1.8em auto;}
.dir-rtl .que {text-align: right;}
-.que .info {float: left;width: 6em;padding:0.5em;margin-bottom: 1.8em;background: #eee;}
+.que .info {float: left;width: 7em;padding:0.5em;margin-bottom: 1.8em;background: #eee;}
.que h2.no {margin: 0;font-size: 0.8em;line-height: 1;}
.que span.qno {font-size: 1.5em;font-weight:bold;}
-.que .state,
-.que .grade,
-.que .editquestion {font-size: 0.8em; margin-top: 0.7em;}
-.que .info .questionflag {margin-top: 1em;margin-right: 1em;text-align: center;}
+.que .info * {font-size: 0.8em;}
+.que .info .state,
+.que .info .grade,
+.que .info .editquestion,
+.que .info .questionflag {margin-top: 0.7em;}
+.que .info .questionflag {cursor:pointer;}
-.que .content {margin: 0 0 0 7.5em;}
+.que .content {margin: 0 0 0 8.5em;}
.que .formulation,
.que .outcome,

0 comments on commit 74b0ad6

Please sign in to comment.