Skip to content

Commit

Permalink
MDL-13849 add API method to use outcome in course into grade_outcome …
Browse files Browse the repository at this point in the history
…class; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Mar 8, 2008
1 parent bf9211e commit b0f44d8
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/grade/grade_outcome.php
Expand Up @@ -129,17 +129,31 @@ function update($source=null) {

if ($result = parent::update($source)) {
if (!empty($this->courseid)) {
if (!get_records('grade_outcomes_courses', 'courseid', $this->courseid, 'outcomeid', $this->id)) {
$goc = new object();
$goc->courseid = $this->courseid;
$goc->outcomeid = $this->id;
insert_record('grade_outcomes_courses', $goc);
}
$this->use_in($this->courseid);
}
}
return $result;
}

/**
* Mark outcome as used in course
* @param int $courseid
* @return succes - false if incorrect courseid requested
*/
function use_in($courseid) {
if (!empty($this->courseid) and $courseid != $this->courseid) {
return false;
}

if (!record_exists('grade_outcomes_courses', 'courseid', $courseid, 'outcomeid', $this->id)) {
$goc = new object();
$goc->courseid = $courseid;
$goc->outcomeid = $this->id;
return (bool)insert_record('grade_outcomes_courses', $goc);
}
return true;
}

/**
* Finds and returns a grade_outcome instance based on params.
* @static
Expand Down

0 comments on commit b0f44d8

Please sign in to comment.