本文整理匯總了PHP中quiz_delete_all_attempts函數的典型用法代碼示例。如果您正苦於以下問題:PHP quiz_delete_all_attempts函數的具體用法?PHP quiz_delete_all_attempts怎麽用?PHP quiz_delete_all_attempts使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了quiz_delete_all_attempts函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: quiz_delete_instance
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id the id of the quiz to delete.
* @return bool success or failure.
*/
function quiz_delete_instance($id) {
global $DB;
$quiz = $DB->get_record('quiz', array('id' => $id), '*', MUST_EXIST);
quiz_delete_all_attempts($quiz);
quiz_delete_all_overrides($quiz);
$DB->delete_records('quiz_question_instances', array('quiz' => $quiz->id));
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
$events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
foreach ($events as $event) {
$event = calendar_event::load($event);
$event->delete();
}
quiz_grade_item_delete($quiz);
$DB->delete_records('quiz', array('id' => $quiz->id));
return true;
}
示例2: quiz_reset_userdata
/**
* Actual implementation of the reset course functionality, delete all the
* quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
* set and true.
*
* Also, move the quiz open and close dates, if the course start date is changing.
*
* @global stdClass
* @global object
* @param object $data the data submitted from the reset course.
* @return array status array
*/
function quiz_reset_userdata($data) {
global $CFG, $DB;
require_once($CFG->libdir.'/questionlib.php');
$componentstr = get_string('modulenameplural', 'quiz');
$status = array();
/// Delete attempts.
if (!empty($data->reset_quiz_attempts)) {
$quizzes = $DB->get_records('quiz', array('course' => $data->courseid));
foreach ($quizzes as $quiz) {
quiz_delete_all_attempts($quiz);
}
// remove all grades from gradebook
if (empty($data->reset_gradebook_grades)) {
quiz_reset_gradebook($data->courseid);
}
$status[] = array('component' => $componentstr, 'item' => get_string('attemptsdeleted', 'quiz'), 'error' => false);
}
/// updating dates - shift may be negative too
if ($data->timeshift) {
shift_course_mod_dates('quiz', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('openclosedatesupdated', 'quiz'), 'error' => false);
}
return $status;
}
示例3: quiz_delete_instance
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id the id of the quiz to delete.
* @return bool success or failure.
*/
function quiz_delete_instance($id)
{
global $DB;
$quiz = $DB->get_record('quiz', array('id' => $id), '*', MUST_EXIST);
quiz_delete_all_attempts($quiz);
quiz_delete_all_overrides($quiz);
// Look for random questions that may no longer be used when this quiz is gone.
$sql = "SELECT q.id\n FROM {quiz_slots} slot\n JOIN {question} q ON q.id = slot.questionid\n WHERE slot.quizid = ? AND q.qtype = ?";
$questionids = $DB->get_fieldset_sql($sql, array($quiz->id, 'random'));
// We need to do this before we try and delete randoms, otherwise they would still be 'in use'.
$DB->delete_records('quiz_slots', array('quizid' => $quiz->id));
$DB->delete_records('quiz_sections', array('quizid' => $quiz->id));
foreach ($questionids as $questionid) {
question_delete_question($questionid);
}
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
quiz_access_manager::delete_settings($quiz);
$events = $DB->get_records('event', array('modulename' => 'quiz', 'instance' => $quiz->id));
foreach ($events as $event) {
$event = calendar_event::load($event);
$event->delete();
}
quiz_grade_item_delete($quiz);
$DB->delete_records('quiz', array('id' => $quiz->id));
return true;
}
示例4: emarking_insert_user_answers
emarking_insert_user_answers($choices, $user, $attemptid);
}
echo $OUTPUT->notification(get_string('csvimportsuccessfull', 'mod_emarking'), 'notifysuccess');
echo $OUTPUT->single_button(new moodle_url('/mod/emarking/orm/processomr.php', array('cmid' => $cm->id, 'finish' => true)), get_string('finish', 'mod_emarking'));
} else {
$answersform->display();
}
echo $OUTPUT->footer();
die;
}
// Get the users enrolled
$users = emarking_get_enroled_students($course->id);
$pbar = new progress_bar();
$pbar->create();
if ($create) {
quiz_delete_all_attempts($quiz);
}
$cur = 1;
$total = count($users);
// Insert answers or finish the attempt for each student
foreach ($users as $user) {
$pbar->update($cur, $total, get_string('processing', 'mod_emarking') . $user->lastname . $user->firstname);
flush();
// Get the quiz instance for the specific student
$quizobj = quiz::create($cm->instance, $user->id);
// Get all the attempts
$attempts = quiz_get_user_attempts($quizobj->get_quizid(), $user->id, 'all');
if ($create) {
emarking_add_user_attempt($cm, $user);
} else {
// For each attempt insert the answers or finish