本文整理汇总了PHP中quiz_delete_override函数的典型用法代码示例。如果您正苦于以下问题:PHP quiz_delete_override函数的具体用法?PHP quiz_delete_override怎么用?PHP quiz_delete_override使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quiz_delete_override函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quiz_delete_all_overrides
/**
* Deletes all quiz overrides from the database and clears any corresponding calendar events
*
* @param object $quiz The quiz object.
*/
function quiz_delete_all_overrides($quiz) {
global $DB;
$overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id), 'id');
foreach ($overrides as $override) {
quiz_delete_override($quiz, $override->id);
}
}
示例2: require_capability
// Check the user has the required capabilities to modify an override.
require_capability('mod/quiz:manageoverrides', $context);
$url = new moodle_url('/mod/quiz/overridedelete.php', array('id'=>$override->id));
$confirmurl = new moodle_url($url, array('id'=>$override->id, 'confirm'=>1));
$cancelurl = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$cm->id));
if (!empty($override->userid)) {
$cancelurl->param('mode', 'user');
}
// If confirm is set (PARAM_BOOL) then we have confirmation of intention to delete.
if ($confirm) {
require_sesskey();
quiz_delete_override($quiz, $override->id);
add_to_log($cm->course, 'quiz', 'delete override',
"overrides.php?cmid=$cm->id", $quiz->id, $cm->id);
redirect($cancelurl);
}
// Prepare the page to show the confirmation form.
$stroverride = get_string('override', 'quiz');
$title = get_string('deletecheck', null, $stroverride);
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$PAGE->navbar->add($title);
$PAGE->set_title($title);
示例3: test_group_override_deleted
/**
* Test the group override deleted event.
*/
public function test_group_override_deleted()
{
global $DB;
$this->resetAfterTest();
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id));
// Create an override.
$override = new stdClass();
$override->quiz = $quiz->id;
$override->groupid = 2;
$override->id = $DB->insert_record('quiz_overrides', $override);
// Trigger and capture the event.
$sink = $this->redirectEvents();
quiz_delete_override($quiz, $override->id);
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\\mod_quiz\\event\\group_override_deleted', $event);
$this->assertEquals(context_module::instance($quiz->cmid), $event->get_context());
$expected = array($course->id, 'quiz', 'delete override', 'overrides.php?cmid=' . $quiz->cmid, $quiz->id, $quiz->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}