timemodified = time(); # May have to add extra stuff in here # if (!get_record('autoattendmod', 'course', $autoattendmod->course)) { return insert_record("autoattendmod", $autoattendmod); } else { return false; } } function autoattendmod_update_instance($autoattendmod) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will update an existing instance with new data. $autoattendmod->timemodified = time(); $autoattendmod->id = $autoattendmod->instance; # May have to add extra stuff in here # return update_record("autoattendmod", $autoattendmod); } function autoattendmod_delete_instance($id) { /// Given an ID of an instance of this module, /// this function will permanently delete the instance /// and any data that depends on it. if (! $autoattendmod = get_record("autoattendmod", "id", "$id")) { return false; } $result = true; # Delete any dependent records here # if (! delete_records("autoattendmod", "id", "$autoattendmod->id")) { $result = false; } return $result; } function autoattendmod_user_outline($course, $user, $mod, $autoattendmod) { /// Return a small object with summary information about what a /// user has done with a given particular instance of this module /// Used for user activity reports. /// $return->time = the time they did it /// $return->info = a short text description global $CFG; require_once($CFG->dirroot.'/blocks/autoattend/lib.php'); $summary = autoattend_get_usersummary($course->id, $user->id); if (!$summary) return false; $maxtime = 0; foreach($summary['attitems'] as $att) { $maxtime = $maxtime >= $att->calledtime ? $maxtime : $att->calledtime; } $return->info = get_string('grade').': '.$summary['grade']." / ".$summary['maxgrade'].' ('.$summary['percent'].'%)'; $return->time = $maxtime; return $return; } function autoattendmod_user_complete($course, $user, $mod, $autoattendmod) { /// Print a detailed representation of what a user has done with /// a given particular instance of this module, for user activity reports. global $CFG; require_once($CFG->dirroot.'/blocks/autoattend/lib.php'); if (isstudent($course->id,$user->id)) autoattend_print_user($user, $course); return true; } function autoattendmod_print_recent_activity($course, $isteacher, $timestart) { /// Given a course and a time, this module should find recent activity /// that has occurred in autoattendmod activities and print it out. /// Return true if there was output, or false is there was none. global $CFG; return false; // True if anything was printed, otherwise false } function autoattendmod_cron () { /// Function to be run periodically according to the moodle cron /// This function searches for things that need to be done, such /// as sending out mail, toggling flags etc ... global $CFG; require_once($CFG->dirroot.'/blocks/autoattend/automaticlib.php'); if ($autoattendmods = get_records("autoattendmod")) { foreach ($autoattendmods as $autoattendmod) { autoattend_update_sessions($autoattendmod->course); } } return true; } function autoattendmod_grades($autoattendmodid) { /// Must return an array of grades for a given instance of this module, /// indexed by user. It also returns a maximum allowed grade. /// /// $return->grades = array of grades; /// $return->maxgrade = maximum allowed grade; /// /// return $return; global $CFG; require_once($CFG->dirroot.'/blocks/autoattend/lib.php'); if (!$mod = get_record('autoattendmod', 'id', $autoattendmodid)) { return NULL; } $maxgrade = 0; $students = get_course_students($mod->course); foreach ($students as $student) { $summary = autoattend_get_usersummary($mod->course, $student->id); if ($summary) { $return->grades[$student->id] = $summary['grade']; $maxgrade = $maxgrade >= $summary['maxgrade'] ? $maxgrade : $summary['maxgrade']; } } $return->maxgrade = $maxgrade; return $return; } function autoattendmod_get_participants($autoattendmodid) { //Must return an array of user records (all data) who are participants //for a given instance of autoattendmod. Must include every user involved //in the instance, independient of his role (student, teacher, admin...) //See other modules as example. return false; } function autoattendmod_scale_used ($autoattendmodid,$scaleid) { //This function returns if a scale is being used by one autoattendmod //it it has support for grading and scales. Commented code should be //modified if necessary. See forum, glossary or journal modules //as reference. $return = false; //$rec = get_record("autoattendmod","id","$autoattendmodid","scale","-$scaleid"); // //if (!empty($rec) && !empty($scaleid)) { // $return = true; //} return $return; } ////////////////////////////////////////////////////////////////////////////////////// /// Any other autoattendmod functions go here. Each of them must have a name that /// starts with autoattendmod_ ?>