From eaf45bce098698d6e62265dbcc0a1c682da596dc Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 3 Nov 2016 16:14:18 +0800 Subject: [PATCH] MDL-56724 boost: Update mod_choice to use bootstrap classes for styles --- mod/choice/renderer.php | 23 +-- mod/choice/report.php | 10 +- mod/choice/styles.css | 152 ------------------- theme/boost/scss/moodle/modules.scss | 15 -- theme/bootstrapbase/less/moodle/modules.less | 12 +- theme/bootstrapbase/style/moodle.css | 12 +- 6 files changed, 24 insertions(+), 200 deletions(-) delete mode 100644 mod/choice/styles.css diff --git a/mod/choice/renderer.php b/mod/choice/renderer.php index 48f31ba3cb7a1..8848c95a81d5d 100644 --- a/mod/choice/renderer.php +++ b/mod/choice/renderer.php @@ -44,7 +44,7 @@ public function display_options($options, $coursemoduleid, $vertical = false, $m $disabled = empty($options['previewonly']) ? array() : array('disabled' => 'disabled'); $html = html_writer::start_tag('form', $attributes); - $html .= html_writer::start_tag('ul', array('class'=>'choices' )); + $html .= html_writer::start_tag('ul', array('class'=>'choices list-unstyled unstyled' )); $availableoption = count($options['options']); $choicecount = 0; @@ -59,6 +59,7 @@ public function display_options($options, $coursemoduleid, $vertical = false, $m $option->attributes->type = 'radio'; } $option->attributes->id = 'choice_'.$choicecount; + $option->attributes->class = 'm-x-1'; $labeltext = $option->text; if (!empty($option->attributes->disabled)) { @@ -83,7 +84,7 @@ public function display_options($options, $coursemoduleid, $vertical = false, $m $html .= html_writer::tag('label', get_string('choicefull', 'choice')); } else { $html .= html_writer::empty_tag('input', - array('type' => 'submit', 'value' => get_string('savemychoice', 'choice'), 'class' => 'button')); + array('type' => 'submit', 'value' => get_string('savemychoice', 'choice'), 'class' => 'btn btn-primary')); } if (!empty($options['allowupdate']) && ($options['allowupdate'])) { @@ -147,7 +148,7 @@ public function display_publish_name_vertical($choices) { $table = new html_table(); $table->cellpadding = 0; $table->cellspacing = 0; - $table->attributes['class'] = 'results names '; + $table->attributes['class'] = 'results names table table-bordered'; $table->tablealign = 'center'; $table->summary = get_string('responsesto', 'choice', format_string($choices->name)); $table->data = array(); @@ -223,6 +224,7 @@ public function display_publish_name_vertical($choices) { } $userfullname = fullname($user, $choices->fullnamecapability); + $mediabody = ''; if ($choices->viewresponsecapability && $choices->deleterepsonsecapability) { $checkboxid = 'attempt-user'.$user->id.'-option'.$optionid; $attemptaction = html_writer::label($userfullname . ' ' . $optionsnames[$optionid], @@ -234,16 +236,17 @@ public function display_publish_name_vertical($choices) { $attemptaction .= html_writer::checkbox('userid[]', $user->id, '', null, array('id' => $checkboxid)); } - $data .= html_writer::tag('div', $attemptaction, array('class'=>'attemptaction')); + $mediabody .= html_writer::tag('div', $attemptaction, array('class'=>'media-left p-t-1')); } $userimage = $this->output->user_picture($user, array('courseid'=>$choices->courseid)); - $data .= html_writer::tag('div', $userimage, array('class'=>'image')); + $mediabody .= html_writer::tag('div', $userimage, array('class'=>'media-left')); - $userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course'=>$choices->courseid)); - $name = html_writer::tag('a', $userfullname, array('href'=>$userlink, 'class'=>'username')); - $data .= html_writer::tag('div', $name, array('class'=>'fullname')); - $data .= html_writer::tag('div','', array('class'=>'clearfloat')); - $optionusers .= html_writer::tag('div', $data, array('class'=>'user')); + $userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course' => $choices->courseid)); + $name = html_writer::tag('a', $userfullname, array('href' => $userlink)); + $mediabody .= html_writer::tag('div', $name, array('class' => 'media-body')); + $data .= html_writer::tag('div', $mediabody, array('class' => 'media m-b-1')); + + $optionusers .= $data; } $cell->text = $optionusers; } diff --git a/mod/choice/report.php b/mod/choice/report.php index 3fcde4218c358..1fc4c0518b6e0 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -257,19 +257,19 @@ $options["id"] = "$cm->id"; $options["download"] = "ods"; $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadods")); - $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption')); + $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption list-inline-item')); $options["download"] = "xls"; $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadexcel")); - $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption')); + $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption list-inline-item')); $options["download"] = "txt"; $button = $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadtext")); - $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption')); + $downloadoptions[] = html_writer::tag('li', $button, array('class'=>'reportoption list-inline-item')); - $downloadlist = html_writer::tag('ul', implode('', $downloadoptions)); + $downloadlist = html_writer::tag('ul', implode('', $downloadoptions), array('class' => 'list-inline inline')); $downloadlist .= html_writer::tag('div', '', array('class'=>'clearfloat')); - echo html_writer::tag('div',$downloadlist, array('class'=>'downloadreport')); + echo html_writer::tag('div',$downloadlist, array('class'=>'downloadreport m-t-1')); } echo $OUTPUT->footer(); diff --git a/mod/choice/styles.css b/mod/choice/styles.css deleted file mode 100644 index bdc53dfbc94a3..0000000000000 --- a/mod/choice/styles.css +++ /dev/null @@ -1,152 +0,0 @@ -.path-mod-choice .results { - border-collapse: separate; -} - -.path-mod-choice .results .data { - vertical-align: top; - white-space: nowrap; -} - -.path-mod-choice .button { - text-align: center; -} - -.path-mod-choice .attemptcell { - width: 5px; - white-space: nowrap; -} - -.path-mod-choice .anonymous, -.path-mod-choice .names { - margin-left: auto; - margin-right: auto; - width: 100%; -} - -.path-mod-choice .downloadreport { - border-width: 0; - margin-left: 10%; -} - -.path-mod-choice .choiceresponse { - width: 100%; -} - -.path-mod-choice .choiceresponse .picture { - width: 10px; - white-space: nowrap; -} - -.path-mod-choice .choiceresponse .fullname { - width: 100%; - white-space: nowrap; -} - -.path-mod-choice .responseheader { - width: 100%; - text-align: center; - margin-top: 10px; -} - -.path-mod-choice .choices .option label { - vertical-align: top; -} - -.path-mod-choice .choices .option input { - vertical-align: middle; -} - -.path-mod-choice .horizontal, -.path-mod-choice .vertical { - margin-left: 10%; - margin-right: 10%; -} - -.path-mod-choice .horizontal .choices .option { - padding-right: 20px; - display: inline-block; - white-space: normal; -} - -.path-mod-choice .horizontal .choices .button { - margin-top: 10px; -} - -.path-mod-choice ul.choices li { - list-style: none; -} - -.path-mod-choice .results { - text-align: center; -} - -.path-mod-choice .results.anonymous .graph.horizontal { - vertical-align: middle; - text-align: left; - width: 70%; -} - -.path-mod-choice .results.anonymous .graph.vertical, -.path-mod-choice .cell { - vertical-align: bottom; - text-align: center; -} - -.path-mod-choice .results.names .header { - width: 10%; - white-space: normal; -} - -.path-mod-choice .results.names .cell { - vertical-align: top; - text-align: left; -} - -.path-mod-choice .results.names .user, -.path-mod-choice #yourselection { - padding: 5px; -} - -.path-mod-choice .results.names .user .attemptaction, -.path-mod-choice .results.names .user .image, -.path-mod-choice .results.names .user .fullname { - float: left; -} - -.path-mod-choice .results.names .user .fullname { - padding-left: 5px; -} - -.path-mod-choice .results .data.header { - width: 10%; -} - -.path-mod-choice .responseaction { - text-align: center; -} - -.path-mod-choice .results .option { - white-space: normal; -} - -.path-mod-choice .response { - overflow: auto; -} - -.path-mod-choice .results .option, -.path-mod-choice .results .numberofuser, -.path-mod-choice .results .percentage { - font-weight: bold; - font-size: 108%; -} - -#page-mod-choice-report .downloadreport ul li { - list-style: none; - padding: 0 20px; - float: left; -} - -.path-mod-choice .clearfloat { - float: none; - clear: both; -} diff --git a/theme/boost/scss/moodle/modules.scss b/theme/boost/scss/moodle/modules.scss index 1ec5dc3f051ad..afea201b63c57 100644 --- a/theme/boost/scss/moodle/modules.scss +++ b/theme/boost/scss/moodle/modules.scss @@ -208,21 +208,6 @@ div#dock { // Choice module -.path-mod-choice { - .horizontal .choices { - margin: 0; - - .option { - display: inline-block; - padding: 10px; - } - } - - .results .data { - white-space: normal; - } -} - // Lesson module /** General styles (scope: all of lesson) **/ diff --git a/theme/bootstrapbase/less/moodle/modules.less b/theme/bootstrapbase/less/moodle/modules.less index 3514265a174f2..b2a01e9ce7436 100644 --- a/theme/bootstrapbase/less/moodle/modules.less +++ b/theme/bootstrapbase/less/moodle/modules.less @@ -291,15 +291,9 @@ div#dock { // Choice module .path-mod-choice { - .horizontal .choices { - margin: 0; - .option { - display: inline-block; - padding: 10px; - } - } - .results .data { - white-space: normal; + .media-left { + float: left; + padding-right: 1em; } } diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index 4c026913cd88d..1c75338816603 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -14704,15 +14704,9 @@ canvas { div#dock { display: none; } -.path-mod-choice .horizontal .choices { - margin: 0; -} -.path-mod-choice .horizontal .choices .option { - display: inline-block; - padding: 10px; -} -.path-mod-choice .results .data { - white-space: normal; +.path-mod-choice .media-left { + float: left; + padding-right: 1em; } .path-mod-lesson .firstpageoptions { margin: auto;