MDL-74054 qbank: Updates to plugins to support qbank customisation

This commit is contained in:
Mark Johnson 2023-08-11 17:04:04 +01:00 committed by Andrew Nicols
parent 82599bef84
commit 3685a3355f
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
5 changed files with 18 additions and 17 deletions

View File

@ -40,20 +40,21 @@ Feature: A teacher can edit question with custom fields
And I am on the "Test quiz name" "mod_quiz > question bank" page
Scenario: Edit a previously created question and see the custom field in the overview table and in the question preview.
When I choose "Edit question" action for "First question" in the question bank
And I should see "Category for test"
When I am on the "First question" "core_question > edit" page
Then I should see "Category for test"
And I click on "Expand all" "link" in the "region-main" "region"
And I should see "Field 1"
And I set the following fields to these values:
| Field 1 | custom field text |
| Question name | First question edited |
| Field 1 | custom field text |
And I press "id_submitbutton"
And I should see "First question"
And I should see "custom field text"
And I choose "Preview" action for "First question" in the question bank
And I am on the "First question edited" "core_question > preview" page
And I should see "Field 1"
Then I should see "custom field text"
And I should see "custom field text"
Scenario: Preview a previously created question with custom fields set with empty values
When I choose "Preview" action for "First question" in the question bank
And I should see "Field 1"
Then I should not see "custom field text"
When I am on the "First question" "core_question > preview" page
Then I should see "Field 1"
And I should not see "custom field text"

View File

@ -37,13 +37,12 @@ Feature: The visibility of question custom fields control where they are display
| Correct answer | False |
| Feedback for the response 'True'. | So you think it is true |
| Feedback for the response 'False'. | So you think it is false |
And I am on the "Test quiz name" "mod_quiz > question bank" page
@javascript
Scenario: Display custom question fields to teachers based on their visibility.
When I choose "Edit question" action for "First question" in the question bank
And I should see "Category for test"
And I click on "Expand all" "link" in the "region-main" "region"
When I am on the "First question" "core_question > edit" page
Then I should see "Category for test"
And I click on "Expand all" "link"
And I should see "Field 1"
And I should see "Field 2"
And I should see "Field 3"
@ -63,4 +62,4 @@ Feature: The visibility of question custom fields control where they are display
And I should see "Field 2"
And I should see "custom field text two"
And I should see "Field 3"
Then I should see "secret"
And I should see "secret"

View File

@ -92,8 +92,9 @@ class question_history_view extends view {
}
}
protected function create_new_question_form($category, $canadd): void {
public function allow_add_questions(): bool {
// As we dont want to create questions in this page.
return false;
}
/**

View File

@ -1,4 +1,4 @@
#categoryquestions td.questionlastused span.date {
.question-bank-table td.questionlastused span.date {
font-weight: 400;
font-size: .8em;
}

View File

@ -50,8 +50,8 @@ class question_name_idnumber_tags_column extends viewquestionname_column_helper
// The non-breaking space ' ' is used in html to fix MDL-75051 (browser issues caused by chrome and Edge).
if ($question->idnumber !== null && $question->idnumber !== '') {
echo ' ' . \html_writer::span(
\html_writer::span(get_string('idnumber', 'question'), 'accesshide')
. ' ' . \html_writer::span(s($question->idnumber), 'badge badge-primary'), 'ml-1');
\html_writer::span(get_string('idnumber', 'question') . ' ', 'accesshide')
. \html_writer::span(s($question->idnumber), 'badge badge-primary'), 'ml-1');
}
// Question tags.