Skip to content
Browse files

MDL-28471 make the question flag smaller, and give it a label.

  • Loading branch information...
1 parent 6f05796 commit 474ee9389abd3cd2d75b67382ebb5f7a20c09077 Wale Olujide committed with timhunt Jul 26, 2011
Showing with 29 additions and 3 deletions.
  1. +2 −0 lang/en/question.php
  2. +5 −1 question/engine/lib.php
  3. +22 −2 question/flags.js
View
2 lang/en/question.php
@@ -399,3 +399,5 @@
$string['withselected'] = 'With selected';
$string['xoutofmax'] = '{$a->mark} out of {$a->max}';
$string['yougotnright'] = 'You have correctly selected {$a->num}.';
+$string['clickflag'] = 'Flag question';
+$string['clickunflag'] = 'Unflag question';
View
6 question/engine/lib.php
@@ -632,20 +632,24 @@ public static function initialise_js() {
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
);
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
+ $fltext = 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, $fltext), false, $module);
$done = true;
}
}
View
24 question/flags.js
@@ -28,11 +28,13 @@
M.core_question_flags = {
flagattributes: null,
actionurl: null,
+ fltext: null,
listeners: [],
- init: function(Y, actionurl, flagattributes) {
+ init: function(Y, actionurl, flagattributes, fltext) {
M.core_question_flags.flagattributes = flagattributes;
M.core_question_flags.actionurl = actionurl;
+ M.core_question_flags.fltext = fltext;
Y.all('div.questionflag').each(function(flagdiv, i) {
var checkbox = flagdiv.one('input[type=checkbox]');
@@ -49,10 +51,18 @@ M.core_question_flags = {
var image = Y.Node.create('<input type="image" class="questionflagimage" />');
M.core_question_flags.update_flag(input, image);
+ // Create flag text
+ var flstatus = input.get('value');
+ var txt = M.core_question_flags.fltext[flstatus];
+ var flagtext = Y.Node.create('<span class="flag-text">');
+ flagtext.addClass(txt);
+ flagtext.append(txt);
+
checkbox.remove();
flagdiv.one('label').remove();
flagdiv.append(input);
flagdiv.append(image);
+ flagdiv.append(flagtext);
});
Y.delegate('click', function(e) {
@@ -69,7 +79,17 @@ M.core_question_flags = {
},
update_flag: function(input, image) {
- image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
+
+ YUI().use('node', function (Y) {
+ image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
+ // get flag text which is next to image element
+ var element = image.next();
+ // if element update its text
+ if(element){
+ element.set('innerText', M.core_question_flags.fltext[input.get('value')]);
+ }
+ });
+
},
add_listener: function(listener) {

0 comments on commit 474ee93

Please sign in to comment.
Something went wrong with that request. Please try again.