本文整理汇总了PHP中question_edit_contexts::lowest方法的典型用法代码示例。如果您正苦于以下问题:PHP question_edit_contexts::lowest方法的具体用法?PHP question_edit_contexts::lowest怎么用?PHP question_edit_contexts::lowest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_edit_contexts
的用法示例。
在下文中一共展示了question_edit_contexts::lowest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_question_category_created
/**
* Test the question category created event.
*/
public function test_question_category_created()
{
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
$quiz = $this->getDataGenerator()->create_module('quiz', array('course' => $course->id));
$contexts = new question_edit_contexts(context_module::instance($quiz->cmid));
$defaultcategoryobj = question_make_default_categories(array($contexts->lowest()));
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
$qcobject = new question_category_object(1, new moodle_url('/mod/quiz/edit.php', array('cmid' => $quiz->cmid)), $contexts->having_one_edit_tab_cap('categories'), $defaultcategoryobj->id, $defaultcategory, null, $contexts->having_cap('moodle/question:add'));
// Trigger and capture the event.
$sink = $this->redirectEvents();
$categoryid = $qcobject->add_category($defaultcategory, 'newcategory', '', true);
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\question_category_created', $event);
$this->assertEquals(context_module::instance($quiz->cmid), $event->get_context());
$expected = array($course->id, 'quiz', 'addcategory', 'view.php?id=' . $quiz->cmid, $categoryid, $quiz->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}
示例2: stdClass
// get display strings
$txt = new stdClass();
$txt->importerror = get_string('importerror', 'question');
$txt->importquestions = get_string('importquestions', 'question');
list($catid, $catcontext) = explode(',', $pagevars['cat']);
if (!($category = $DB->get_record("question_categories", array('id' => $catid)))) {
print_error('nocategory', 'question');
}
$categorycontext = context::instance_by_id($category->contextid);
$category->context = $categorycontext;
//this page can be called without courseid or cmid in which case
//we get the context from the category object.
if ($contexts === null) {
// need to get the course from the chosen category
$contexts = new question_edit_contexts($categorycontext);
$thiscontext = $contexts->lowest();
if ($thiscontext->contextlevel == CONTEXT_COURSE) {
require_login($thiscontext->instanceid, false);
} elseif ($thiscontext->contextlevel == CONTEXT_MODULE) {
list($module, $cm) = get_module_from_cmid($thiscontext->instanceid);
require_login($cm->course, false, $cm);
}
$contexts->require_one_edit_tab_cap($edittab);
}
$PAGE->set_url($thispageurl);
$import_form = new question_import_form($thispageurl, array('contexts' => $contexts->having_one_edit_tab_cap('import'), 'defaultcategory' => $pagevars['cat']));
if ($import_form->is_cancelled()) {
redirect($thispageurl);
}
//==========
// PAGE HEADER