Skip to content

Commit

Permalink
MDL-81587 quiz: fix layout of the add/edit random UI
Browse files Browse the repository at this point in the history
Some of the removed CSS seems no longer relevant now that we have
customisation options for the layout of the question bank.
  • Loading branch information
timhunt committed Apr 30, 2024
1 parent 792698a commit 78eeb7e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 52 deletions.
8 changes: 8 additions & 0 deletions mod/quiz/classes/question/bank/preview_action_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@ public function get_extra_classes(): array {
return ['iconcol'];
}

#[\Override]
public function get_title(): string {
return ' ';
}

#[\Override]
public function get_name() {
return 'previewquestionaction';
}

#[\Override]
public function get_default_width(): int {
return 45;
}

#[\Override]
protected function display_content($question, $rowclasses) {
global $PAGE;
if (!question_has_capability_on($question, 'use')) {
Expand Down
10 changes: 10 additions & 0 deletions mod/quiz/classes/question/bank/question_name_text_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@
*/
class question_name_text_column extends question_name_column {

#[\Override]
public function get_name(): string {
return 'questionnametext';
}

#[\Override]
public function get_default_width(): int {
// In the places this is used, this seems to make it use all the available space, without overflowing.
return 800;
}

#[\Override]
protected function display_content($question, $rowclasses): void {
echo \html_writer::start_tag('div');
$labelfor = $this->label_for($question);
Expand All @@ -44,6 +52,7 @@ protected function display_content($question, $rowclasses): void {
echo \html_writer::end_tag('div');
}

#[\Override]
public function get_required_fields(): array {
$fields = parent::get_required_fields();
$fields[] = 'q.questiontext';
Expand All @@ -52,6 +61,7 @@ public function get_required_fields(): array {
return $fields;
}

#[\Override]
public function load_additional_data(array $questions) {
parent::load_additional_data($questions);
parent::load_question_tags($questions);
Expand Down
24 changes: 9 additions & 15 deletions mod/quiz/classes/question/bank/random_question_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace mod_quiz\question\bank;

use qbank_viewquestiontype\question_type_column;

/**
* Subclass to customise the view of the question bank for the quiz editing screen.
*
Expand All @@ -25,24 +27,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class random_question_view extends custom_view {
/**
* Init required columns.
*
* @return void
*/
protected function init_required_columns(): void {
// Override core columns.
$this->corequestionbankcolumns = [
'question_type_column',
'question_name_text_column',
'preview_action_column'
#[\Override]
protected function get_question_bank_plugins(): array {
return [
new question_type_column($this),
new question_name_text_column($this),
new preview_action_column($this),
];
}

/**
* Prints the table of questions in a category with interactions
*
* @param \context $catcontext*/
#[\Override]
protected function display_bottom_controls(\context $catcontext): void {
}
}
16 changes: 1 addition & 15 deletions theme/boost/scss/moodle/question.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ table.question-bank-table {
table-layout: fixed;
overflow-x: scroll;
width: min-content;

td,
th {
max-width: 40vw;
width: max-content;
}
max-width: 100%;

th {
text-align: left;
Expand Down Expand Up @@ -676,12 +671,3 @@ body.path-question-type .mform fieldset.hidden {
margin: 0;
}
}

@include media-breakpoint-down(md) {
.question-bank-table {
td,
th {
max-width: 75vw;
}
}
}
12 changes: 1 addition & 11 deletions theme/boost/style/moodle.css
Original file line number Diff line number Diff line change
Expand Up @@ -31975,11 +31975,7 @@ table.question-bank-table {
table-layout: fixed;
overflow-x: scroll;
width: min-content;
}
table.question-bank-table td,
table.question-bank-table th {
max-width: 40vw;
width: max-content;
max-width: 100%;
}
table.question-bank-table th {
text-align: left;
Expand Down Expand Up @@ -32525,12 +32521,6 @@ body.path-question-type .mform fieldset.hidden {
margin: 0;
}
}
@media (max-width: 991.98px) {
.question-bank-table td,
.question-bank-table th {
max-width: 75vw;
}
}
/* user.less */
.userprofile .fullprofilelink {
text-align: center;
Expand Down
12 changes: 1 addition & 11 deletions theme/classic/style/moodle.css
Original file line number Diff line number Diff line change
Expand Up @@ -31975,11 +31975,7 @@ table.question-bank-table {
table-layout: fixed;
overflow-x: scroll;
width: min-content;
}
table.question-bank-table td,
table.question-bank-table th {
max-width: 40vw;
width: max-content;
max-width: 100%;
}
table.question-bank-table th {
text-align: left;
Expand Down Expand Up @@ -32525,12 +32521,6 @@ body.path-question-type .mform fieldset.hidden {
margin: 0;
}
}
@media (max-width: 991.98px) {
.question-bank-table td,
.question-bank-table th {
max-width: 75vw;
}
}
/* user.less */
.userprofile .fullprofilelink {
text-align: center;
Expand Down

0 comments on commit 78eeb7e

Please sign in to comment.