require_once("../../config.php");
require_once($CFG->dirroot.'/mod/quiz/editlib.php');
-
+ /**
+ * Callback function called from question_list() function (which is called from showbank()
+ * Displays action icon as first action for each question.
+ */
+ function module_specific_actions($pageurl, $questionid, $cmid){
+ global $CFG;
+ if (has_capability("mod/quiz:manage", get_context_instance(CONTEXT_MODULE, $cmid))){
+ $straddtoquiz = get_string("addtoquiz", "quiz");
+ $out = "<a title=\"$straddtoquiz\" href=\"edit.php?".$pageurl->get_query_string()."&addquestion=$questionid&sesskey=".sesskey()."\"><img
+ src=\"$CFG->pixpath/t/moveleft.gif\" alt=\"$straddtoquiz\" /></a> ";
+ return $out;
+ } else {
+ return '';
+ }
+ }
+ /**
+ * Callback function called from question_list() function (which is called from showbank()
+ * Displays button in form with checkboxes for each question.
+ */
+ function module_specific_buttons($cmid){
+ global $THEME;
+ if (has_capability("mod/quiz:manage", get_context_instance(CONTEXT_MODULE, $cmid))){
+ $straddtoquiz = get_string("addtoquiz", "quiz");
+ $out = "<input type=\"submit\" name=\"add\" value=\"{$THEME->larrow} $straddtoquiz\" />\n";
+ $out .= '</td><td>';
+ return $out;
+ } else {
+ return '';
+ }
+ }
+
+
+ /**
+ * Callback function called from question_list() function (which is called from showbank()
+ * Displays button in form with checkboxes for each question.
+ */
+ function module_specific_controls($totalnumber, $recurse, $categoryid, $cmid){
+ if (has_capability("mod/quiz:manage", get_context_instance(CONTEXT_MODULE, $cmid))){
+ for ($i = 1;$i <= min(10, $totalnumber); $i++) {
+ $randomcount[$i] = $i;
+ }
+ for ($i = 20;$i <= min(100, $totalnumber); $i += 10) {
+ $randomcount[$i] = $i;
+ }
+ $out = '<br />';
+ $out .= get_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
+ $out .= '<input type="hidden" name="recurse" value="'.$recurse.'" />';
+ $out .= "<input type=\"hidden\" name=\"categoryid\" value=\"$categoryid\" />";
+ $out .= ' <input type="submit" name="addrandom" value="'. get_string('add') .'" />';
+ $out .= helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '', true);
+ return $out;
+ } else {
+ return '';
+ }
+ }
+
list($thispageurl, $courseid, $cmid, $cm, $quiz, $pagevars) = question_edit_setup(true);
//these params are only passed from page request to request while we stay on this page
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package questionbank
*/
+
require_once("../config.php");
require_once("editlib.php");
$straction = get_string("action");
$strrestore = get_string('restore');
- $straddtoquiz = get_string("addtoquiz", "quiz");
$strtype = get_string("type", "quiz");
$strcreatemultiple = get_string("createmultiple", "quiz");
$strpreview = get_string("preview","quiz");
$canedit = has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course));
if ($cm AND $cm->modname == 'quiz') {
- $editingquiz = has_capability("mod/quiz:manage", get_context_instance(CONTEXT_MODULE, $cm->id));
$quizid = $cm->instance;
} else {
- $editingquiz = false;
$quizid = 0;
}
echo "<tr>\n<td style=\"white-space:nowrap;\" $nameclass>\n";
- // add to quiz
- if ($editingquiz) {
- echo "<a title=\"$straddtoquiz\" href=\"edit.php?".$pageurl->get_query_string()."&addquestion=$question->id&sesskey=$USER->sesskey\"><img
- src=\"$CFG->pixpath/t/moveleft.gif\" alt=\"$straddtoquiz\" /></a> ";
+ if (function_exists('module_specific_actions')) {
+ echo module_specific_actions($pageurl, $question->id, $cm->id);
}
-
+
// preview
link_to_popup_window('/question/preview.php?id=' . $question->id . '&quizid=' . $quizid, 'questionpreview',
"<img src=\"$CFG->pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"$strpreview\" />",
' <a href="javascript:deselect_all_in(\'TABLE\', null, \'categoryquestions\');">'.$strselectnone.'</a>'.
'</td><td align="right"><b> '.get_string('withselected', 'quiz').':</b></td></tr><tr><td>';
- if ($editingquiz) {
- echo "<input type=\"submit\" name=\"add\" value=\"{$THEME->larrow} $straddtoquiz\" />\n";
- echo '</td><td>';
+ if (function_exists('module_specific_buttons')) {
+ echo module_specific_buttons($cm->id);
}
// print delete and move selected question
if ($canedit) {
}
echo "</td></tr></table>";
- // add random question
- if ($editingquiz) {
- for ($i = 1;$i <= min(10, $totalnumber); $i++) {
- $randomcount[$i] = $i;
- }
- for ($i = 20;$i <= min(100, $totalnumber); $i += 10) {
- $randomcount[$i] = $i;
- }
- echo '<br />';
- print_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
- echo '<input type="hidden" name="recurse" value="'.$recurse.'" />';
- echo "<input type=\"hidden\" name=\"categoryid\" value=\"$category->id\" />";
- echo ' <input type="submit" name="addrandom" value="'. get_string('add') .'" />';
- helpbutton('random', get_string('random', 'quiz'), 'quiz');
+ if (function_exists('module_specific_controls')) {
+ echo module_specific_controls($totalnumber, $recurse, $category->id, $cm->id);
}
echo '</fieldset>';
echo "</form>\n";