That allows us to have a few sentences explanation of each question type, and is also easier to fit into a tight layout.
This commit should also fix MDL-18214 Layout screwed in Safari with long category names.
<?php
+$string['addingcalculated'] = 'Adding a Calculated question';
$string['addmoreanswerblanks'] = 'Add another answer blank.';
$string['addmoreunitblanks'] = 'Blanks for $a More Units';
$string['answerhdr'] = 'Answer';
$string['atleastoneanswer'] = 'You need to provide at least one answer.';
+$string['calculated'] = 'Calculated';
+$string['calculatedsummary'] = 'Calculated questions are like numerical questions but with the numbers used selected randomly from a set when the quiz is taken.';
$string['correctanswershows'] = 'Correct answer shows';
$string['correctanswershowsformat'] = 'Format';
+$string['editingcalculated'] = 'Editing a Calculated question';
$string['existingcategory1'] = 'will use an already existing shared dataset';
$string['keptcategory1'] = 'will use the same existing shared dataset as before';
$string['keptlocal1'] = 'will use the same existing private dataset as before';
--- /dev/null
+<?php
+$string['addingdescription'] = 'Adding a Description';
+$string['editingdescription'] = 'Editing a Description';
+$string['description'] = 'Description';
+$string['descriptionsummary'] = 'This is not actually a question. Instead it is a way to add some instructions, rubric or other content to the quiz. This is similar to the way that Labels can be used to add content to the course page.';
+?>
\ No newline at end of file
--- /dev/null
+<?php
+$string['addingessay'] = 'Adding an Essay question';
+$string['editingessay'] = 'Editing a Essay question';
+$string['essay'] = 'Essay';
+$string['essaysummary'] = 'Allows a response of a few sentences or paragraphs. This must then be graded manually.';
+?>
\ No newline at end of file
<?php
+$string['addingmatch'] = 'Adding a Matching question';
$string['addmoreqblanks'] = '{no} More Sets of Blanks';
+$string['editingmatch'] = 'Editing a Matching question';
$string['filloutthreeqsandtwoas'] = 'You must provide at least two questions and three answers. You can provide extra wrong answers by giving an answer with a blank question. Entries where both the question and the answer are blank will be ignored.';
+$string['match'] = 'Matching';
+$string['matchsummary'] = 'The answer to each of a number of sub-question must be selected from a list of possibilities.';
$string['nomatchinganswerforq'] = 'You must specify an answer for this question.';
$string['notenoughquestions'] = 'You must supply at least $a question and answer pairs.';
$string['notenoughqsandas'] = 'You must supply at least $a->q questions and $a->a answers.';
-<?php // $Id: qtype_missingtype.php,v 1.1 2008-09-09 08:43:39 tjhunt Exp $
+<?php // $Id$
$string['missingtype'] = 'Missing type';
+$string['editingmissingtype'] = 'Editing a question of an unknown type';
$string['warningmissingtype'] = '<b>This question is of a type that has not been installed on your Moodle yet.<br />Please alert your Moodle administrator.</b>';
?>
<?php
-$string['addingmultianswer'] = 'Adding an Embedded answers (Cloze)';
+$string['addingmultianswer'] = 'Adding an Embedded answers (Cloze) question';
$string['correctanswer'] = 'Correct Answer';
$string['correctanswerandfeedback'] = 'Correct Answer and Feedback';
$string['decodeverifyquestiontext'] = 'Decode and Verify the Question Text';
-$string['editingmultianswer'] = 'Editing an Embedded answers (Cloze)';
+$string['editingmultianswer'] = 'Editing an Embedded answers (Cloze) question';
$string['layout'] = 'Layout';
$string['layoutselectinline'] = 'Dropdown menu in-line in the text';
$string['layouthorizontal'] = 'Horizontal row of radio-buttons';
$string['layoutundefined'] = 'Undefined layout';
$string['layoutvertical'] = 'Vertical column of radio buttons';
$string['multianswer'] = 'Embedded answers (Cloze)';
+$string['multianswersummary'] = 'Questions of this type are very flexible, but can only be created by entering text containing special codes that create embedded multiple choice, short answers and numerical questions.';
$string['nooptionsforsubquestion'] = 'Unable to get options for question part # $a->sub (question->id={$a->id})';
$string['noquestions'] = 'The Cloze(multianswer) question \"<strong>$a</strong>\" does not contain any question ';
$string['qtypenotrecognized'] = 'questiontype $a not recognized';
$string['fractionsnomax'] = 'One of the choices should be 100%%, so that it is<br />possible to get a full grade for this question.<br />Do you want to go back and fix this question?';
$string['incorrectfeedback'] = 'For any incorrect response';
$string['multichoice'] = 'Multiple choice';
+$string['multichoicesummary'] = 'Allows the selection of a single or multiple responses from a pre-defined list.';
$string['notenoughanswers'] = 'This type of question requires at least $a choices';
$string['overallfeedback'] = 'Overall Feedback';
$string['overallcorrectfeedback'] = 'Feedback for any correct response';
<?php
+$string['addingnumerical'] = 'Adding a Numerical question';
$string['addmoreanswerblanks'] = 'Blanks for {no} More Answers';
$string['addmoreunitblanks'] = 'Blanks for {no} More Units';
$string['answerno'] = 'Answer $a';
$string['answermustbenumberorstar'] = 'The answer must be a number, or \'*\'.';
+$string['editingnumerical'] = 'Editing a Numerical question';
$string['errorrepeatedunit'] = 'You cannot have two units with the same name.';
$string['errornomultiplier'] = 'You must specify a multiplier for this unit.';
$string['notenoughanswers'] = 'You must enter at least one answer.';
+$string['numerical'] = 'Numerical';
+$string['numericalsummary'] = 'Allows a numerical response, possibly with units, that is graded by comparing against various model answers, possibly with tolerances.';
$string['unithdr'] = 'Unit $a';
?>
\ No newline at end of file
<?php
$string['configselectmanualquestions'] = 'Can the random question type select a manually graded question when it is making its random choice of a question from a category?';
+$string['editingrandom'] = 'Editing a Random question';
+$string['random'] = 'Random';
$string['randomqname'] = 'Random ($a)';
$string['randomqplusname'] = 'Random ($a and sub-categories)';
$string['selectmanualquestions'] = 'Random questions can use manually graded questions';
$string['nosaincategory'] = 'There are no short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some questions in this category.';
$string['notenoughsaincategory'] = 'There is/are only $a->nosaquestions short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some more questions in this category or reduce the amount of questions you\'ve selected.';
$string['randomsamatch'] = 'Random short-answer matching';
+$string['randomsamatchsummary'] = 'Like a Matching question, but created randomly from the shortanswer questions in a particular category.';
?>
\ No newline at end of file
$string['editingshortanswer'] = 'Editing a Short answer question';
$string['filloutoneanswer'] = 'You must provide at least one possible answer. Answers left blank will not be used. \'*\' can be used as a wildcard to match any characters. The first matching answer will be used to determine the score and feedback.';
$string['shortanswer'] = 'Short answer';
+$string['shortanswersummary'] = 'Allows a response of one or a few words that is graded by comparing against various model answers, which may contain wildcards.';
?>
\ No newline at end of file
$string['feedbacktrue'] = 'Feedback for the response \'True\'.';
$string['true'] = 'True';
$string['truefalse'] = 'True/False';
+$string['truefalsesummary'] = 'A simple form of multiple choice question with just the two choices \'True\' and \'False\'.';
?>
$string['chooseqtypetoadd'] = 'Choose a question type to add';
$string['clicktoflag'] = 'Click to flag this question';
$string['clicktounflag'] = 'Click to un-flag this question';
+$string['createnewquestion'] = 'Create a new question ...';
$string['cwrqpfs'] = 'Random questions selecting questions from sub categories.';
$string['cwrqpfsinfo'] = '<p>During the upgrade to Moodle 1.9 we will separate question categories into
different contexts. Some question categories and questions on your site will have to have their sharing
$string['questiontype'] = 'Question type';
$string['questionuse'] = 'Use question in this activity';
$string['saveflags'] = 'Save the state of the flags';
+$string['selectacategory'] = 'Select a category:';
+$string['selectaqtypefordescription'] = 'Select a question type to see its description.';
$string['selectquestionsforbulk'] = 'Select questions for bulk actions';
$string['shareincontext'] = 'Share in context for $a';
$string['tofilecategory'] = 'Write category to file';
$string['accessnoticesheader'] = 'You can preview this quiz, but if this were a real attempt, you would be blocked because:';
$string['action'] = 'Action';
$string['adaptive'] = 'Adaptive mode';
+$string['addaquestion'] = 'Add a question ...';
$string['addcategory'] = 'Add category';
$string['adddescriptionlabel'] = 'Add description/label';
$string['addingcalculated'] = 'Adding a Calculated question';
$string['addrandom2'] = 'random questions';
$string['addrandomfromcategory'] = 'Add random questions from category:';
$string['addrandomquestion'] = 'Add random question';
+$string['addarandomquestion'] = 'Add a random question ...';
$string['addrandomquestiontoquiz'] = 'Add random question to quiz $a';
$string['addselectedtoquiz'] = 'Add selected to quiz';
$string['addtoquiz'] = 'Add to quiz';
$string['createfirst'] = 'You must create some short-answer questions first.';
$string['createmultiple'] = 'Add several random questions to quiz';
$string['createnewquestion'] = 'Create new question';
+$string['createquestionandadd'] = 'Create a new question and add it to the quiz.';
$string['custom'] = 'Custom format';
$string['dataitemneed'] = 'You need to add at least one set of data items to get a valid question';
$string['datasetdefinitions'] = 'Reusable dataset definitions for category $a';
*/
function quiz_print_pagecontrols($quiz,$pageurl,$page, $hasattempts){
global $CFG;
- $strcreatenewquestion=get_string("createnewquestion",'quiz');
- $strselectquestiontype=get_string("selectquestiontype",'quiz');
echo '<div class="pagecontrols">';
- // get the current context
+
+ // Get the current context
$thiscontext = get_context_instance(CONTEXT_COURSE, $quiz->course);
$contexts = new question_edit_contexts($thiscontext);
- // get default category and turn its infor into a string that works in an url
+
+ // Get the default category.
$defaultcategory = question_make_default_categories($contexts->all());
- $categorystring = "$defaultcategory->id,$defaultcategory->contextid";
- //create the url the question page will return to
- $returnurl_addtoquiz=new moodle_url($pageurl->out(true),
- array("addonpage"=>$page));
- //create the url of the new question page to forward to. return url is given
- //as a parameter and automatically urlencoded.
+
+ // Create the url the question page will return to
+ $returnurl_addtoquiz = new moodle_url($pageurl->out(true), array("addonpage" => $page));
+
+ // Print a button linking to the choose question type page.
$newquestionparams = array('returnurl' => $returnurl_addtoquiz->out(false),
- 'cmid'=>$quiz->cmid, "appendqnumstring"=>"addquestion", "category"=>$categorystring);
- $newquestionurl_object = new moodle_url("$CFG->wwwroot/question/question.php",
- $newquestionparams);
- $newquestionurl=$newquestionurl_object->out(false);
- echo get_string("addquestion","quiz").": ";
+ 'cmid' => $quiz->cmid, 'appendqnumstring' => 'addquestion');
+ create_new_question_button($defaultcategory->id, $newquestionparams, get_string('addaquestion', 'quiz'),
+ get_string('createquestionandadd', 'quiz'), $hasattempts);
+
if ($hasattempts) {
$disabled = 'disabled="disabled"';
} else {
$disabled = '';
}
- popup_form ($newquestionurl.'&qtype=',
- question_type_menu(),
- "addquestion_$page",
- "",
- $strselectquestiontype,
- "",
- "",
- false,
- "self",
- "",
- null,
- $strcreatenewquestion, $hasattempts);
- helpbutton("questiontypes", $strcreatenewquestion, "quiz");
- echo '<div class="adddescription">';
- print_single_button($CFG->wwwroot."/question/question.php",
- array("cmid"=>$quiz->cmid,
- "courseid"=>$quiz->course,
- "returnurl"=>$returnurl_addtoquiz->out(false),
- "appendqnumstring"=>"addquestion",
- "category"=>$categorystring,
- "qtype"=>"description"),
- get_string("adddescriptionlabel","quiz"),'get', '_self', false, '',
- $hasattempts);
- echo "\n</div>";
?>
- <div class="addrandomquestion">
<div class="singlebutton">
<form class="randomquestionform" action="<?php echo $CFG->wwwroot; ?>/mod/quiz/addrandom.php" method="get">
<div>
<input type="hidden" name="cmid" value="<?php echo $quiz->cmid; ?>" />
<input type="hidden" name="courseid" value="<?php echo $quiz->course; ?>" />
<input type="hidden" name="returnurl" value="<?php echo urlencode($pageurl->out(true)); ?>" />
- <input type="submit" id="addrandomdialoglaunch_<?php echo $page; ?>" value="<?php echo get_string("addrandomquestion","quiz"); ?>" <?php echo " $disabled"; ?> />
- <!--<a href="#" id="addrandomdialoglaunch_<?php echo $page; ?>">laa</a>-->
- <?php helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '');
- ?>
+ <input type="submit" id="addrandomdialoglaunch_<?php echo $page; ?>" value="<?php echo get_string('addarandomquestion','quiz'); ?>" <?php echo " $disabled"; ?> />
+ <!--<a href="#" id="addrandomdialoglaunch_<?php echo $page; ?>">laa</a>-->
</div>
</form>
</div>
- </div>
+ <?php helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, ''); ?>
<?php
echo "\n</div>";
}
class quiz_question_bank_view extends question_bank_view {
protected $quizhasattempts = false;
- protected function know_field_types() {
- $types = parent::know_field_types();
+ protected function known_field_types() {
+ $types = parent::known_field_types();
$types[] = new question_bank_add_to_quiz_action_column($this);
$types[] = new question_bank_question_name_text_column($this);
return $types;
--- /dev/null
+<?php // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Shows a screen where the user can choose a question type, before being
+ * redirected to question.php
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package questionbank
+ *//** */
+
+require_once(dirname(__FILE__) . '/../config.php');
+require_once(dirname(__FILE__) . '/editlib.php');
+
+// Read URL parameters.
+$categoryid = required_param('category', PARAM_INT);
+$cmid = optional_param('cmid', 0, PARAM_INT);
+$courseid = optional_param('courseid', 0, PARAM_INT);
+$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
+$appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA);
+
+// Place to accumulate hidden params for the form we will print.
+$hiddenparams = array('category' => $categoryid);
+
+// Validate params.
+if (!$category = $DB->get_record('question_categories', array('id' => $categoryid))) {
+ print_error('categorydoesnotexist', 'question', $returnurl);
+}
+
+if ($cmid){
+ list($module, $cm) = get_module_from_cmid($cmid);
+ require_login($cm->course, false, $cm);
+ $thiscontext = get_context_instance(CONTEXT_MODULE, $cmid);
+ $hiddenparams['cmid'] = $cmid;
+} else if ($courseid) {
+ require_login($courseid, false);
+ $thiscontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $module = null;
+ $cm = null;
+ $hiddenparams['courseid'] = $courseid;
+} else {
+ print_error('missingcourseorcmid', 'question');
+}
+
+// Check permissions.
+$categorycontext = get_context_instance_by_id($category->contextid);
+require_capability('moodle/question:add', $categorycontext);
+
+// Ensure other optional params get passed on to question.php.
+if (!empty($returnurl)) {
+ $hiddenparams['returnurl'] = $returnurl;
+}
+if (!empty($appendqnumstring)) {
+ $hiddenparams['appendqnumstring'] = $appendqnumstring;
+}
+
+$chooseqtype = get_string('chooseqtypetoadd', 'question');
+if ($cm !== null) {
+ $navlinks = array();
+ if (stripos($returnurl, "$CFG->wwwroot/mod/{$cm->modname}/view.php")!== 0){
+ //don't need this link if returnurl returns to view.php
+ $navlinks[] = array('name' => get_string('editinga', 'moodle', get_string('modulename', $cm->modname)), 'link' => $returnurl, 'type' => 'title');
+ }
+ $navlinks[] = array('name' => $chooseqtype, 'link' => '', 'type' => 'title');
+ $navigation = build_navigation($navlinks, $cm);
+ print_header_simple($chooseqtype, '', $navigation, '', '', true, update_module_button($cm->id, $cm->course, get_string('modulename', $cm->modname)));
+
+} else {
+ $navlinks = array();
+ $navlinks[] = array('name' => get_string('editquestions', 'question'), 'link' => $returnurl, 'type' => 'title');
+ $navlinks[] = array('name' => $chooseqtype, 'link' => '', 'type' => 'title');
+ $navigation = build_navigation($navlinks);
+ print_header_simple($chooseqtype, '', $navigation);
+}
+
+// Display a form to choose the question type.
+print_box_start('generalbox boxwidthnormal boxaligncenter', 'chooseqtypebox');
+print_choose_qtype_to_add_form($hiddenparams);
+print_box_end();
+
+print_footer($COURSE);
+
+
+?>
\ No newline at end of file
// TODO log this page view.
+ $localcss = '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.
+ '/lib/yui/container/assets/container.css" />';
$context = $contexts->lowest();
$streditingquestions = get_string('editquestions', "quiz");
if ($cm!==null) {
$navlinks[] = array('name' => format_string($module->name), 'link' => "$CFG->wwwroot/mod/{$cm->modname}/view.php?id={$cm->id}", 'type' => 'title');
$navlinks[] = array('name' => $streditingquestions, 'link' => '', 'type' => 'title');
$navigation = build_navigation($navlinks);
- print_header_simple($streditingquestions, '', $navigation, "", "", true, $strupdatemodule);
+ print_header_simple($streditingquestions, '', $navigation, '', $localcss, true, $strupdatemodule);
$currenttab = 'edit';
$mode = 'questions';
$navlinks[] = array('name' => $streditingquestions, 'link' => '', 'type' => 'title');
$navigation = build_navigation($navlinks);
- print_header_simple($streditingquestions, '', $navigation);
+ print_header_simple($streditingquestions, '', $navigation, '', $localcss);
// print tabs
$currenttab = 'questions';
include('tabs.php');
}
- echo '<table class="boxaligncenter" border="0" cellpadding="2" cellspacing="0">';
- echo '<tr><td valign="top">';
-
+ echo '<div class="questionbankwindow boxwidthwide boxaligncenter">';
$questionbank->display('questions', $pagevars['qpage'],
$pagevars['qperpage'], $pagevars['qsortorder'], $pagevars['qsortorderdecoded'],
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['showquestiontext']);
-
- echo '</td></tr>';
- echo '</table>';
+ echo "</div>\n";
print_footer($COURSE);
?>
protected function display_content($question, $rowclasses) {
if (question_has_capability_on($question, 'move')) {
- $this->print_icon('move', $this->strmove, $this->qbank->move_question_url($question->id));
+ $this->print_icon('t/move.gif', $this->strmove, $this->qbank->move_question_url($question->id));
}
}
}
protected function display_content($question, $rowclasses) {
if (question_has_capability_on($question, 'edit')) {
if ($question->hidden) {
- $this->print_icon('restore', $this->strrestore, $this->qbank->base_url()->out(false, array('unhide' => $question->id)));
+ $this->print_icon('t/restore.gif', $this->strrestore, $this->qbank->base_url()->out(false, array('unhide' => $question->id)));
} else {
- $this->print_icon('delete', $this->strdelete,
+ $this->print_icon('t/delete.gif', $this->strdelete,
$this->qbank->base_url()->out(false, array('deleteselected' => $question->id, 'q' . $question->id => 1)));
}
}
return $columns;
}
- protected function know_field_types() {
+ protected function known_field_types() {
return array(
new question_bank_checkbox_column($this),
new question_bank_question_type_column($this),
protected function init_column_types() {
$this->knowncolumntypes = array();
- foreach ($this->know_field_types() as $col) {
+ foreach ($this->known_field_types() as $col) {
$this->knowncolumntypes[$col->get_name()] = $col;
}
}
global $CFG;
/// Get all the existing categories now
+ echo '<div class="choosecategory">';
$catmenu = question_category_options($contexts, false, 0, true);
-
- $strcategory = get_string('selectcategory', 'quiz');
- $strshow = get_string('show', 'quiz');
- $streditcats = get_string('editcategories', 'quiz');
-
popup_form('edit.php?'.$pageurl->get_query_string().'&category=',
$catmenu, 'catmenu', $current, '', '', '', false, 'self',
- $strcategory);
+ get_string('selectacategory', 'question'));
+ echo "</div>\n";
}
protected function display_options($recurse = 1, $showhidden = false, $showquestiontext = false) {
}
protected function create_new_question_form($category, $canadd) {
- $qtypemenu = question_type_menu();
- $straddquestions = get_string('addquestions', 'quiz');
+ global $CFG;
echo '<div class="createnewquestion">';
if ($canadd) {
- popup_form($this->editquestionurl->out(false, array('category' => $category->id)) . '&qtype=',
- $qtypemenu, 'addquestion', '', 'choose', '', '', false, 'self', $straddquestions);
- helpbutton('questiontypes', $straddquestions, 'quiz');
+ create_new_question_button($category->id, $this->editquestionurl->params(),
+ get_string('createnewquestion', 'question'));
} else {
print_string('nopermissionadd', 'question');
}
echo '<fieldset class="invisiblefieldset" style="display: block;">';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo $pageurl->hidden_params_out();
- echo '<div class="categoryquestionscontainer">';
+ echo '<div class="categoryquestionscontainer">';
$this->start_table();
$rowcount = 0;
foreach ($questions as $question) {
$rowcount += 1;
}
$this->end_table();
+ echo "</div>\n";
echo '<div class="categorypagingbarcontainer pagingbottom">';
$paging = print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage', false, true);
$checkforfiles = true;
}
}
- $returnurl = $pageurl->out(false, array('category'=>"$tocategoryid,$contextid"));
+ $returnurl = $this->baseurl->out(false, array('category'=>"$tocategoryid,$contextid"));
if (!$checkforfiles){
if (!question_move_questions_to_category(implode(',', $questionids), $tocategory->id)) {
print_error('errormovingquestions', 'question', $returnurl, $questionids);
}
}
}
- redirect($pageurl->out());
+ redirect($this->baseurl->out());
} else {
print_error('invalidconfirm', 'question');
}
if(!$DB->set_field('question', 'hidden', 0, array('id', $unhide))) {
print_error('cannotunhidequestion', 'question');
}
- redirect($pageurl->out());
+ redirect($this->baseurl->out());
}
}
require_login();
}
}
+
+/**
+ * Print a form to let the user choose which question type to add.
+ * When the form is submitted, it goes to the question.php script.
+ * @param $hiddenparams hidden parameters to add to the form, in addition to
+ * the qtype radio buttons.
+ */
+function print_choose_qtype_to_add_form($hiddenparams) {
+ global $CFG, $QTYPES;
+ require_js(array('yui_yahoo','yui_dom','yui_event'));
+ require_js('question/qbank.js');
+ echo '<div id="chooseqtypehead" class="hd">' . "\n";
+ print_heading(get_string('chooseqtypetoadd', 'question'), '', 3);
+ echo "</div>\n";
+ echo '<div id="chooseqtype">' . "\n";
+ echo '<form action="' . $CFG->wwwroot . '/question/question.php" method="get"><div id="qtypeformdiv">' . "\n";
+ foreach ($hiddenparams as $name => $value) {
+ echo '<input type="hidden" name="' . s($name) . '" value="' . s($value) . '" />' . "\n";
+ }
+ echo "</div>\n";
+ $types = question_type_menu();
+ echo '<div class="qtypes">' . "\n";
+ echo '<div class="instruction">' . get_string('selectaqtypefordescription', 'question') . "</div>\n";
+ foreach ($types as $qtype => $localizedname) {
+ print_qtype_to_add_option($qtype, $localizedname);
+ }
+ echo "</div>\n";
+ echo '<div class="submitbuttons">' . "\n";
+ echo '<input type="submit" value="' . get_string('next') . '" id="chooseqtype_submit" />' . "\n";
+ echo '<input type="submit" id="chooseqtypecancel" name="addcancel" value="' . get_string('cancel') . '" />' . "\n";
+ echo "</div></form>\n";
+ echo "</div>\n";
+ print_js_call('qtype_chooser.init', array('chooseqtype'));
+}
+
+/**
+ * Private function used by the preceding one.
+ * @param $qtype the question type.
+ * @param $localizedname the localized name of this question type.
+ */
+function print_qtype_to_add_option($qtype, $localizedname) {
+ global $QTYPES;
+ echo '<div class="qtypeoption">' . "\n";
+ echo '<input type="radio" name="qtype" id="qtype_' . $qtype . '" value="' . $qtype . '" />';
+ echo '<label for="qtype_' . $qtype . '"><span class="qtypename">';
+ $fakequestion = new stdClass;
+ $fakequestion->qtype = $qtype;
+ print_question_icon($fakequestion);
+ echo $localizedname . '</span><span class="qtypesummary">' . get_string($qtype . 'summary', 'qtype_' . $qtype);
+ echo "</span></label>\n";
+ echo "</div>\n";
+}
+
+/**
+ * Print a button for creating a new question. This will open question/addquestion.php,
+ * which in turn goes to question/question.php before getting back to $params['returnurl']
+ * (by default the question bank screen).
+ *
+ * @param integer $categoryid The id of the category that the new question should be added to.
+ * @param array $params Other paramters to add to the URL. You need either $params['cmid'] or
+ * $params['courseid'], and you should probably set $params['returnurl']
+ * @param string $caption the text to display on the button.
+ * @param string $tooltip a tooltip to add to the button (optional).
+ * @param boolean $disabled if true, the button will be disabled.
+ */
+function create_new_question_button($categoryid, $params, $caption, $tooltip = '', $disabled = false) {
+ global $CFG;
+ static $choiceformprinted = false;
+ $params['category'] = $categoryid;
+ print_single_button($CFG->wwwroot . '/question/addquestion.php', $params,
+ $caption,'get', '', false, $tooltip, $disabled);
+ helpbutton('questiontypes', get_string('createnewquestion', 'question'), 'question');
+ require_js(array('yui_yahoo','yui_dom','yui_event', 'yui_dragdrop', 'yui_container'));
+ if (!$choiceformprinted) {
+ echo '<div id="qtypechoicecontainer">';
+ print_choose_qtype_to_add_form(array());
+ echo "</div>\n";
+ $choiceformprinted = true;
+ }
+}
+
?>
-// This script is included by question_bank_view in question/editlib.php.
+// This script is included by question_bank_view and other parts of question/editlib.php.
+// JavaScript belonging to question_bank_view.
question_bank = {
strselectall: '',
strdeselectall: '',
question_bank.headercheckbox.checked = false;
}
};
+
+// JavaScript to make the list of question types pop-up when you click an add
+// add question button.
+qtype_chooser = {
+ radiobuttons: [],
+ labels: [],
+ container: null,
+ submitbutton: null,
+
+ init: function(boxid) {
+ // Find the radio buttons.
+ qtype_chooser.radiobuttons = YAHOO.util.Dom.getElementsBy(
+ function(el) { return el.type == 'radio'; }, 'input' , boxid);
+ qtype_chooser.labels = YAHOO.util.Dom.getElementsByClassName('qtypeoption', 'div', boxid);
+
+ // Find the submit button.
+ qtype_chooser.submitbutton = document.getElementById(boxid + '_submit');
+ qtype_chooser.enable_disable_submit();
+
+ // Add the event handlers.
+ YAHOO.util.Event.addListener(boxid, 'click', qtype_chooser.enable_disable_submit);
+ YAHOO.util.Event.addListener(boxid, 'key_down', qtype_chooser.enable_disable_submit);
+ YAHOO.util.Event.addListener(boxid, 'key_up', qtype_chooser.enable_disable_submit);
+ YAHOO.util.Event.addListener(boxid, 'dblclick', qtype_chooser.double_click);
+
+ YAHOO.util.Event.onDOMReady(qtype_chooser.init_container);
+ },
+
+ enable_disable_submit: function() {
+ var ok = false;
+ for (var i = 0; i < qtype_chooser.radiobuttons.length; i++) {
+ if (qtype_chooser.radiobuttons[i].checked) {
+ ok = true;
+ YAHOO.util.Dom.addClass(qtype_chooser.labels[i], 'selected');
+ } else {
+ YAHOO.util.Dom.removeClass(qtype_chooser.labels[i], 'selected');
+ }
+ }
+ qtype_chooser.submitbutton.disabled = !ok;
+ },
+
+ double_click: function() {
+ if (!qtype_chooser.submitbutton.disabled) {
+ qtype_chooser.submitbutton.form.submit();
+ }
+ },
+
+ init_container: function() {
+ if (!document.getElementById('qtypechoicecontainer')) {
+ return;
+ }
+ qtype_chooser.container = new YAHOO.widget.Dialog('qtypechoicecontainer', {
+ constraintoviewport: true,
+ visible: false,
+ modal: true,
+ fixedcenter: true,
+ close: true,
+ draggable: true,
+ dragOnly: true,
+ postmethod: 'form',
+ zIndex: 1000
+ });
+ qtype_chooser.container.render();
+
+ YAHOO.util.Event.addListener('chooseqtypecancel', 'click', qtype_chooser.cancel_popup);
+
+ var addforms = YAHOO.util.Dom.getElementsBy(function(el) {
+ return /question\/addquestion\.php/.test(el.action); }, 'form', document.body);
+ for (var i = 0; i < addforms.length; i++) {
+ YAHOO.util.Event.addListener(addforms[i], 'submit', qtype_chooser.add_button_click);
+ }
+ },
+
+ add_button_click: function(e) {
+ var form = document.getElementById('qtypeformdiv');
+
+ var oldhidden = YAHOO.util.Dom.getElementsBy(
+ function(el) { return el.type == 'hidden'; }, 'input', form);
+ for (var i = 0; i < oldhidden.length; i++) {
+ oldhidden[i].parentNode.removeChild(oldhidden[i]);
+ }
+
+ var wantedhidden = YAHOO.util.Dom.getElementsBy(
+ function(el) { return el.type == 'hidden'; }, 'input', this);
+ for (i = 0; i < wantedhidden.length; i++) {
+ form.appendChild(wantedhidden[i].cloneNode(true));
+ }
+
+ qtype_chooser.container.show();
+ YAHOO.util.Event.preventDefault(e);
+ },
+
+ cancel_popup: function(e) {
+ qtype_chooser.container.hide();
+ YAHOO.util.Event.preventDefault(e);
+ }
+};
\ No newline at end of file
$returnurl = "{$CFG->wwwroot}/question/edit.php?courseid={$COURSE->id}";
}
+if (optional_param('addcancel', false, PARAM_BOOL)) {
+ redirect($returnurl);
+}
+
if ($id) {
if (!$question = $DB->get_record('question', array('id' => $id))) {
print_error('questiondoesnotexist', 'question', $returnurl);
}
} else {
- list($streditingquestion,) = $QTYPES[$question->qtype]->get_heading();
+ $streditingquestion = $QTYPES[$question->qtype]->get_heading();
if ($cm !== null) {
$strmodule = get_string('modulename', $cm->modname);
$strupdatemodule = has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $COURSE->id))
*** Question
***/
+#qtypechoicecontainer #chooseqtype .qtypes {
+ border-bottom-color: grey;
+}
+#qtypechoicecontainer #chooseqtype .selected {
+ background: #dddddd;
+}
+#qtypechoicecontainer #chooseqtype .instruction,
+#qtypechoicecontainer #chooseqtype .qtypesummary {
+ border-left-color: grey;
+ background-color: white;
+}
+
.que {
border-color: #DDD;
}
*** Question
***/
+#chooseqtype .instruction,
+#chooseqtype .qtypesummary {
+ font-size: 0.8em;
+}
+#chooseqtype .qtypename {
+ font-weight: bold;
+}
+#qtypechoicecontainer #chooseqtype .qtypename {
+ font-weight: normal;
+}
+
.que .info h2 {
font-size: 1.25em;
font-weight: bold;
margin-top: 0;
}
+#chooseqtypebox {
+ margin-top: 1em;
+}
+#chooseqtype h3 {
+ margin: 0 0 0.3em;
+}
+#chooseqtype .instruction {
+ display: none;
+}
+#chooseqtype .qtypeoption {
+ margin-bottom: 0.5em;
+}
+#chooseqtype .qtypename img {
+ padding: 0 0.3em;
+}
+#chooseqtype .qtypesummary {
+ display: block;
+ margin: 0 2em;
+}
+#chooseqtype .submitbuttons {
+ margin: 0.7em 0;
+ text-align: center;
+}
+
+#qtypechoicecontainer {
+ display: none;
+}
+body.jsenabled #qtypechoicecontainer {
+ display: block;
+}
+#qtypechoicecontainer #chooseqtype {
+ width: 30em;
+}
+#qtypechoicecontainer #chooseqtypehead h3 {
+ margin: 0;
+}
+#qtypechoicecontainer #chooseqtype .qtypes {
+ position: relative;
+ border-bottom: 1px solid grey;
+ padding: 0.24em 0;
+}
+#qtypechoicecontainer #chooseqtype .qtypeoption {
+ margin-bottom: 0;
+}
+#qtypechoicecontainer #chooseqtype .instruction,
+#qtypechoicecontainer #chooseqtype .qtypesummary {
+ display: none;
+ position: absolute;
+ top: 0px;
+ right: 0px;
+ bottom: 0px;
+ left: 60%;
+ margin: 0;
+ border-left: 1px solid grey;
+ padding: 0.3em 0.5em;
+}
+#qtypechoicecontainer #chooseqtype .instruction,
+#qtypechoicecontainer #chooseqtype .selected .qtypesummary {
+ display: block;
+}
+
.que {
text-align: left;
margin: 0 auto 1.8em auto;
z-index:999;
}
-#mod-quiz-edit .quizpagedelete img{
+#mod-quiz-edit .quizpagedelete img {
background-color:#d6d6d6;
padding:0.5em;
}
-#mod-quiz-edit .pagecontrols{
+#mod-quiz-edit .pagecontrols {
clear:both;
margin-left:0.5em;
padding-top:0.5em;
}
-#mod-quiz-edit .pagecontrols .singlebutton{
- float:left;
-}
-
-#mod-quiz-edit div.quizpage .pagecontent form#addquestion{
- margin-right:1em;
- -webkit-border-radius:0.2em;
- border-radius:0.2em;
- padding:0.3em;
+#mod-quiz-edit .pagecontrols .singlebutton {
+ float:left;
+ margin-left: 1em;
}
-
-#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform{
- padding-left:1em;
+#mod-quiz-edit .pagecontrols .helplink {
+ float:left;
}
#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform div{
/* it is a mystery why this has to be inline-table but
otherwise the layout gets screwed, even if
it is "inline" */
- display:inline-table;
+ display: inline-table;
}
#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform div input{
- display:inline;
-}
-
-#mod-quiz-edit div.quizpage .pagecontent .adddescription{
- clear:left;
- margin-top:0.3em;
-}
-
-#mod-quiz-edit div.quizpage .pagecontent .addrandomquestion{
- margin-top:0.3em;
+ display: inline;
}
/* a CSS class YUI container creates on the fly: */
}
/*start question bank*/
-
-/*TODO: below applies to also question bank, so when
-question bank is adapted to the new UI, add the appropriate
-css id's of question bank*/
-#mod-quiz-edit .questionbankwindow .createnewquestion select,
-#mod-quiz-edit .questionbankwindow #catmenu select{
- width:80%;
+.questionbankwindow .choosecategory,
+.questionbankwindow .createnewquestion {
+ padding: 0.3em;
}
-#mod-quiz-addrandom select {
- width:100%;
+.questionbankwindow .createnewquestion .singlebutton {
+ display: inline;
}
-#mod-quiz-edit table#categoryquestions{
+.questionbankwindow #catmenu_jump {
+ display: block;
+}
+#mod-quiz-edit .questionbankwindow .createnewquestion select,
+#mod-quiz-edit .questionbankwindow #catmenu select,
+#mod-quiz-edit .questionbankwindow #menucategory {
+ width: 100%;
+}
+table#categoryquestions {
width: 100%;
overflow: hidden;
table-layout: fixed;
}
-#mod-quiz-edit table#categoryquestions td,#mod-quiz-edit table#categoryquestions th{
+table#categoryquestions td,#mod-quiz-edit table#categoryquestions th{
overflow:hidden;
white-space:nowrap;
}
text-align: center;
}
-#mod-quiz-edit #categoryquestions .qtype {
+#categoryquestions .qtype {
width: 24px;
padding: 0;
}
#categoryquestions .questiontext p {
margin: 0;
}
-#mod-quiz-edit .categoryinfo{
- padding:0.3em;
+.categoryinfo {
+ padding: 0.3em;
}
#mod-quiz-edit .paging{
display:block;
}
-#mod-quiz-edit .questionsortoptions{
- margin-top:0.3em;
-}
-
#mod-quiz-edit .pagingbottom{
padding-bottom:0.3em;
}
clear:both;
}
-#mod-quiz-edit div.createnewquestion{
- padding-top:0.3em;
- clear:left;
-}
-
#mod-quiz-edit .sideblock .content{
padding:0;
}
margin-top:0.3em;
}
-#mod-quiz-edit .questionbank .categoryselectallcontainer{
- padding-bottom:0.5em;
-}
-
-#mod-quiz-edit .questionbank div.categoryquestionscontainer,
-#mod-quiz-edit .questionbank .categorysortopotionscontainer,
-#mod-quiz-edit .questionbank .categorypagingbarcontainer,
-#mod-quiz-edit .questionbank .categoryselectallcontainer{
+.questionbank div.categoryquestionscontainer,
+.questionbank .categorysortopotionscontainer,
+.questionbank .categorypagingbarcontainer,
+.questionbank .categoryselectallcontainer{
padding-left:0.3em;
padding-right:0.3em;
}
-#mod-quiz-edit .noquestionsincategory{
+.noquestionsincategory{
clear:both;
padding-top:1em;
padding-bottom:1em;
}
-#mod-quiz-edit .modulespecificbuttonscontainer{
+.modulespecificbuttonscontainer{
padding-left:0.3em;
padding-right:0.3em;
}