edit/outcomeitem.php - fixed selection of outcomes to show only available course outcomes
This commit is contained in:
@@ -19,13 +19,9 @@ require_capability('moodle/course:update', $context);
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'outcomes', 'courseid'=>$courseid));
|
||||
|
||||
// first of all fix the state of outcomes_course table
|
||||
if (!$standardoutcomes = grade_outcome::fetch_all_global()) {
|
||||
$standardoutcomes = array();
|
||||
}
|
||||
if (!$co_custom = grade_outcome::fetch_all_local($courseid)) {
|
||||
$co_custom = array();
|
||||
}
|
||||
$co_standard_used = array();
|
||||
$standardoutcomes = grade_outcome::fetch_all_global();
|
||||
$co_custom = grade_outcome::fetch_all_local($courseid);
|
||||
$co_standard_used = array();
|
||||
$co_standard_notused = array();
|
||||
|
||||
if ($courseused = get_records('grade_outcomes_courses', 'courseid', $courseid, '', 'outcomeid')) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class edit_outcomeitem_form extends moodleform {
|
||||
|
||||
// allow setting of outcomes on module items too
|
||||
$options = array();
|
||||
if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$COURSE->id), true)) {
|
||||
if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
|
||||
foreach ($outcomes as $outcome) {
|
||||
$options[$outcome->id] = $outcome->get_name();
|
||||
}
|
||||
|
||||
@@ -162,20 +162,55 @@ class grade_outcome extends grade_object {
|
||||
|
||||
/**
|
||||
* Static function returning all global outcomes
|
||||
* @static
|
||||
* @return object
|
||||
*/
|
||||
function fetch_all_global() {
|
||||
return grade_outcome::fetch_all(array('courseid'=>null));
|
||||
if (!$outcomes = grade_outcome::fetch_all(array('courseid'=>null))) {
|
||||
$outcomes = array();
|
||||
}
|
||||
return $outcomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function returning all local course outcomes
|
||||
* @static
|
||||
* @param int $courseid
|
||||
* @return object
|
||||
*/
|
||||
function fetch_all_local($courseid) {
|
||||
return grade_outcome::fetch_all(array('courseid'=>$courseid));
|
||||
if (!$outcomes =grade_outcome::fetch_all(array('courseid'=>$courseid))) {
|
||||
$outcomes = array();
|
||||
}
|
||||
return $outcomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method - returns all outcomes available in course
|
||||
* @static
|
||||
* @param int $courseid
|
||||
* @return array
|
||||
*/
|
||||
function fetch_all_available($courseid) {
|
||||
global $CFG;
|
||||
|
||||
$result = array();
|
||||
$sql = "SELECT go.*
|
||||
FROM {$CFG->prefix}grade_outcomes go, {$CFG->prefix}grade_outcomes_courses goc
|
||||
WHERE go.id = goc.outcomeid AND goc.courseid = {$courseid}
|
||||
ORDER BY go.id ASC";
|
||||
|
||||
if ($datas = get_records_sql($sql)) {
|
||||
foreach($datas as $data) {
|
||||
$instance = new grade_outcome();
|
||||
grade_object::set_properties($instance, $data);
|
||||
$result[$instance->id] = $instance;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the most descriptive field for this object. This is a standard method used
|
||||
* when we do not know the exact type of an object.
|
||||
|
||||
Reference in New Issue
Block a user