. /** * mod_attendance data generator * * @package mod_attendance * @category test * @copyright 2013 Davo Smith, Synergy Learning * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * mod_attendance data generator * * @package mod_attendance * @category test * @copyright 2013 Davo Smith, Synergy Learning * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_attendance_generator extends testing_module_generator { /** * Create new attendance module instance * * @param array|stdClass $record * @param array $options * @return stdClass mod_attendance_structure */ public function create_instance($record = null, array $options = null) { global $CFG, $DB; require_once($CFG->dirroot.'/mod/attendance/lib.php'); $this->instancecount++; $i = $this->instancecount; $record = (object)(array)$record; $options = (array)$options; if (empty($record->course)) { throw new coding_exception('module generator requires $record->course'); } if (!isset($record->name)) { $record->name = get_string('pluginname', 'attendance').' '.$i; } if (!isset($record->grade)) { $record->grade = 100; } $att = parent::create_instance($record, (array)$options); $cm = $DB->get_record('course_modules', array('id' => $att->cmid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); unset($att->cmid); return new mod_attendance_structure($att, $cm, $course); } }