Commit 12d6dfc1 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-56826 questions: Add styling for boost theme

Changes include:
* question: Add bootstrap classes to buttons and selects so they look consistent.

* mod_quiz: Add bootstrap styles to report form elements

* question: Add bootstrap classes to question form elements

* And remove the success/fail styles from boost because they conflict badly
with the quiz plugin styles (making unreadable text).

* quiz: nav block buttons had black background

* quiz: Add bootstrap styles to quiz navigation buttons

* qtype_ddmarker: Remove bullets from list

Edit form coordinates preview had list bullets for each coordinate.

* boost: Prevent menu scrolling on quiz edit

* mod_quiz: Add bootstrap styles to edit quiz fields

Pagination and max grades forms.

* quiz: Undo some custom styles on review options

These checkboxes were laid out in a fake grid with no responsiveness
that conflicts with the bootstrap form-inline templates. Reset the
custom style to bootstrap default.

* quiz: Fix unit tests for boost changes

* qtype_ddwtos: Accurate positioning of drop targets

* questions: Make the review page responsive

* question: bootstrap 4 compatibility

.alert in bs4 contains no colours by default, you need to mix it with
one of the context classes to get some change in colours, borders etc.
parent b4d6669d
......@@ -984,7 +984,8 @@ function question_category_select_menu($contexts, $top = false, $currentcat = 0,
$options[] = array($group => $opts);
}
echo html_writer::label(get_string('questioncategory', 'core_question'), 'id_movetocategory', false, array('class' => 'accesshide'));
echo html_writer::select($options, 'category', $selected, $choose, array('id' => 'id_movetocategory'));
$attrs = array('id' => 'id_movetocategory', 'class' => 'custom-select');
echo html_writer::select($options, 'category', $selected, $choose, $attrs);
}
/**
......
......@@ -159,16 +159,17 @@ class edit_renderer extends \plugin_renderer_base {
$output = '';
$output .= html_writer::start_div('maxgrade');
$output .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'edit.php',
'class' => 'quizsavegradesform'));
'class' => 'quizsavegradesform form-inline'));
$output .= html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
$output .= html_writer::input_hidden_params($pageurl);
$a = html_writer::empty_tag('input', array('type' => 'text', 'id' => 'inputmaxgrade',
'name' => 'maxgrade', 'size' => ($structure->get_decimal_places_for_grades() + 2),
'value' => $structure->formatted_quiz_grade()));
'value' => $structure->formatted_quiz_grade(),
'class' => 'form-control'));
$output .= html_writer::tag('label', get_string('maximumgradex', '', $a),
array('for' => 'inputmaxgrade'));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-secondary m-l-1',
'name' => 'savechanges', 'value' => get_string('save', 'quiz')));
$output .= html_writer::end_tag('fieldset');
$output .= html_writer::end_tag('form');
......@@ -198,6 +199,7 @@ class edit_renderer extends \plugin_renderer_base {
'name' => 'repaginate',
'id' => 'repaginatecommand',
'value' => get_string('repaginatecommand', 'quiz'),
'class' => 'btn btn-secondary m-b-1',
);
if (!$structure->can_be_repaginated()) {
$buttonoptions['disabled'] = 'disabled';
......@@ -226,9 +228,14 @@ class edit_renderer extends \plugin_renderer_base {
$hiddenurl->param('sesskey', sesskey());
$select = html_writer::select($perpage, 'questionsperpage',
$structure->get_questions_per_page(), false);
$structure->get_questions_per_page(), false, array('class' => 'custom-select'));
$buttonattributes = array('type' => 'submit', 'name' => 'repaginate', 'value' => get_string('go'));
$buttonattributes = array(
'type' => 'submit',
'name' => 'repaginate',
'value' => get_string('go'),
'class' => 'btn btn-secondary m-l-1'
);
$formcontent = html_writer::tag('form', html_writer::div(
html_writer::input_hidden_params($hiddenurl) .
......
......@@ -216,7 +216,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
'value' => sesskey()));
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
'class' => 'questionflagsavebutton', 'name' => 'savingflags',
'class' => 'questionflagsavebutton btn btn-secondary', 'name' => 'savingflags',
'value' => get_string('saveflags', 'question')));
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
......@@ -239,7 +239,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
return html_writer::empty_tag('input', array('type' => 'button',
'value' => get_string('finishreview', 'quiz'),
'id' => 'secureclosebutton',
'class' => 'mod_quiz-next-nav'));
'class' => 'mod_quiz-next-nav btn btn-primary'));
} else {
return html_writer::link($url, get_string('finishreview', 'quiz'),
......@@ -351,7 +351,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @return string HTML fragment.
*/
protected function render_quiz_nav_question_button(quiz_nav_question_button $button) {
$classes = array('qnbutton', $button->stateclass, $button->navmethod);
$classes = array('qnbutton', $button->stateclass, $button->navmethod, 'btn', 'btn-secondary');
$extrainfo = array();
if ($button->currentpage) {
......@@ -536,7 +536,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
if ($page > 0 && $navmethod == 'free') {
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'previous',
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav'));
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary'));
}
if ($lastpage) {
$nextlabel = get_string('endtest', 'quiz');
......@@ -544,7 +544,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
$nextlabel = get_string('navigatenext', 'quiz');
}
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next',
'value' => $nextlabel, 'class' => 'mod_quiz-next-nav'));
'value' => $nextlabel, 'class' => 'mod_quiz-next-nav btn btn-primary'));
$output .= html_writer::end_tag('div');
return $output;
......
......@@ -593,7 +593,7 @@ abstract class quiz_attempts_report_table extends table_sql {
protected function submit_buttons() {
global $PAGE;
if (has_capability('mod/quiz:deleteattempts', $this->context)) {
echo '<input type="submit" id="deleteattemptsbutton" name="delete" value="' .
echo '<input type="submit" class="btn btn-secondary m-r-1" id="deleteattemptsbutton" name="delete" value="' .
get_string('deleteselected', 'quiz_overview') . '"/>';
$PAGE->requires->event_handler('#deleteattemptsbutton', 'click', 'M.util.show_confirm_dialog',
array('message' => get_string('deleteattemptcheck', 'quiz')));
......
......@@ -189,7 +189,7 @@ class quiz_overview_table extends quiz_attempts_report_table {
protected function submit_buttons() {
if (has_capability('mod/quiz:regrade', $this->context)) {
echo '<input type="submit" name="regrade" value="' .
echo '<input type="submit" class="btn btn-secondary m-r-1" name="regrade" value="' .
get_string('regradeselected', 'quiz_overview') . '"/>';
}
parent::submit_buttons();
......
......@@ -184,11 +184,11 @@ class quiz_overview_report extends quiz_attempts_report {
echo '<form action="'.$displayurl->out_omit_querystring().'">';
echo '<div>';
echo html_writer::input_hidden_params($displayurl);
echo '<input type="submit" name="regradeall" value="'.$regradealllabel.'"/>';
echo '<input type="submit" name="regradealldry" value="' .
echo '<input type="submit" class="btn btn-secondary" name="regradeall" value="'.$regradealllabel.'"/>';
echo '<input type="submit" class="btn btn-secondary m-l-1" name="regradealldry" value="' .
$regradealldrylabel . '"/>';
if ($regradesneeded) {
echo '<input type="submit" name="regradealldrydo" value="' .
echo '<input type="submit" class="btn btn-secondary m-l-1" name="regradealldrydo" value="' .
$regradealldrydolabel . '"/>';
}
echo '</div>';
......
......@@ -135,7 +135,7 @@ class category_condition extends condition {
echo \html_writer::start_div('choosecategory');
$catmenu = question_category_options($contexts, false, 0, true);
echo \html_writer::label(get_string('selectacategory', 'question'), 'id_selectacategory');
echo \html_writer::select($catmenu, 'category', $current, array(), array('class' => 'searchoptions', 'id' => 'id_selectacategory'));
echo \html_writer::select($catmenu, 'category', $current, array(), array('class' => 'searchoptions custom-select', 'id' => 'id_selectacategory'));
echo \html_writer::end_div() . "\n";
}
......
......@@ -756,11 +756,11 @@ class view {
// Print delete and move selected question.
if ($caneditall) {
echo '<input type="submit" name="deleteselected" value="' . get_string('delete') . "\" />\n";
echo '<input type="submit" class="btn btn-secondary" name="deleteselected" value="' . get_string('delete') . "\" />\n";
}
if ($canmoveall && count($addcontexts)) {
echo '<input type="submit" name="move" value="' . get_string('moveto', 'question') . "\" />\n";
echo '<input type="submit" class="btn btn-secondary" name="move" value="' . get_string('moveto', 'question') . "\" />\n";
question_category_select_menu($addcontexts, false, 0, "{$category->id},{$category->contextid}");
}
}
......
......@@ -760,19 +760,19 @@ class qtype_calculated extends question_type {
}
$menu1 = html_writer::label(get_string('lengthoption', 'qtype_calculated'),
'menucalclength', false, array('class' => 'accesshide'));
$menu1 .= html_writer::select($lengthoptions, 'calclength[]', $regs[4], null);
$menu1 .= html_writer::select($lengthoptions, 'calclength[]', $regs[4], null, array('class' => 'custom-select'));
$options = array('uniform' => get_string('uniformbit', 'qtype_calculated'),
'loguniform' => get_string('loguniformbit', 'qtype_calculated'));
$menu2 = html_writer::label(get_string('distributionoption', 'qtype_calculated'),
'menucalcdistribution', false, array('class' => 'accesshide'));
$menu2 .= html_writer::select($options, 'calcdistribution[]', $regs[1], null);
return '<input type="submit" onclick="'
$menu2 .= html_writer::select($options, 'calcdistribution[]', $regs[1], null, array('class' => 'custom-select'));
return '<input type="submit" class="btn btn-secondary" onclick="'
. "getElementById('addform').regenerateddefid.value='{$defid}'; return true;"
.'" value="'. get_string('generatevalue', 'qtype_calculated') . '"/><br/>'
. '<input type="text" size="3" name="calcmin[]" '
. '<input type="text" class="form-control" size="3" name="calcmin[]" '
. " value=\"{$regs[2]}\"/> &amp; <input name=\"calcmax[]\" "
. ' type="text" size="3" value="' . $regs[3] .'"/> '
. ' type="text" class="form-control" size="3" value="' . $regs[3] .'"/> '
. $menu1 . '<br/>'
. $menu2;
} else {
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -33,7 +33,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
'<div class="markertexts"></div>' +
'<div class="droparea"></div>' +
'<div class="dropzones"></div>' +
'<ul class="pager">' +
'<ul class="pager unstyled list-unstyled">' +
'<li><span id="xcoordpreview">X = </span></li>' +
'<li><span id="ycoordpreview">Y = </span></li>' +
'</ul>' +
......
......@@ -46,7 +46,7 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
$attributes = array(
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'place' . $place,
'class' => 'custom-select place' . $place,
);
$groupclass = 'group' . $group;
......
......@@ -82,7 +82,7 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
'menu' . $qa->get_qt_field_name('sub' . $key), false,
array('class' => 'accesshide')) .
html_writer::select($choices, $qa->get_qt_field_name('sub' . $key), $selected,
array('0' => 'choose'), array('disabled' => $options->readonly)) .
array('0' => 'choose'), array('disabled' => $options->readonly, 'class' => 'custom-select m-l-1')) .
' ' . $feedbackimage, array('class' => $classes));
$result .= html_writer::end_tag('tr');
......
......@@ -222,6 +222,7 @@ class qtype_multianswer_textfield_renderer extends qtype_multianswer_subq_render
'value' => $response,
'id' => $qa->get_qt_field_name($fieldname),
'size' => $size,
'class' => 'form-control',
);
if ($options->readonly) {
$inputattributes['readonly'] = 'readonly';
......@@ -229,7 +230,7 @@ class qtype_multianswer_textfield_renderer extends qtype_multianswer_subq_render
$feedbackimg = '';
if ($options->correctness) {
$inputattributes['class'] = $this->feedback_class($matchinganswer->fraction);
$inputattributes['class'] .= ' ' . $this->feedback_class($matchinganswer->fraction);
$feedbackimg = $this->feedback_image($matchinganswer->fraction);
}
......@@ -244,7 +245,7 @@ class qtype_multianswer_textfield_renderer extends qtype_multianswer_subq_render
$qa, 'question', 'answerfeedback', $matchinganswer->id),
s($correctanswer->answer), $options);
$output = html_writer::start_tag('span', array('class' => 'subquestion'));
$output = html_writer::start_tag('span', array('class' => 'subquestion form-inline'));
$output .= html_writer::tag('label', get_string('answer'),
array('class' => 'subq accesshide', 'for' => $inputattributes['id']));
$output .= html_writer::empty_tag('input', $inputattributes);
......
......@@ -116,7 +116,7 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
new question_pattern_expectation('~<input[^>]* class="incorrect" [^>]*/>~'),
new question_pattern_expectation('~<input[^>]* class="[^"]*incorrect[^"]*" [^>]*/>~'),
$this->get_contains_subq_status(question_state::$gaveup),
$this->get_does_not_contain_validation_error_expectation());
}
......
......@@ -97,7 +97,7 @@ abstract class qtype_multichoice_renderer_base extends qtype_with_combined_feedb
$question->make_html_inline($question->format_text(
$ans->answer, $ans->answerformat,
$qa, 'question', 'answer', $ansid)),
array('for' => $inputattributes['id']));
array('for' => $inputattributes['id'], 'class' => 'm-l-1'));
// Param $options->suppresschoicefeedback is a hack specific to the
// oumultiresponse question type. It would be good to refactor to
......
......@@ -49,6 +49,7 @@ class qtype_numerical_renderer extends qtype_renderer {
'value' => $currentanswer,
'id' => $inputname,
'size' => 80,
'class' => 'form-control',
);
if ($options->readonly) {
......@@ -65,7 +66,7 @@ class qtype_numerical_renderer extends qtype_renderer {
} else {
$fraction = 0;
}
$inputattributes['class'] = $this->feedback_class($fraction);
$inputattributes['class'] .= ' ' . $this->feedback_class($fraction);
$feedbackimg = $this->feedback_image($fraction);
}
......@@ -123,7 +124,7 @@ class qtype_numerical_renderer extends qtype_renderer {
$result = html_writer::tag('div', $questiontext, array('class' => 'qtext'));
if (!$placeholder) {
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
$result .= html_writer::start_tag('div', array('class' => 'ablock form-inline'));
$result .= html_writer::tag('label', get_string('answercolon', 'qtype_numerical'), array('for' => $inputattributes['id']));
$result .= html_writer::tag('span', $input, array('class' => 'answer'));
$result .= html_writer::end_tag('div');
......
......@@ -47,6 +47,7 @@ class qtype_shortanswer_renderer extends qtype_renderer {
'value' => $currentanswer,
'id' => $inputname,
'size' => 80,
'class' => 'form-control',
);
if ($options->readonly) {
......@@ -61,7 +62,7 @@ class qtype_shortanswer_renderer extends qtype_renderer {
} else {
$fraction = 0;
}
$inputattributes['class'] = $this->feedback_class($fraction);
$inputattributes['class'] .= ' ' . $this->feedback_class($fraction);
$feedbackimg = $this->feedback_image($fraction);
}
......@@ -84,7 +85,7 @@ class qtype_shortanswer_renderer extends qtype_renderer {
$result = html_writer::tag('div', $questiontext, array('class' => 'qtext'));
if (!$placeholder) {
$result .= html_writer::start_tag('div', array('class' => 'ablock'));
$result .= html_writer::start_tag('div', array('class' => 'ablock form-inline'));
$result .= html_writer::tag('label', get_string('answer', 'qtype_shortanswer',
html_writer::tag('span', $input, array('class' => 'answer'))),
array('for' => $inputattributes['id']));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment