Merge branch 'MDL-76026' of https://github.com/AnupamaSarjoshi/moodle
This commit is contained in:
@@ -51,3 +51,22 @@ Feature: Moving a question to another category should not affect random question
|
||||
And I should see "Random (Used category)" on quiz page "1"
|
||||
And I click on "(See questions)" "link"
|
||||
And I should see "Used category"
|
||||
|
||||
@javascript
|
||||
Scenario: Renaming a random question category should update the random question
|
||||
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
||||
When I open the "last" add to quiz menu
|
||||
And I follow "a random question"
|
||||
And I set the field "Category" to "Used category"
|
||||
And I press "Add random question"
|
||||
And I should see "Random (Used category)" on quiz page "1"
|
||||
And I am on the "Course 1" "core_question > course question categories" page
|
||||
And I click on "Edit this category" "link" in the "Used category" "list_item"
|
||||
And I set the following fields to these values:
|
||||
| Name | Used category new |
|
||||
| Category info | I was edited |
|
||||
And I press "Save changes"
|
||||
Then I should see "Used category new"
|
||||
And I should see "I was edited" in the "Used category new" "list_item"
|
||||
And I am on the "Quiz 1" "mod_quiz > Edit" page
|
||||
And I should see "Random (Used category new)" on quiz page "1"
|
||||
|
||||
@@ -474,23 +474,6 @@ class question_category_object {
|
||||
$event = \core\event\question_category_updated::create_from_question_category_instance($cat);
|
||||
$event->trigger();
|
||||
|
||||
// If the category name has changed, rename any random questions in that category.
|
||||
if ($oldcat->name != $cat->name) {
|
||||
// Get the question ids for each question category.
|
||||
$questionids = $this->get_real_question_ids_in_category($cat->id);
|
||||
|
||||
foreach ($questionids as $question) {
|
||||
$where = "qtype = 'random' AND id = ? AND " . $DB->sql_compare_text('questiontext') . " = ?";
|
||||
|
||||
$randomqtype = question_bank::get_qtype('random');
|
||||
$randomqname = $randomqtype->question_name($cat, false);
|
||||
$DB->set_field_select('question', 'name', $randomqname, $where, [$question->id, '0']);
|
||||
|
||||
$randomqname = $randomqtype->question_name($cat, true);
|
||||
$DB->set_field_select('question', 'name', $randomqname, $where, [$question->id, '1']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldcat->contextid != $tocontextid) {
|
||||
// Moving to a new context. Must move files belonging to questions.
|
||||
question_move_category_to_context($cat->id, $oldcat->contextid, $tocontextid);
|
||||
|
||||
@@ -46,6 +46,10 @@ Feature: A teacher can put questions in categories in the question bank
|
||||
|
||||
Scenario: A question category can be edited
|
||||
When I am on the "Course 1" "core_question > course question categories" page
|
||||
# There have been bugs which only happened if a question category was not empty, so add a question.
|
||||
And the following "questions" exist:
|
||||
| questioncategory | qtype | name | questiontext |
|
||||
| Subcategory | essay | Test question for renaming category | Write about whatever you want |
|
||||
And I click on "Edit this category" "link" in the "Subcategory" "list_item"
|
||||
And the field "parent" matches value " Default for C1"
|
||||
And I set the following fields to these values:
|
||||
|
||||
Reference in New Issue
Block a user