mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
added function callbacks for module specific controls to question bank.
This commit is contained in:
parent
0de94538ee
commit
85c375c3f8
@ -29,7 +29,62 @@
|
||||
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
|
||||
|
@ -10,6 +10,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package questionbank
|
||||
*/
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("editlib.php");
|
||||
|
||||
|
@ -191,7 +191,6 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
||||
$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");
|
||||
@ -210,10 +209,8 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -308,12 +305,10 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
||||
|
||||
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\" />",
|
||||
@ -377,9 +372,8 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
||||
' <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) {
|
||||
@ -389,20 +383,8 @@ function question_list($course, $pageurl, $categoryid, $cm = null,
|
||||
}
|
||||
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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user