lib.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. //adds gradeimporter to add new activity page
  3. function tool_devcourse_extend_navigation_course($navigation, $course, $coursecontext) {
  4. $url = new moodle_url('/admin/tool/devcourse/index.php');
  5. $devcoursenode = navigation_node::create('Development course', $url, navigation_node::TYPE_CUSTOM, 'Dev course', 'devcourse');
  6. $navigation->add_node($devcoursenode);
  7. }
  8. function gradeimporter_supports($feature) {
  9. switch($feature) {
  10. case FEATURE_MOD_INTRO: return true;
  11. case FEATURE_SHOW_DESCRIPTION: return true;
  12. default: return null;
  13. }
  14. }
  15. function gradeimporter_add_instance ($data, $mform) {
  16. /*
  17. *Given an object containing all the necessary data,
  18. *(defined by the form in mod_form.php) this function
  19. *creates a new instance and returns the id of this new
  20. *instance.
  21. *
  22. *@param $data: an object from the form in mod_form.php
  23. *@return int: the id of the newly inserted gradeimport record
  24. */
  25. global $DB;
  26. $data->timemodified = time();
  27. $data->id = $DB->insert_record("gradeimporter", $data);
  28. return $data->id;
  29. }
  30. function gradeimporter_update_instance ($data){
  31. /*
  32. *given an object containing all the necessary data,
  33. *(defined by the form in mod_form.php) this function
  34. *updates an existing instance with the new data.
  35. *
  36. *@param $data: an object from the form mod_form.php
  37. *@return boolean: if the record update was a success of fail
  38. */
  39. global $DB;
  40. $data->timemodified = time();
  41. $data->id = $data->instance;
  42. return $DB->update_record('gradeimporter', $data);
  43. }
  44. function gradeimporter_delete_instance($data){
  45. /*
  46. *Given an id of a gradeimporter instance,
  47. * this function permanently deletes the instance
  48. * and any data that depends on it.
  49. *
  50. *@param int $id: Id of the gradeimporter instance
  51. *@return boolean, if the deletion was a success or
  52. * a failure.
  53. */
  54. global $DB;
  55. if (!$data = $DB->get_record('gradeimporter', array('id'=>$id) ) ){
  56. return false;
  57. }
  58. $DB->delete_records('gradeimporter', array('id'=>$id) );
  59. return true;
  60. }