Skip to content

Commit

Permalink
fix lang static lang strings (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syxton authored Jan 16, 2024
1 parent 660d828 commit 85fee8c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion classes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public static function show_description(array $modules, bool $showdescription):
\course_modinfo::purge_course_module_cache($cm->course, $cm->id);
}
} else {
throw new moodle_exception('Could not find course module with id ' . $cm->id);
throw new moodle_exception('invalidmoduleid', 'block_massaction', $cm->id);
}
}
}
Expand Down
23 changes: 18 additions & 5 deletions classes/event/course_modules_duplicated.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,28 @@ public function get_description(): string {
$cms = [];
$failed = [];
foreach ($this->other['cms'] as $srccm => $dstcm) {
$cms[] = 'cmid from \'' . $srccm . '\' to \'' . $dstcm . '\'';
$cms[] = get_string('event:duplicated_description',
'block_massaction',
['src' => $srccm,
'dst' => $dstcm,
]);
}

foreach ($this->other['failed'] as $cmid) {
$failed[] = 'cmid \'' . $cmid . '\'';
}
return 'Course modules duplicate has been completed. '
. 'Summary: ' . count($cms) . ' Completed, ' . count($failed) . ' Failed.'
. ($cms ? ' Completed ' . implode(", ", $cms) . '.' : '')
. ($failed ? ' Failed ' . implode(", ", $failed) . '.' : '');

return get_string('event:duplicated_summary',
'block_massaction',
['countcomplete' => count($cms),
'countfailed' => count($failed),
]) .
($cms ? get_string('event:duplicated_completed_list',
'block_massaction',
['list' => implode(', ', $cms)]) : '') .
($failed ? get_string('event:duplicated_failed_list',
'block_massaction',
['list' => implode(', ', $failed)]) : '');
}

/**
Expand Down
8 changes: 5 additions & 3 deletions classes/event/course_modules_duplicated_failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ public static function get_name(): string {
* @return string
*/
public function get_description(): string {
return 'Course modules duplicate failed. '
. 'cmid: ' . $this->other['cmid']
. 'error:' . $this->other['error'];
return get_string('event:duplicated_failed_description',
'block_massaction',
['cmid' => $this->other['cmid'],
'error' => $this->other['error'],
]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/massactionutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function duplicate_cm_to_course(object $course, object $cm): int {
}
}
if (empty($newcmid)) {
throw new \moodle_exception('Could not duplicate course module from id ' . $cm->id);
throw new \moodle_exception('duplicatefailed', 'block_massaction', $cm->id);
}
return $newcmid;
}
Expand Down
6 changes: 6 additions & 0 deletions lang/en/block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@
$string['confirmsectionselect'] = 'Choose section';
$string['deletecheck'] = 'Confirm mass deletion';
$string['deletecheckconfirm'] = 'Are you sure you want to delete the following module(s)?';
$string['duplicatefailed'] = 'Could not duplicate course module from id {$a}';
$string['duplicatemaxactivities'] = 'Maximum amount of course modules to duplicate';
$string['duplicatemaxactivities_description'] = 'Maximum amount of course modules which can be duplicated at the same time without running the process as background task. If set to "0" all duplication operations will be run as background task.';
$string['enablebulkediting'] = 'Enable bulk editing';
$string['event:course_modules_duplicated'] = 'Course modules duplicated';
$string['event:course_modules_duplicated_failed'] = 'Course modules failed to duplicate';
$string['event:duplicated_description'] = 'cmid from \'{$a->src}\' to \'{$a->dst}\'';
$string['event:duplicated_summary'] = 'Course module duplication has been completed. Summary: {$a->countcomplete} Completed, {$a->countfailed} Failed.';
$string['event:duplicated_completed_list'] = 'Completed {$a->list}.';
$string['event:duplicated_failed_list'] = 'Failed {$a->list}.';
$string['event:duplicated_failed_description'] = 'Course module duplication failed. cmid: {$a->cmid} error: {$a->error}';
$string['invalidaction'] = 'Unknown action: {$a}';
$string['invalidmoduleid'] = 'Invalid module ID: {$a}';
$string['invalidcoursemodule'] = 'Invalid course module';
Expand Down

0 comments on commit 85fee8c

Please sign in to comment.