From 624cbc9c26a5f4b56083b2c1321891f0af62bc82 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 20 Feb 2007 01:48:09 +0000 Subject: [PATCH] MDL-4793 - Option to show question text in the question bank. Also, fix layout problems on the quiz editing screen. Merged from MOODLE_18_STABLE. --- lang/en_utf8/quiz.php | 1 + mod/quiz/editlib.php | 8 +-- question/editlib.php | 128 +++++++++++++++++++++++------------------- question/showbank.php | 38 +++++++------ 4 files changed, 98 insertions(+), 77 deletions(-) diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 1f5e1eb8e8..59b102b753 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -480,6 +480,7 @@ $string['showfeedback'] = 'After answering, show feedback?'; $string['showhidden'] = 'Also show old questions'; $string['shownoattempts'] = 'Show students with no attempts'; $string['shownoattemptsonly'] = 'Show only students with no attempts'; +$string['showquestiontext'] = 'Show show question text in the question list'; $string['showteacherattempts'] = 'Show teacher attempts'; $string['shuffle'] = 'Shuffle'; $string['shuffleanswers'] = 'Shuffle answers'; diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 4db09e5b11..f301f6b639 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -176,17 +176,17 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r $lastindex++; } echo "
"; - echo '
'; + echo '
'; echo "sesskey\" />"; print_simple_box_start(); - echo "\n"; + echo "
\n"; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; - echo ""; + echo ""; echo "\n"; foreach ($order as $i => $qnum) { diff --git a/question/editlib.php b/question/editlib.php index 00848ed6c2..dd2d8417de 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -130,7 +130,7 @@ function question_category_menu($courseid, $published=false) { /** * prints a form to choose categories */ -function question_category_form($course, $current, $recurse=1, $showhidden=false) { +function question_category_form($course, $current, $recurse=1, $showhidden=false, $showquestiontext=false) { global $CFG; /// Make sure the default category exists for this course @@ -159,7 +159,7 @@ function question_category_form($course, $current, $recurse=1, $showhidden=false $strshow = get_string("show", "quiz"); $streditcats = get_string("editcategories", "quiz"); - echo "
$strorder#$strquestionname$strquestionname$strtype$strgrade$straction$straction
"; + echo "'; } @@ -282,22 +282,7 @@ function question_list($course, $categoryid, $quizid=0, echo ''; } - echo ''; - echo '
"; echo "$strcategory: "; echo ""; popup_form ("edit.php?courseid=$course->id&cat=", $catmenu, "catmenu", $current, "", "", "", false, "self"); @@ -174,30 +174,29 @@ function question_category_form($course, $current, $recurse=1, $showhidden=false echo ''; echo "
"; - echo '
'; - echo "id}\" />"; - echo ''; - echo ''; - print_string('recurse', 'quiz'); - // hide-feature - echo '
'; - echo ''; - echo 'id}\" />\n"; + question_category_form_checkbox('recurse', $recurse); + question_category_form_checkbox('showhidden', $showhidden); + question_category_form_checkbox('showquestiontext', $showquestiontext); + echo ''; +} + +/** + * Private funciton to help the preceeding function. + */ +function question_category_form_checkbox($name, $checked) { + echo '
'; + echo ''; - print_string('showhidden', 'quiz'); - echo '
'; + echo '\n"; } - /** * Prints the table of questions in a category with interactions * @@ -210,7 +209,8 @@ function question_category_form($course, $current, $recurse=1, $showhidden=false * @param boolean $showhidden True if also hidden questions should be displayed */ function question_list($course, $categoryid, $quizid=0, - $recurse=1, $page=0, $perpage=100, $showhidden=false, $sortorder='qtype, name ASC') { + $recurse=1, $page=0, $perpage=100, $showhidden=false, $sortorder='qtype, name ASC', + $showquestiontext = false) { global $QTYPE_MENU, $USER, $CFG, $THEME; $context = get_context_instance(CONTEXT_COURSE, $course->id); @@ -272,7 +272,7 @@ function question_list($course, $categoryid, $quizid=0, echo '
'; popup_form ("$CFG->wwwroot/question/question.php?category=$category->id&qtype=", $qtypemenu, "addquestion", "", "choose", "", "", false, "self"); - echo ''; + echo ''; helpbutton("questiontypes", $strcreatenewquestion, "quiz"); echo '
'; - - if (has_capability('moodle/question:import', $context)) { - echo ''.$strimportquestions.''; - helpbutton("import", $strimportquestions, "quiz"); - echo ' | '; - } - - if (has_capability('moodle/question:export', $context)) { - echo "wwwroot/question/export.php?category={$category->id}&courseid={$course->id}\">$strexportquestions"; - helpbutton("export", $strexportquestions, "quiz"); - } - echo '
'; - echo ''; $categorylist = ($recurse) ? question_categorylist($category->id) : $category->id; @@ -330,23 +315,38 @@ function question_list($course, $categoryid, $quizid=0, $canedit = has_capability('moodle/question:manage', $context); echo '
'; - echo '
'; + echo '
'; echo ''; print_simple_box_start(); - echo ''; - $actionwidth = $canedit ? 95 : 70; - echo ""; + echo '
$straction
'; + echo ""; $sortoptions = array('name, qtype ASC' => get_string("sortalpha", "quiz"), 'qtype, name ASC' => get_string("sorttypealpha", "quiz"), 'id ASC' => get_string("sortage", "quiz")); $orderselect = choose_from_menu ($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true); $orderselect .= ''; - echo " - "; + echo " + "; echo "\n"; foreach ($questions as $question) { - echo "\n\n\n"; - if ($question->hidden) { - echo '\n"; - } else { - echo "\n"; - } - echo "\n"; + echo "\n"; echo "\n"; + if($showquestiontext){ + echo '\n"; + } } - echo '
$straction$strquestionname $orderselect$strtype$strquestionname $orderselect$strtype
\n"; + $nameclass = ''; + $textclass = ''; + if ($question->hidden) { + $nameclass = 'dimmed_text'; + $textclass = 'dimmed_text'; + } + if ($showquestiontext) { + $nameclass .= ' header'; + } + if ($nameclass) { + $nameclass = 'class="' . $nameclass . '"'; + } + if ($textclass) { + $textclass = 'class="' . $textclass . '"'; + } + + echo "
\n"; // add to quiz if ($quizid && has_capability('mod/quiz:manage', $context)) { @@ -375,27 +375,41 @@ function question_list($course, $categoryid, $quizid=0, echo " id\" value=\"1\" />"; echo "'.$question->name."".$question->name."\n"; + echo "" . $question->name . "\n"; print_question_icon($question, $canedit); echo "
'; + $formatoptions = new stdClass; + $formatoptions->noclean = true; + $formatoptions->para = false; + echo format_text($question->questiontext, $question->questiontextformat, + $formatoptions, $course->id); + echo "
'; - print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&perpage=$perpage&"); + echo "
\n"; + print_simple_box_end(); + + $paging = print_paging_bar($totalnumber, $page, $perpage, + "edit.php?courseid={$course->id}&perpage=$perpage&", 'page', + false, true); if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) { if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) { - echo ''.get_string('showall', 'moodle', $totalnumber).''; + $showall = ''.get_string('showall', 'moodle', $totalnumber).''; } else { - echo ''.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).''; + $showall = ''.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).''; + } + if ($paging) { + $paging = substr($paging, 0, strrpos($paging, '')); + $paging .= "
$showall"; + } else { + $paging = "
$showall
"; } } - echo "
\n"; - print_simple_box_end(); + echo $paging; echo '
'; echo ''.$strselectall.' /'. diff --git a/question/showbank.php b/question/showbank.php index 14a19c777b..57abaeea2d 100644 --- a/question/showbank.php +++ b/question/showbank.php @@ -147,39 +147,45 @@ $SESSION->questionpage = 0; } - if(isset($_REQUEST['recurse'])) { - $SESSION->questionrecurse = optional_param('recurse', 0, PARAM_BOOL); - } - - if(isset($_REQUEST['showhidden'])) { - $SESSION->questionshowhidden = optional_param('showhidden', 0, PARAM_BOOL); + if (empty($SESSION->questioncat) or !count_records_select("question_categories", "id = '{$SESSION->questioncat}' AND (course = '{$course->id}' OR publish = '1')")) { + $category = get_default_question_category($course->id); + $SESSION->questioncat = $category->id; } -/// all commands have been dealt with, now print the page - -if (empty($SESSION->questioncat) or !count_records_select("question_categories", "id = '{$SESSION->questioncat}' AND (course = '{$course->id}' OR publish = '1')")) { - $category = get_default_question_category($course->id); - $SESSION->questioncat = $category->id; + if(($recurse = optional_param('recurse', -1, PARAM_BOOL)) != -1) { + $SESSION->questionrecurse = $recurse; } if (!isset($SESSION->questionrecurse)) { $SESSION->questionrecurse = 1; } + + if(($showhidden = optional_param('showhidden', -1, PARAM_BOOL)) != -1) { + $SESSION->questionshowhidden = $showhidden; + } if (!isset($SESSION->questionshowhidden)) { - $SESSION->questionshowhidden = false; + $SESSION->questionshowhidden = 0; + } + + if(($showquestiontext = optional_param('showquestiontext', -1, PARAM_BOOL)) != -1) { + $SESSION->questionshowquestiontext = $showquestiontext; + } + if (!isset($SESSION->questionshowquestiontext)) { + $SESSION->questionshowquestiontext = 0; } // starts with category selection form if (has_capability('moodle/question:managecategory', $context)) { print_simple_box_start(); - question_category_form($course, $SESSION->questioncat, $SESSION->questionrecurse, $SESSION->questionshowhidden); + question_category_form($course, $SESSION->questioncat, $SESSION->questionrecurse, + $SESSION->questionshowhidden, $SESSION->questionshowquestiontext); print_simple_box_end(); - - print_spacer(5,1); } // continues with list of questions print_simple_box_start(); - question_list($course, $SESSION->questioncat, isset($modform->instance) ? $modform->instance : 0, $SESSION->questionrecurse, $page, $perpage, $SESSION->questionshowhidden, $sortorder); + question_list($course, $SESSION->questioncat, isset($modform->instance) ? $modform->instance : 0, + $SESSION->questionrecurse, $page, $perpage, $SESSION->questionshowhidden, $sortorder, + $SESSION->questionshowquestiontext); print_simple_box_end(); ?> -- 2.39.5