/**
  * Get a the course settings for a single course.
  *
  * @param int $courseid The course id
  * @return course_competency_settings
  */
 public static function get_by_courseid($courseid)
 {
     global $DB;
     $params = array('courseid' => $courseid);
     $settings = new static(null, (object) $params);
     if ($record = $DB->get_record(self::TABLE, $params)) {
         $settings->from_record($record);
     }
     return $settings;
 }
Example #2
0
 /**
  * Get relation specifying both competencies.
  *
  * This does not perform any validation on the data passed. If the relation exists in the database
  * then it is loaded in a the model, if not then it is up to the developer to save the model.
  *
  * @param int $competencyid
  * @param int $relatedcompetencyid
  * @return related_competency
  */
 public static function get_relation($competencyid, $relatedcompetencyid)
 {
     global $DB;
     // Lower id always as competencyid so we know which one is competencyid and which one relatedcompetencyid.
     $relation = new static();
     if ($competencyid > $relatedcompetencyid) {
         $relation->set_competencyid($relatedcompetencyid);
         $relation->set_relatedcompetencyid($competencyid);
     } else {
         $relation->set_competencyid($competencyid);
         $relation->set_relatedcompetencyid($relatedcompetencyid);
     }
     // We can do it because we have bidirectional relations in the DB.
     $params = array('competencyid' => $relation->get_competencyid(), 'relatedcompetencyid' => $relation->get_relatedcompetencyid());
     if ($record = $DB->get_record(self::TABLE, $params)) {
         $relation->from_record($record);
     }
     return $relation;
 }
 /**
  * Get a relation.
  *
  * This does not perform any validation on the data passed. If the relation exists in the database
  * then it is loaded in a the model, if not then it is up to the developer to save the model.
  *
  * @param int $userevidenceid
  * @param int $competencyid
  * @return template_cohort
  */
 public static function get_relation($userevidenceid, $competencyid)
 {
     global $DB;
     $params = array('userevidenceid' => $userevidenceid, 'competencyid' => $competencyid);
     $relation = new static(null, (object) $params);
     if ($record = $DB->get_record(static::TABLE, $params)) {
         $relation->from_record($record);
     }
     return $relation;
 }
Example #4
0
 /**
  * Get a relation.
  *
  * This does not perform any validation on the data passed. If the relation exists in the database
  * then it is loaded in a the model, if not then it is up to the developer to save the model.
  *
  * @param int $templateid
  * @param int $cohortid
  * @return template_cohort
  */
 public static function get_relation($templateid, $cohortid)
 {
     global $DB;
     $params = array('templateid' => $templateid, 'cohortid' => $cohortid);
     $relation = new static(null, (object) $params);
     if ($record = $DB->get_record(self::TABLE, $params)) {
         $relation->from_record($record);
     }
     return $relation;
 }