From: tjhunt Date: Fri, 23 Jan 2009 05:01:37 +0000 (+0000) Subject: question bank: MDL-17992 and MDL-17397. Put back questiontext as a separate row optio... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b7a9dc5193a94ba6ac3d33852fd1f4e9d93d3329;p=moodle.git question bank: MDL-17992 and MDL-17397. Put back questiontext as a separate row option, and increase consistenscy between stand-alone qbank and the display in the quiz editing page. --- diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 779196a080..6937d5ce0f 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -1163,8 +1163,8 @@ class quiz_question_bank_view extends question_bank_view { echo '
'; echo "
"; echo $this->baseurl->hidden_params_out(array('recurse', 'showhidden', 'showquestiontext')); - $this->display_category_form_checkbox('recurse', $recurse); - $this->display_category_form_checkbox('showhidden', $showhidden); + $this->display_category_form_checkbox('recurse', get_string('recurse', 'quiz')); + $this->display_category_form_checkbox('showhidden', get_string('showhidden', 'quiz')); echo '
'; } diff --git a/question/editlib.php b/question/editlib.php index 9b857d5571..96b45264d7 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -149,12 +149,16 @@ abstract class question_bank_column_base { protected function init() { } + public function is_extra_row() { + return false; + } + /** * Output the column header cell. * @param integer $currentsort 0 for none. 1 for normal sort, -1 for reverse sort. */ public function display_header() { - echo ''; + echo ''; $sortable = $this->is_sortable(); $name = $this->get_name(); $title = $this->get_title(); @@ -255,7 +259,16 @@ abstract class question_bank_column_base { } protected function display_start($question, $rowclasses) { - echo ''; + echo ''; + } + + /** + * @return string the CSS classes to apply to every cell in this column. + */ + protected function get_classes() { + $classes = $this->get_extra_classes(); + $classes[] = $this->get_name(); + return implode(' ', $classes); } /** @@ -265,6 +278,13 @@ abstract class question_bank_column_base { */ abstract public function get_name(); + /** + * @return array any extra class names you would like applied to every cell in this column. + */ + public function get_extra_classes() { + return array(); + } + /** * Output the contents of this column. * @param object $question the row from the $question table, augmented with extra information. @@ -544,6 +564,10 @@ abstract class question_bank_action_column_base extends question_bank_column_bas return ' '; } + public function get_extra_classes() { + return array('iconcol'); + } + protected function print_icon($icon, $title, $url) { global $CFG; echo ' @@ -661,13 +685,36 @@ class question_bank_delete_action_column extends question_bank_action_column_bas * Base class for 'columns' that are actually displayed as a row following the main question row. */ abstract class question_bank_row_base extends question_bank_column_base { - // TODO + public function is_extra_row() { + return true; + } + + protected function display_start($question, $rowclasses) { + if ($rowclasses) { + echo '' . "\n"; + } else { + echo "\n"; + } + echo ''; + } + + protected function display_end($question, $rowclasses) { + echo "\n"; + } } /** * A column type for the name of the question name. */ class question_bank_question_text_row extends question_bank_row_base { + protected $formatoptions; + + protected function init() { + $this->formatoptions = new stdClass; + $this->formatoptions->noclean = true; + $this->formatoptions->para = false; + } + public function get_name() { return 'questiontext'; } @@ -677,18 +724,16 @@ class question_bank_question_text_row extends question_bank_row_base { } protected function display_content($question, $rowclasses) { - // TODO -// echo ''; -// $formatoptions = new stdClass; -// $formatoptions->noclean = true; -// $formatoptions->para = false; -// echo format_text($question->questiontext, $question->questiontextformat, -// $formatoptions, $this->course->id); -// echo "\n"; + $text = format_text($question->questiontext, $question->questiontextformat, + $this->formatoptions, $this->qbank->get_courseid()); + if ($text == '') { + $text = ' '; + } + echo $text; } public function get_required_fields() { - return array('q.questiontext'); + return array('q.questiontext', 'q.questiontextformat'); } } @@ -720,6 +765,7 @@ class question_bank_view { protected $course; protected $knowncolumntypes; protected $visiblecolumns; + protected $extrarows; protected $requiredcolumns; protected $sort; protected $countsql; @@ -755,8 +801,12 @@ class question_bank_view { } protected function wanted_columns() { - return array('checkbox', 'qtype', 'questionname', 'creatorname', + $columns = array('checkbox', 'qtype', 'questionname', 'creatorname', 'modifiername', 'editaction', 'previewaction', 'moveaction', 'deleteaction'); + if (optional_param('qbshowtext', false, PARAM_BOOL)) { + $columns[] = 'questiontext'; + } + return $columns; } protected function know_field_types() { @@ -770,6 +820,7 @@ class question_bank_view { new question_bank_preview_action_column($this), new question_bank_move_action_column($this), new question_bank_delete_action_column($this), + new question_bank_question_text_row($this), ); } @@ -782,13 +833,19 @@ class question_bank_view { protected function init_columns($wanted) { $this->visiblecolumns = array(); + $this->extrarows = array(); foreach ($wanted as $colname) { if (!isset($this->knowncolumntypes[$colname])) { throw new coding_exception('Unknown column type ' . $colname . ' requested in init columns.'); } - $this->visiblecolumns[$colname] = $this->knowncolumntypes[$colname]; + $column = $this->knowncolumntypes[$colname]; + if ($column->is_extra_row()) { + $this->extrarows[$colname] = $column; + } else { + $this->visiblecolumns[$colname] = $column; + } } - $this->requiredcolumns = $this->visiblecolumns; + $this->requiredcolumns = array_merge($this->visiblecolumns, $this->extrarows); } /** @@ -799,6 +856,17 @@ class question_bank_view { return isset($this->visiblecolumns[$colname]); } + /** + * @return integer The number of columns in the table. + */ + public function get_column_count() { + return count($this->visiblecolumns); + } + + public function get_courseid() { + return $this->course->id; + } + protected function init_sort() { $this->init_sort_from_params(); if (empty($this->sort)) { @@ -935,6 +1003,9 @@ class question_bank_view { foreach ($this->visiblecolumns as $column) { $fields = array_merge($fields, $column->get_required_fields()); } + foreach ($this->extrarows as $row) { + $fields = array_merge($fields, $row->get_required_fields()); + } $fields = array_unique($fields); /// Build the order by clause. @@ -1095,9 +1166,9 @@ class question_bank_view { echo '
'; echo "
"; echo $this->baseurl->hidden_params_out(array('recurse', 'showhidden', 'showquestiontext')); - $this->display_category_form_checkbox('recurse', $recurse); - $this->display_category_form_checkbox('showhidden', $showhidden); - $this->display_category_form_checkbox('showquestiontext', $showquestiontext); + $this->display_category_form_checkbox('recurse', get_string('recurse', 'quiz')); + $this->display_category_form_checkbox('showhidden', get_string('showhidden', 'quiz')); + $this->display_category_form_checkbox('qbshowtext', get_string('showquestiontext', 'quiz')); echo '
'; } @@ -1105,16 +1176,15 @@ class question_bank_view { /** * Print a single option checkbox. Used by the preceeding. */ - protected function display_category_form_checkbox($name, $checked) { + protected function display_category_form_checkbox($name, $label) { echo '
'; echo ''; - echo '
\n"; + echo ''; + echo "\n"; } protected function create_new_question_form($category, $canadd) { @@ -1187,8 +1257,10 @@ class question_bank_view { echo '
'; $this->start_table(); + $rowcount = 0; foreach ($questions as $question) { - $this->print_table_row($question); + $this->print_table_row($question, $rowcount); + $rowcount += 1; } $this->end_table(); @@ -1270,16 +1342,19 @@ class question_bank_view { echo "\n"; } - protected function get_row_classes($question) { + protected function get_row_classes($question, $rowcount) { $classes = array(); if ($question->hidden) { $classes[] = 'dimmed_text'; } + if (!empty($this->extrarows)) { + $classes[] = 'r' . ($rowcount % 2); + } return $classes; } - protected function print_table_row($question) { - $rowclasses = implode(' ', $this->get_row_classes($question)); + protected function print_table_row($question, $rowcount) { + $rowclasses = implode(' ', $this->get_row_classes($question, $rowcount)); if ($rowclasses) { echo '' . "\n"; } else { @@ -1289,30 +1364,9 @@ class question_bank_view { $column->display($question, $rowclasses); } echo "\n"; - } - - protected function display_question_sort_options($pageurl, $sortorder){ - //sort options - $html = "
"; - // POST method should only be used for parameters that change data - // or if POST method has to be used, the user must be redirected immediately to - // non-POSTed page to not break the back button - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= $pageurl->hidden_params_out(array('qsortorder')); - //choose_from_menu concatenates the form name with - //"menu" so the label is for menuqsortorder - $sortoptions = array('alpha' => get_string("qname", "quiz"), - 'typealpha' => get_string("qtypename", "quiz"), - 'age' => get_string("age", "quiz")); - $a = choose_from_menu($sortoptions, 'qsortorder', $sortorder, false, 'this.form.submit();', '0', true); - $html .= ''; - $html .= ''; - $html .= '
'; - $html .= "
\n"; - $html .= "
\n"; - echo $html; + foreach ($this->extrarows as $row) { + $row->display($question, $rowclasses); + } } public function process_actions() { diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index d5115443f9..b1e45606b2 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -1187,7 +1187,12 @@ css id's of question bank*/ #mod-quiz-edit .questionbankwindow div.header a{ color:#FFF; } - +#categoryquestions .r1 { + background: #e4e4e4; +} +#categoryquestions .header { + border: 0 none; +} /*** *** Modules: Resource diff --git a/theme/standard/styles_fonts.css b/theme/standard/styles_fonts.css index d614c826de..c9403cda94 100644 --- a/theme/standard/styles_fonts.css +++ b/theme/standard/styles_fonts.css @@ -1046,7 +1046,7 @@ body#mod-forum-index .generalbox .cell { text-decoration:underline; } #mod-quiz-edit div.question div.content .questiontext, -#categoryquestions .questiontext{ +#mod-quiz-edit #categoryquestions .questiontext { font-weight:bold; } #mod-quiz-edit div.question div.content div.questioncontrols{ diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 35666270b7..ea8bad2bbe 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -4718,6 +4718,10 @@ table.quizreviewsummary td.cell { padding-right:0.3em; } +.sideblock #categoryquestions .header { + text-align: center; + padding:0; +} #mod-quiz-edit div.question div.content .questionname, #categoryquestions .questionname{ @@ -5000,8 +5004,9 @@ css id's of question bank*/ width:100%; } #mod-quiz-edit table#categoryquestions{ - width:100%; - overflow:hidden; + width: 100%; + overflow: hidden; + table-layout: fixed; } #mod-quiz-edit table#categoryquestions td,#mod-quiz-edit table#categoryquestions th{ @@ -5009,10 +5014,27 @@ css id's of question bank*/ white-space:nowrap; } -#mod-quiz-edit table#categoryquestions .iconsmall{ - padding-left:5px; +#categoryquestions .iconcol { + width: 15px; + text-align: center; } +#categoryquestions .checkbox { + width: 19px; + text-align: center; +} + +#categoryquestions .qtype { + text-align: center; +} + +#mod-quiz-edit #categoryquestions .qtype { + width: 24px; +} + +#categoryquestions .questiontext p { + margin: 0; +} #mod-quiz-edit .categoryinfo{ padding:0.3em; }