コード例 #1
0
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will create a new instance and return the id number
 * of the new instance.
 *
 * @param object $skillsoft An object from the form in mod_form.php
 * @return int The id of the newly inserted skillsoft record
 */
function skillsoft_add_instance($skillsoft)
{
    global $CFG, $DB;
    $skillsoft->timecreated = time();
    $skillsoft->timemodified = time();
    $skillsoft->completable = skillsoft_iscompletable($skillsoft);
    if ($result = $DB->insert_record('skillsoft', $skillsoft)) {
        $skillsoft->id = $result;
        //$newskillsoft = get_record('skillsoft', 'id' , $result);
        //skillsoft_grade_item_update(stripslashes_recursive($skillsoft),NULL);
        skillsoft_grade_item_update($skillsoft, NULL);
    }
    //Only if completable reprocess imported data
    if ($skillsoft->completable) {
        //We have added an instance so now we need to unset the processed flag
        //in the ODC/CustomReport data so that this new "instance" of a course
        //gets the data updated next time CRON runs
        if ($CFG->skillsoft_trackingmode == TRACK_TO_OLSA_CUSTOMREPORT) {
            //Use more efficient method
            skillsoft_reset_processed($skillsoft->assetid);
        }
        if ($CFG->skillsoft_trackingmode == TRACK_TO_OLSA) {
            //Use more efficient method
            skillsoft_reset_processed($skillsoft->assetid);
        }
    }
    return $result;
}
コード例 #2
0
 protected function process_skillsoft($data)
 {
     global $DB, $CFG;
     $data = (object) $data;
     $oldid = $data->id;
     $data->course = $this->get_courseid();
     $data->timemodified = $this->apply_date_offset($data->timemodified);
     $data->timecreated = $this->apply_date_offset($data->timecreated);
     // insert the skillsoft record
     $newitemid = $DB->insert_record('skillsoft', $data);
     // immediately after inserting "activity" record, call this
     $this->apply_activity_instance($newitemid);
     //Enable (re-)grading:
     require_once dirname(dirname(dirname(__FILE__))) . '/locallib.php';
     skillsoft_reset_processed($data->assetid);
 }