MDL-65937 mod_lesson: Replace concatenated strings with lang strings

This commit is contained in:
Jun Pataleta 2019-06-17 15:13:56 +08:00
parent ae612a5334
commit 32c7889212
2 changed files with 19 additions and 8 deletions

View File

@ -73,6 +73,8 @@ $string['answersfornumerical'] = 'Answers for numerical questions should be matc
$string['arrangebuttonshorizontally'] = 'Arrange content buttons horizontally?';
$string['attempt'] = 'Attempt: {$a}';
$string['attemptheader'] = 'Attempt';
$string['attemptinfonograde'] = '{$a->timestart} ({$a->duration})';
$string['attemptinfowithgrade'] = '{$a->grade}% {$a->timestart} ({$a->duration})';
$string['attempts'] = 'Attempts';
$string['attemptsdeleted'] = 'Deleted attempts';
$string['attemptsremaining'] = 'You have {$a} attempt(s) remaining';
@ -375,6 +377,7 @@ $string['nooverridedata'] = 'You must override at least one of the lesson settin
$string['noretake'] = 'You are not allowed to retake this lesson.';
$string['normal'] = 'Normal - follow lesson path';
$string['notcompleted'] = 'Not completed';
$string['notcompletedwithdate'] = 'Not completed ({$a})';
$string['notyetcompleted'] = 'Lesson has been started, but not yet completed';
$string['notdefined'] = 'Not defined';
$string['notenoughsubquestions'] = 'Not enough sub-questions have been defined!';

View File

@ -971,29 +971,37 @@ function lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup
'try' => $try['try'],
];
$attemptlinkcontents = '';
if ($try["grade"] !== null) { // if null then not done yet
// this is what the link does when the user has completed the try
$timetotake = $try["timeend"] - $try["timestart"];
$attemptlinkcontents .= $try["grade"]."%";
if ($try["grade"] > $bestgrade) {
$bestgrade = $try["grade"];
}
$attemptlinkcontents .= " ".userdate($try["timestart"]);
$attemptlinkcontents .= ", (".format_time($timetotake).")";
$attemptdata = (object)[
'grade' => $try["grade"],
'timestart' => userdate($try["timestart"]),
'duration' => format_time($timetotake),
];
$attemptlinkcontents = get_string('attemptinfowithgrade', 'lesson', $attemptdata);
} else {
if ($try["end"]) {
// User finished the lesson but has no grade. (Happens when there are only content pages).
$attemptlinkcontents .= " ".userdate($try["timestart"]);
$timetotake = $try["timeend"] - $try["timestart"];
$attemptlinkcontents .= ", (".format_time($timetotake).")";
$attemptdata = (object)[
'timestart' => userdate($try["timestart"]),
'duration' => format_time($timetotake),
];
$attemptlinkcontents = get_string('attemptinfonograde', 'lesson', $attemptdata);
} else {
// This is what the link does/looks like when the user has not completed the attempt.
$attemptlinkcontents .= get_string("notcompleted", "lesson");
if ($try['timestart'] !== 0) {
// Teacher previews do not track time spent.
$attemptlinkcontents .= " ".userdate($try["timestart"]);
$attemptlinkcontents = get_string("notcompletedwithdate", "lesson", userdate($try["timestart"]));
} else {
$attemptlinkcontents = get_string("notcompleted", "lesson");
}
$timetotake = null;
}