Add the ability to select Outcomes in the Grade element (#329)
This commit is contained in:
parent
a5d51f2478
commit
c992d7a376
2 changed files with 56 additions and 32 deletions
|
@ -468,7 +468,7 @@ class element_helper {
|
||||||
$modules = array();
|
$modules = array();
|
||||||
|
|
||||||
// Collect course modules data.
|
// Collect course modules data.
|
||||||
$modinfo = get_fast_modinfo($course);
|
if ($modinfo = get_fast_modinfo($course)) {
|
||||||
$mods = $modinfo->get_cms();
|
$mods = $modinfo->get_cms();
|
||||||
$sections = $modinfo->get_section_info_all();
|
$sections = $modinfo->get_section_info_all();
|
||||||
|
|
||||||
|
@ -507,7 +507,9 @@ class element_helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get other non-module related grade items.
|
||||||
if ($gradeitems = \grade_item::fetch_all(['courseid' => $course->id])) {
|
if ($gradeitems = \grade_item::fetch_all(['courseid' => $course->id])) {
|
||||||
$arrgradeitems = [];
|
$arrgradeitems = [];
|
||||||
foreach ($gradeitems as $gi) {
|
foreach ($gradeitems as $gi) {
|
||||||
|
@ -525,6 +527,27 @@ class element_helper {
|
||||||
$modules = $modules + $arrgradeitems;
|
$modules = $modules + $arrgradeitems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get outcomes being used by activities.
|
||||||
|
if ($gradeitems = \grade_item::fetch_all(['courseid' => $course->id, 'gradetype' => GRADE_TYPE_SCALE,
|
||||||
|
'itemtype' => 'mod'])) {
|
||||||
|
$selectoutcomes = [];
|
||||||
|
foreach ($gradeitems as $gradeitem) {
|
||||||
|
// Get the name of the activity.
|
||||||
|
$cm = get_coursemodule_from_instance($gradeitem->itemmodule, $gradeitem->iteminstance, $course->id);
|
||||||
|
$modcontext = \context_module::instance($cm->id);
|
||||||
|
$modname = format_string($cm->name, true, array('context' => $modcontext));
|
||||||
|
|
||||||
|
$optionname = get_string('gradeoutcome', 'mod_customcert') . ' : ' .$modname . " - " . $gradeitem->get_name();
|
||||||
|
$selectoutcomes['gradeitem:' . $gradeitem->id] = $optionname;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alphabetise this.
|
||||||
|
asort($selectoutcomes);
|
||||||
|
|
||||||
|
// Merge results.
|
||||||
|
$modules = $modules + $selectoutcomes;
|
||||||
|
}
|
||||||
|
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ $string['fontcolour_help'] = 'The colour of the font.';
|
||||||
$string['fontsize'] = 'Size';
|
$string['fontsize'] = 'Size';
|
||||||
$string['fontsize_help'] = 'The size of the font in points.';
|
$string['fontsize_help'] = 'The size of the font in points.';
|
||||||
$string['getcustomcert'] = 'View certificate';
|
$string['getcustomcert'] = 'View certificate';
|
||||||
|
$string['gradeoutcome'] = 'Outcome';
|
||||||
$string['height'] = 'Height';
|
$string['height'] = 'Height';
|
||||||
$string['height_help'] = 'This is the height of the certificate PDF in mm. For reference an A4 piece of paper is 297mm high and a letter is 279mm high.';
|
$string['height_help'] = 'This is the height of the certificate PDF in mm. For reference an A4 piece of paper is 297mm high and a letter is 279mm high.';
|
||||||
$string['invalidcode'] = 'Invalid code supplied.';
|
$string['invalidcode'] = 'Invalid code supplied.';
|
||||||
|
|
Loading…
Reference in a new issue