mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-78477 qbank_history: Fix and improve UI for edit menu delete option
Changes done to fix the warnings thrown in the history view when the last version of a question is deleted and improved UI to display the message and a Continue button, to navigate back to the Question bank.
This commit is contained in:
parent
64b701190d
commit
e954482cb0
@ -175,7 +175,7 @@ class question_history_view extends view {
|
||||
* Display the header for the question bank in the history page to include question name and type.
|
||||
*/
|
||||
public function display_question_bank_header(): void {
|
||||
global $PAGE, $DB;
|
||||
global $PAGE, $DB, $OUTPUT;
|
||||
$sql = 'SELECT q.*
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
@ -187,13 +187,19 @@ class question_history_view extends view {
|
||||
WHERE be.id = qbe.id)
|
||||
AND qbe.id = ?';
|
||||
$latestquestiondata = $DB->get_record_sql($sql, [$this->entryid]);
|
||||
$historydata = [
|
||||
'questionname' => $latestquestiondata->name,
|
||||
'returnurl' => $this->basereturnurl,
|
||||
'questionicon' => print_question_icon($latestquestiondata)
|
||||
];
|
||||
// Header for the page before the actual form from the api.
|
||||
echo $PAGE->get_renderer('qbank_history')->render_history_header($historydata);
|
||||
if ($latestquestiondata) {
|
||||
$historydata = [
|
||||
'questionname' => $latestquestiondata->name,
|
||||
'returnurl' => $this->basereturnurl,
|
||||
'questionicon' => print_question_icon($latestquestiondata)
|
||||
];
|
||||
// Header for the page before the actual form from the api.
|
||||
echo $PAGE->get_renderer('qbank_history')->render_history_header($historydata);
|
||||
} else {
|
||||
// Continue when all the question versions are deleted.
|
||||
echo $OUTPUT->notification(get_string('allquestionversionsdeleted', 'qbank_history'), 'notifysuccess');
|
||||
echo $OUTPUT->continue_button($this->basereturnurl);
|
||||
}
|
||||
}
|
||||
|
||||
public function is_listing_specific_versions(): bool {
|
||||
|
@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['allquestionversionsdeleted'] = 'All versions of this question have been deleted.';
|
||||
$string['close_history'] = 'Close';
|
||||
$string['history_action'] = 'History';
|
||||
$string['history_header'] = 'Question history';
|
||||
|
@ -43,3 +43,15 @@ Feature: Use the qbank plugin manager page for question history
|
||||
And the "History" action should not exist for the "First question" question in the question bank
|
||||
And I click on "#qbank-history-close" "css_element"
|
||||
And the "History" action should exist for the "First question" question in the question bank
|
||||
|
||||
@javascript
|
||||
Scenario: Delete question from the history using Edit question menu
|
||||
Given I am on the "Test quiz" "mod_quiz > question bank" page logged in as "admin"
|
||||
And I choose "History" action for "First question" in the question bank
|
||||
When I choose "Delete" action for "First question" in the question bank
|
||||
And I press "Delete"
|
||||
And I should not see "First question"
|
||||
Then I should see "All versions of this question have been deleted."
|
||||
And I click on "Continue" "button"
|
||||
And I should see "Question bank"
|
||||
And I should not see "First question"
|
||||
|
Loading…
x
Reference in New Issue
Block a user