/** * Records this object in the Database, sets its id to the returned value, and returns that value. * If successful this function also fetches the new object data from database and stores it * in object properties. * @param string $source from where was the object inserted (mod/forum, manual, etc.) * @return int PK ID if successful, false otherwise */ function insert($source = null) { $this->timecreated = time(); $this->timemodified = time(); return parent::insert($source); }
/** * Internal function - used only from fetch_course_category() * Normal insert() can not be used for course category * * @param int $courseid The course ID * @return int The ID of the new course category */ public function insert_course_category($courseid) { $this->courseid = $courseid; $this->fullname = '?'; $this->path = null; $this->parent = null; $this->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2; $this->apply_default_settings(); $this->apply_forced_settings(); $this->timecreated = $this->timemodified = time(); if (!parent::insert('system')) { debugging("Could not insert this category: " . print_r($this, true)); return false; } // build path and depth $this->update('system'); return $this->id; }
/** * Records this object in the Database, sets its id to the returned value, and returns that value. * If successful this function also fetches the new object data from database and stores it * in object properties. * @param string $source from where was the object inserted (mod/forum, manual, etc.) * @return int PK ID if successful, false otherwise */ function insert($source = null) { $this->timecreated = $this->timemodified = time(); if ($result = parent::insert($source)) { if (!empty($this->courseid)) { $goc = new object(); $goc->courseid = $this->courseid; $goc->outcomeid = $this->id; insert_record('grade_outcomes_courses', $goc); } } return $result; }
/** * In addition to perform parent::insert(), calls force_regrading() method too. * @param string $source from where was the object inserted (mod/forum, manual, etc.) * @return int PK ID if successful, false otherwise */ function insert($source = null) { global $CFG; if (empty($this->courseid)) { error('Can not insert grade item without course id!'); } // load scale if needed $this->load_scale(); // add parent category if needed if (empty($this->categoryid) and !$this->is_course_item() and !$this->is_category_item()) { $course_category = grade_category::fetch_course_category($this->courseid); $this->categoryid = $course_category->id; } // always place the new items at the end, move them after insert if needed $last_sortorder = get_field_select('grade_items', 'MAX(sortorder)', "courseid = {$this->courseid}"); if (!empty($last_sortorder)) { $this->sortorder = $last_sortorder + 1; } else { $this->sortorder = 1; } // add proper item numbers to manual items if ($this->itemtype == 'manual') { if (empty($this->itemnumber)) { $this->itemnumber = 0; } } // make sure there is not 0 in outcomeid if (empty($this->outcomeid)) { $this->outcomeid = null; } $this->timecreated = $this->timemodified = time(); if (parent::insert($source)) { // force regrading of items if needed $this->force_regrading(); return $this->id; } else { debugging("Could not insert this grade_item in the database!"); return false; } }
/** * Insert the grade_grade instance into the database. * * @param string $source From where was the object inserted (mod/forum, manual, etc.) * @return int The new grade_grade ID if successful, false otherwise */ public function insert($source = null) { // TODO: dategraded hack - do not update times, they are used for submission and grading (MDL-31379) //$this->timecreated = $this->timemodified = time(); return parent::insert($source); }
/** * Records this object in the Database, sets its id to the returned value, and returns that value. * If successful this function also fetches the new object data from database and stores it * in object properties. * * @param string $source from where was the object inserted (mod/forum, manual, etc.) * @return int PK ID if successful, false otherwise */ public function insert($source = null) { global $DB; $this->timecreated = $this->timemodified = time(); if ($result = parent::insert($source)) { if (!empty($this->courseid)) { $goc = new stdClass(); $goc->courseid = $this->courseid; $goc->outcomeid = $this->id; $DB->insert_record('grade_outcomes_courses', $goc); } } return $result; }
/** * Internal function - used only from fetch_course_category() * Normal insert() can not be used for course category * @param int $courseid * @return bool success */ function insert_course_category($courseid) { $this->courseid = $courseid; $this->fullname = get_string('coursegradecategory', 'grades'); $this->path = null; $this->parent = null; $this->aggregate = GRADE_AGGREGATE_MEAN; if (!parent::insert('system')) { debugging("Could not insert this category: " . print_r($this, true)); return false; } // build path and depth $this->update('system'); return $this->id; }