Adding Gradebook Functionality - mkadin/sort GitHub Wiki

  1. Add case FEATURE_MOD_INTRO: return true; to lib.php’s newmodule_support() function.
  2. Add the line $this->standard_grading_coursemodule_elements(); to mod_form.php for your module. This adds a ‘grade’ form element with which the user can select their preferred grading method for the activity.
  3. Using Moodle XMLDB editor, add a ‘grade’ field to the module’s base table. Add the PHP code it generates to db/upgrade.php. Should be a signed integer field.
  4. Update the version of the module in version.php and update the module in moodle’s interface.
  5. Update the code in newmodule_grade_item_update() in lib.php for your module. If you want it to be able to handle other grading scales besides point values. Replace there with similar code from assignment_grade_item_update() form the assignment module. Some variable renaming will be necessary.
  6. Add a call to newmodule_grade_item_update() in newmodule_add_instance() and newmodule_update_instance(). This will make sure that the gradebook has a grading item when an instance of the activity is created. In newmodule_add_instance, be sure that the object being passed to newmodule_grade_item_update() has the newly created id generated during the insert. You want to add the instance first, and have insert_record() return the new id, and add that to the object before passing it to newmodule_grade_item_update().
  7. Create a file called grade.php at the root of your activity module which conditionally redirects the user to other pages. A user ends up here when they click on the title of the activity on the gradebook page. You may want to redirect them to a page that summarizes helpful information for grading the students.