本文整理汇总了PHP中lesson_reset_gradebook函数的典型用法代码示例。如果您正苦于以下问题:PHP lesson_reset_gradebook函数的具体用法?PHP lesson_reset_gradebook怎么用?PHP lesson_reset_gradebook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lesson_reset_gradebook函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lesson_reset_userdata
/**
* Actual implementation of the reset course functionality, delete all the
* lesson attempts for course $data->courseid.
*
* @global stdClass
* @global object
* @param object $data the data submitted from the reset course.
* @return array status array
*/
function lesson_reset_userdata($data)
{
global $CFG, $DB;
$componentstr = get_string('modulenameplural', 'lesson');
$status = array();
if (!empty($data->reset_lesson)) {
$lessonssql = "SELECT l.id\n FROM {lesson} l\n WHERE l.course=:course";
$params = array("course" => $data->courseid);
$lessons = $DB->get_records_sql($lessonssql, $params);
// Get rid of attempts files.
$fs = get_file_storage();
if ($lessons) {
foreach ($lessons as $lessonid => $unused) {
if (!($cm = get_coursemodule_from_instance('lesson', $lessonid))) {
continue;
}
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_lesson', 'essay_responses');
}
}
$DB->delete_records_select('lesson_timer', "lessonid IN ({$lessonssql})", $params);
$DB->delete_records_select('lesson_grades', "lessonid IN ({$lessonssql})", $params);
$DB->delete_records_select('lesson_attempts', "lessonid IN ({$lessonssql})", $params);
$DB->delete_records_select('lesson_branch', "lessonid IN ({$lessonssql})", $params);
// remove all grades from gradebook
if (empty($data->reset_gradebook_grades)) {
lesson_reset_gradebook($data->courseid);
}
$status[] = array('component' => $componentstr, 'item' => get_string('deleteallattempts', 'lesson'), 'error' => false);
}
// Remove user overrides.
if (!empty($data->reset_lesson_user_overrides)) {
$DB->delete_records_select('lesson_overrides', 'lessonid IN (SELECT id FROM {lesson} WHERE course = ?) AND userid IS NOT NULL', array($data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('useroverridesdeleted', 'lesson'), 'error' => false);
}
// Remove group overrides.
if (!empty($data->reset_lesson_group_overrides)) {
$DB->delete_records_select('lesson_overrides', 'lessonid IN (SELECT id FROM {lesson} WHERE course = ?) AND groupid IS NOT NULL', array($data->courseid));
$status[] = array('component' => $componentstr, 'item' => get_string('groupoverridesdeleted', 'lesson'), 'error' => false);
}
/// updating dates - shift may be negative too
if ($data->timeshift) {
$DB->execute("UPDATE {lesson_overrides}\n SET available = available + ?\n WHERE lessonid IN (SELECT id FROM {lesson} WHERE course = ?)\n AND available <> 0", array($data->timeshift, $data->courseid));
$DB->execute("UPDATE {lesson_overrides}\n SET deadline = deadline + ?\n WHERE lessonid IN (SELECT id FROM {lesson} WHERE course = ?)\n AND deadline <> 0", array($data->timeshift, $data->courseid));
shift_course_mod_dates('lesson', array('available', 'deadline'), $data->timeshift, $data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
}
return $status;
}