mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
fixing course outcomes edit page to not use user preference but proper grade_outcomes_courses table, because course outcomes should not be a user preference
This commit is contained in:
parent
014834e40b
commit
0b06f5666d
@ -9,6 +9,9 @@
|
||||
|
||||
<?php
|
||||
foreach ($outcomes as $outcome) {
|
||||
if (in_array($outcome->id, array_keys($courseoutcomes))) {
|
||||
continue;
|
||||
}
|
||||
echo '<option value="'.$outcome->id.'">'.$outcome->get_name().'</option>';
|
||||
}
|
||||
?>
|
||||
@ -22,11 +25,11 @@
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<label for="removeoutcomes"><?php print_string('favoutcomes', 'grades'); ?></label>
|
||||
<label for="removeoutcomes"><?php print_string('courseoutcomes', 'grades'); ?></label>
|
||||
<br />
|
||||
<select id="removeoutcomes" size="20" name="removeoutcomes[]" multiple="multiple">
|
||||
<?php
|
||||
foreach ($favoutcomes as $outcome) {
|
||||
foreach ($courseoutcomes as $outcome) {
|
||||
echo '<option value="'.$outcome->id.'">'.$outcome->get_name().'</option>';
|
||||
}
|
||||
?>
|
||||
|
@ -15,69 +15,59 @@ require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:update', $context);
|
||||
|
||||
/// form processing
|
||||
if ($data = data_submitted()) {
|
||||
require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
if (!empty($data->add) && !empty($data->addoutcomes)) {
|
||||
/// add all selected to course list
|
||||
foreach ($data->addoutcomes as $add) {
|
||||
$goc -> courseid = $courseid;
|
||||
$goc -> outcomeid = $add;
|
||||
insert_record('grade_outcomes_courses', $goc);
|
||||
}
|
||||
} else if (!empty($data->remove) && !empty($data->removeoutcomes)) {
|
||||
/// remove all selected from course outcomes list
|
||||
foreach ($data->removeoutcomes as $remove) {
|
||||
delete_records('grade_outcomes_courses', 'courseid', $courseid, 'outcomeid', $remove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'favoutcomes', 'courseid'=>$courseid));
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$pagename = get_string('favoutcomes', 'grades');
|
||||
$pagename = get_string('courseoutcomes', 'grades');
|
||||
|
||||
$navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$pagename, 'link'=>'', 'type'=>'misc'));
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
if ($fav_outcomes_ids = get_user_preferences('grade_favourite_outcomes', null)) {
|
||||
$fav_outcomes_ids = unserialize($fav_outcomes_ids);
|
||||
} else {
|
||||
$fav_outcomes_ids = array();
|
||||
}
|
||||
|
||||
$outcomes = grade_outcome::fetch_all_global();
|
||||
$favoutcomes = array();
|
||||
foreach($outcomes as $outcome) {
|
||||
if (in_array($outcome->id, $fav_outcomes_ids)) {
|
||||
unset($outcomes[$outcome->id]);
|
||||
$favoutcomes[$outcome->id] = $outcome;
|
||||
$courseoutcomes = array();
|
||||
if ($coutcomes = get_records_sql('SELECT go.id, go.fullname
|
||||
FROM '.$CFG->prefix.'grade_outcomes_courses goc,
|
||||
'.$CFG->prefix.'grade_outcomes go
|
||||
WHERE goc.courseid = '.$courseid.'
|
||||
AND goc.outcomeid = go.id')) {
|
||||
foreach ($coutcomes as $id=>$coutcome) {
|
||||
$courseoutcomes[$id] = new grade_outcome(array('id'=>$id));
|
||||
}
|
||||
}
|
||||
|
||||
// store user preferences
|
||||
if ($data = data_submitted()) {
|
||||
if (!empty($data->add) && !empty($data->addoutcomes)) {
|
||||
/// add all selected to favourite list
|
||||
foreach ($data->addoutcomes as $add) {
|
||||
if (isset($outcomes[$add])) {
|
||||
$outcome = $outcomes[$add];
|
||||
unset($outcomes[$outcome->id]);
|
||||
$favoutcomes[$outcome->id] = $outcome;
|
||||
}
|
||||
}
|
||||
} else if (!empty($data->remove) && !empty($data->removeoutcomes)) {
|
||||
/// remove all selected from favourites
|
||||
foreach ($data->removeoutcomes as $remove) {
|
||||
if (isset($favoutcomes[$remove])) {
|
||||
$outcome = $favoutcomes[$remove];
|
||||
unset($favoutcomes[$outcome->id]);
|
||||
$outcomes[$outcome->id] = $outcome;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pref = array_keys($favoutcomes);
|
||||
$pref = serialize($pref);
|
||||
set_user_preference('grade_favourite_outcomes', $pref);
|
||||
if (empty($courseoutcomes)) {
|
||||
$courseoutcomes = grade_outcome::fetch_all(array('courseid'=>$courseid));
|
||||
} elseif ($mcourseoutcomes = grade_outcome::fetch_all(array('courseid'=>$courseid))) {
|
||||
$courseoutcomes += $mcourseoutcomes;
|
||||
}
|
||||
|
||||
/// Print header
|
||||
print_header_simple($strgrades.': '.$pagename, ': '.$strgrades, $navigation, '', '', true, '', navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'edit', 'favoutcomes');
|
||||
|
||||
print_grade_plugin_selector($courseid, 'edit', 'courseoutcomes');
|
||||
|
||||
check_theme_arrows();
|
||||
include_once('form.html');
|
||||
|
||||
print_footer($course);
|
||||
|
||||
|
||||
?>
|
||||
?>
|
@ -75,6 +75,7 @@ $string['configshowuserimage'] = 'Whether to show the user\'s profile image next
|
||||
$string['configstudentsperpage'] = 'The number of students to display per page in the grader report.';
|
||||
$string['configstudentsperpagedefault'] = 'The number of students to display per page in the grader report. Leave this field empty to use the site default (currently $a).';
|
||||
$string['contract'] = 'Contract Category';
|
||||
$string['courseoutcomes'] = 'Course outcomes';
|
||||
$string['createcategory'] = 'Create Category';
|
||||
$string['createcategoryerror'] = 'Could not create a new category';
|
||||
$string['creatinggradebooksettings'] = 'Creating Gradebook settings';
|
||||
@ -118,6 +119,7 @@ $string['finalgrade'] = 'Final grade';
|
||||
$string['forelementtypes'] = ' for the selected $a';
|
||||
$string['forstudents'] = 'For Students';
|
||||
$string['full'] = 'Full';
|
||||
$string['globaloutcomes'] = 'Global outcomes';
|
||||
$string['grade'] = 'Grade';
|
||||
$string['gradebook'] = 'Gradebook';
|
||||
$string['gradebookhiddenerror'] = 'The gradebook is currently set to hide everything from students.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user