mirror of
https://github.com/moodle/moodle.git
synced 2025-04-03 15:32:43 +02:00
Merge branch 'MDL-75431' of https://github.com/AnupamaSarjoshi/moodle
This commit is contained in:
commit
8167e6e327
@ -93,12 +93,18 @@ class update_question_version_status_test extends \advanced_testcase {
|
||||
public function test_submit_status_does_not_create_a_new_version() {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Find out the start count in 'question_versions' table.
|
||||
$versioncount = $DB->count_records('question_versions');
|
||||
|
||||
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
$cat = $questiongenerator->create_question_category();
|
||||
$numq = $questiongenerator->create_question('essay', null,
|
||||
['category' => $cat->id, 'name' => 'This is the first version']);
|
||||
$countcurrentrecords = $DB->count_records('question_versions');
|
||||
$this->assertEquals(1, $countcurrentrecords);
|
||||
// New version count should be equal to start + 1.
|
||||
$this->assertEquals($versioncount + 1, $countcurrentrecords);
|
||||
|
||||
$result = update_question_version_status::execute($numq->id, 'draft');
|
||||
$countafterupdate = $DB->count_records('question_versions');
|
||||
$this->assertEquals($countcurrentrecords, $countafterupdate);
|
||||
|
@ -65,7 +65,8 @@ class helper_test extends \advanced_testcase {
|
||||
|
||||
$datagenerator = $this->getDataGenerator();
|
||||
$this->course = $datagenerator->create_course();
|
||||
$this->quiz = $datagenerator->create_module('quiz', ['course' => $this->course->id]);
|
||||
$this->quiz = $datagenerator->create_module('quiz',
|
||||
['course' => $this->course->id, 'name' => 'Quiz 1']);
|
||||
$this->qgenerator = $datagenerator->get_plugin_generator('core_question');
|
||||
$this->context = \context_module::instance($this->quiz->cmid);
|
||||
|
||||
@ -232,14 +233,16 @@ class helper_test extends \advanced_testcase {
|
||||
|
||||
// Validate that we have the array with the categories tree.
|
||||
$categorycontexts = helper::question_category_options($contexts->having_cap('moodle/question:add'));
|
||||
foreach ($categorycontexts as $categorycontext) {
|
||||
$this->assertCount(3, $categorycontext);
|
||||
}
|
||||
// The quiz name 'Quiz 1' is set in setUp function.
|
||||
$categorycontext = $categorycontexts['Quiz: Quiz 1'];
|
||||
$this->assertCount(3, $categorycontext);
|
||||
|
||||
// Validate that we have the array with the categories tree and that top category is there.
|
||||
$categorycontexts = helper::question_category_options($contexts->having_cap('moodle/question:add'), true);
|
||||
foreach ($categorycontexts as $categorycontext) {
|
||||
$this->assertCount(4, $categorycontext);
|
||||
$newcategorycontexts = helper::question_category_options($contexts->having_cap('moodle/question:add'), true);
|
||||
foreach ($newcategorycontexts as $key => $categorycontext) {
|
||||
$oldcategorycontext = $categorycontexts[$key];
|
||||
$count = count($oldcategorycontext);
|
||||
$this->assertCount($count + 1, $categorycontext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user