| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | <?php//adds gradeimporter to add new activity pagefunction tool_devcourse_extend_navigation_course($navigation, $course, $coursecontext) {    $url = new moodle_url('/admin/tool/devcourse/index.php');    $devcoursenode = navigation_node::create('Development course', $url, navigation_node::TYPE_CUSTOM, 'Dev course', 'devcourse');    $navigation->add_node($devcoursenode);}function gradeimporter_supports($feature) {    switch($feature) {       case FEATURE_MOD_INTRO:         return true;       case FEATURE_SHOW_DESCRIPTION:  return true;         default:                        return null;      }    }function gradeimporter_add_instance ($data, $mform) {    /*        *Given an object containing all the necessary data,        *(defined by the form in mod_form.php) this function        *creates a new instance and returns the id of this new        *instance.        *        *@param $data: an object from the form in mod_form.php        *@return int: the id of the newly inserted gradeimport record    */    global $DB;    $data->timemodified = time();        $data->id = $DB->insert_record("gradeimporter", $data);        return $data->id;}function gradeimporter_update_instance ($data){    /*        *given an object containing all the necessary data,        *(defined by the form in mod_form.php) this function        *updates an existing instance with the new data.        *        *@param $data: an object from the form mod_form.php        *@return boolean: if the record update was a success of fail    */    global $DB;    $data->timemodified = time();    $data->id = $data->instance;    return $DB->update_record('gradeimporter', $data);}function gradeimporter_delete_instance($data){    /*    *Given an id of a gradeimporter instance,    * this function permanently deletes the instance    * and any data that depends on it.    *    *@param int $id: Id of the gradeimporter instance    *@return boolean, if the deletion was a success or    *                 a failure.    */    global $DB;        if (!$data = $DB->get_record('gradeimporter', array('id'=>$id) ) ){        return false;    }    $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id);    $context = context_module::instance($cm->id);    // Files    $fs = get_file_storage();    $fs->delete_area_files($context->id, 'mod_gradeimporter');        //delete all files and submissions associated with this instance    $DB->delete_records('gradeimporter_submission', array('gradeimporterid' => $gradeimporter->id));    $DB->delete_records('gradeimporter_feedback', array('gradeimporterid' => $gradeimporter->id));    //delete the instance itself    $DB->delete_records('gradeimporter', array('id'=>$id) );    return true;}
 |