Skip to content

Commit

Permalink
MDL-30817 activity_completion: Fixed title and alt string (on checkbo…
Browse files Browse the repository at this point in the history
…x) to have module name prefixed
  • Loading branch information
Rajesh Taneja committed Mar 12, 2012
1 parent 476626d commit 337e789
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
20 changes: 14 additions & 6 deletions course/completion.js
Expand Up @@ -18,17 +18,21 @@ M.core_completion.init = function(Y) {

} else {
var current = args.state.get('value');

var modulename = args.modulename.get('value');
if (current == 1) {
var altstr = M.str.completion['completion-alt-manual-y'].replace('{$a}', modulename);
var titlestr = M.str.completion['completion-title-manual-y'].replace('{$a}', modulename);
args.state.set('value', 0);
args.image.set('src', M.util.image_url('i/completion-manual-y', 'moodle'));
args.image.set('alt', M.str.completion['completion-alt-manual-y']);
args.image.set('title', M.str.completion['completion-title-manual-y']);
args.image.set('alt', altstr);
args.image.set('title', titlestr);
} else {
var altstr = M.str.completion['completion-alt-manual-n'].replace('{$a}', modulename);
var titlestr = M.str.completion['completion-title-manual-n'].replace('{$a}', modulename);
args.state.set('value', 1);
args.image.set('src', M.util.image_url('i/completion-manual-n', 'moodle'));
args.image.set('alt', M.str.completion['completion-alt-manual-n']);
args.image.set('title', M.str.completion['completion-title-manual-n']);
args.image.set('alt', altstr);
args.image.set('title', titlestr);
}
}

Expand All @@ -48,6 +52,7 @@ M.core_completion.init = function(Y) {
var completionstate = 0;
var state = null;
var image = null;
var modulename = null;

var inputs = Y.Node.getDOMNode(form).getElementsByTagName('input');
for (var i=0; i<inputs.length; i++) {
Expand All @@ -59,6 +64,9 @@ M.core_completion.init = function(Y) {
completionstate = inputs[i].value;
state = Y.one(inputs[i]);
break;
case 'modulename':
modulename = Y.one(inputs[i]);
break;
}
if (inputs[i].type == 'image') {
image = Y.one(inputs[i]);
Expand All @@ -76,7 +84,7 @@ M.core_completion.init = function(Y) {
success: handle_success,
failure: handle_failure
},
arguments: {state: state, image: image, ajax: ajax}
arguments: {state: state, image: image, ajax: ajax, modulename: modulename}
};

Y.use('io-base', function(Y) {
Expand Down
5 changes: 3 additions & 2 deletions course/lib.php
Expand Up @@ -1733,9 +1733,9 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
if ($completionicon) {
$imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon);
$imgalt = s(get_string('completion-alt-'.$completionicon, 'completion'));
$imgalt = s(get_string('completion-alt-'.$completionicon, 'completion', $mod->name));
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
$imgtitle = s(get_string('completion-title-'.$completionicon, 'completion'));
$imgtitle = s(get_string('completion-title-'.$completionicon, 'completion', $mod->name));
$newstate =
$completiondata->completionstate==COMPLETION_COMPLETE
? COMPLETION_INCOMPLETE
Expand All @@ -1754,6 +1754,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
echo "
<form class='togglecompletion$extraclass' method='post' action='".$CFG->wwwroot."/course/togglecompletion.php'><div>
<input type='hidden' name='id' value='{$mod->id}' />
<input type='hidden' name='modulename' value='".s($mod->name)."' />
<input type='hidden' name='sesskey' value='".sesskey()."' />
<input type='hidden' name='completionstate' value='$newstate' />
<input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' />
Expand Down
12 changes: 6 additions & 6 deletions lang/en/completion.php
Expand Up @@ -36,12 +36,12 @@
$string['completion_link'] = 'activity/completion';
$string['completion-alt-auto-enabled'] = 'The system marks this item complete according to conditions';
$string['completion-alt-auto-fail'] = 'Completed (did not achieve pass grade)';
$string['completion-alt-auto-n'] = 'Not completed';
$string['completion-alt-auto-n'] = 'Not completed: {$a}';
$string['completion-alt-auto-pass'] = 'Completed (achieved pass grade)';
$string['completion-alt-auto-y'] = 'Completed';
$string['completion-alt-auto-y'] = 'Completed: {$a}';
$string['completion-alt-manual-enabled'] = 'Students can manually mark this item complete';
$string['completion-alt-manual-n'] = 'Not completed; select to mark as complete';
$string['completion-alt-manual-y'] = 'Completed; select to mark as not complete';
$string['completion-alt-manual-n'] = 'Not completed: {$a}. Select to mark as complete.';
$string['completion-alt-manual-y'] = 'Completed: {$a}. Select to mark as not complete.';
$string['completion_automatic'] = 'Show activity as complete when conditions are met';
$string['completiondisabled'] = 'Disabled, not shown in activity settings';
$string['completionexpected'] = 'Expect completed on';
Expand All @@ -54,8 +54,8 @@
If a blank tick box is shown, a tick will appear automatically when you have completed the activity according to conditions set by the teacher.';
$string['completion_manual'] = 'Students can manually mark the activity as completed';
$string['completion_none'] = 'Do not indicate activity completion';
$string['completion-title-manual-n'] = 'Mark as complete';
$string['completion-title-manual-y'] = 'Mark as not complete';
$string['completion-title-manual-n'] = 'Mark as complete: {$a}';
$string['completion-title-manual-y'] = 'Mark as not complete: {$a}';
$string['completionnotenabled'] = 'Completion is not enabled';
$string['completionnotenabledforcourse'] = 'Completion is not enabled for this course';
$string['completionnotenabledforsite'] = 'Completion is not enabled for this site';
Expand Down

0 comments on commit 337e789

Please sign in to comment.