public function testable_save_user_extension($userid, $extensionduedate) { return parent::save_user_extension($userid, $extensionduedate); }
/** * Grant extension dates to students for an setaskment. * * @param int $setaskmentid The id of the setaskment * @param array $userids Array of user ids to grant extensions to * @param array $dates Array of extension dates * @return array of warnings for each extension date that could not be granted * @since Moodle 2.6 */ public static function save_user_extensions($setaskmentid, $userids, $dates) { global $CFG; require_once "{$CFG->dirroot}/mod/setask/locallib.php"; $params = self::validate_parameters(self::save_user_extensions_parameters(), array('setaskmentid' => $setaskmentid, 'userids' => $userids, 'dates' => $dates)); if (count($params['userids']) != count($params['dates'])) { $detail = 'Length of userids and dates parameters differ.'; $warnings[] = self::generate_warning($params['setaskmentid'], 'invalidparameters', $detail); return $warnings; } $cm = get_coursemodule_from_instance('setask', $params['setaskmentid'], 0, false, MUST_EXIST); $context = context_module::instance($cm->id); self::validate_context($context); $setaskment = new setask($context, $cm, null); $warnings = array(); foreach ($params['userids'] as $idx => $userid) { $duedate = $params['dates'][$idx]; if (!$setaskment->save_user_extension($userid, $duedate)) { $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['setaskmentid'] . ', Extension date: ' . $duedate; $warnings[] = self::generate_warning($params['setaskmentid'], 'couldnotgrantextensions', $detail); } } return $warnings; }