本文整理汇总了PHP中create_new_question_button函数的典型用法代码示例。如果您正苦于以下问题:PHP create_new_question_button函数的具体用法?PHP create_new_question_button怎么用?PHP create_new_question_button使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_new_question_button函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quiz_print_pagecontrols
/**
* Print all the controls for adding questions directly into the
* specific page in the edit tab of edit.php
*
* @param unknown_type $quiz
* @param unknown_type $pageurl
* @param unknown_type $page
* @param unknown_type $hasattempts
*/
function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts)
{
global $CFG;
static $randombuttoncount = 0;
$randombuttoncount++;
echo '<div class="pagecontrols">';
// Get the current context
$thiscontext = get_context_instance(CONTEXT_COURSE, $quiz->course);
$contexts = new question_edit_contexts($thiscontext);
// Get the default category.
$defaultcategory = question_make_default_categories($contexts->all());
// 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');
create_new_question_button($defaultcategory->id, $newquestionparams, get_string('addaquestion', 'quiz'), get_string('createquestionandadd', 'quiz'), $hasattempts);
if ($hasattempts) {
$disabled = 'disabled="disabled"';
} else {
$disabled = '';
}
?>
<div class="singlebutton">
<form class="randomquestionform" action="<?php
echo $CFG->wwwroot;
?>
/mod/quiz/addrandom.php" method="get">
<div>
<input type="hidden" class="addonpage_formelement" name="addonpage_form" value="<?php
echo $page;
?>
" />
<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 $randombuttoncount;
?>
" value="<?php
echo get_string('addarandomquestion', 'quiz');
?>
" <?php
echo " {$disabled}";
?>
/>
</div>
</form>
</div>
<?php
helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '');
?>
<?php
echo "\n</div>";
}
示例2: quiz_print_pagecontrols
/**
* Print all the controls for adding questions directly into the
* specific page in the edit tab of edit.php
*
* @param object $quiz This is not the standard quiz object used elsewhere but
* it contains the quiz layout in $quiz->questions and the grades in
* $quiz->grades
* @param moodle_url $pageurl The url of the current page with the parameters required
* for links returning to the current page, as a moodle_url object
* @param int $page the current page number.
* @param bool $hasattempts Indicates whether the quiz has attempts
* @param object $defaultcategoryobj
* @param bool $canaddquestion is the user able to add and use questions anywere?
* @param bool $canaddrandom is the user able to add random questions anywere?
*/
function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts,
$defaultcategoryobj, $canaddquestion, $canaddrandom) {
global $CFG, $OUTPUT;
static $randombuttoncount = 0;
$randombuttoncount++;
echo '<div class="pagecontrols">';
// Get the current context.
$thiscontext = context_course::instance($quiz->course);
$contexts = new question_edit_contexts($thiscontext);
// Get the default category.
list($defaultcategoryid) = explode(',', $pageurl->param('cat'));
if (empty($defaultcategoryid)) {
$defaultcategoryid = $defaultcategoryobj->id;
}
if ($canaddquestion) {
// Create the url the question page will return to.
$returnurladdtoquiz = new moodle_url($pageurl, array('addonpage' => $page));
// Print a button linking to the choose question type page.
$returnurladdtoquiz = $returnurladdtoquiz->out_as_local_url(false);
$newquestionparams = array('returnurl' => $returnurladdtoquiz,
'cmid' => $quiz->cmid, 'appendqnumstring' => 'addquestion');
create_new_question_button($defaultcategoryid, $newquestionparams,
get_string('addaquestion', 'quiz'),
get_string('createquestionandadd', 'quiz'), $hasattempts);
}
if ($hasattempts) {
$disabled = 'disabled="disabled"';
} else {
$disabled = '';
}
if ($canaddrandom) {
?>
<div class="singlebutton">
<form class="randomquestionform" action="<?php echo $CFG->wwwroot;
?>/mod/quiz/addrandom.php" method="get">
<div>
<input type="hidden" class="addonpage_formelement" name="addonpage" value="<?php
echo $page; ?>" />
<input type="hidden" name="cmid" value="<?php echo $quiz->cmid; ?>" />
<input type="hidden" name="courseid" value="<?php echo $quiz->course; ?>" />
<input type="hidden" name="category" value="<?php
echo $pageurl->param('cat'); ?>" />
<input type="hidden" name="returnurl" value="<?php
echo s(str_replace($CFG->wwwroot, '', $pageurl->out(false))); ?>" />
<input type="submit" id="addrandomdialoglaunch_<?php
echo $randombuttoncount; ?>" value="<?php
echo get_string('addarandomquestion', 'quiz'); ?>" <?php
echo " $disabled"; ?> />
</div>
</form>
</div>
<?php echo $OUTPUT->help_icon('addarandomquestion', 'quiz');
}
echo "\n</div>";
}
示例3: create_new_question_form
protected function create_new_question_form($category, $canadd) {
global $CFG;
echo '<div class="createnewquestion">';
if ($canadd) {
create_new_question_button($category->id, $this->editquestionurl->params(),
get_string('createnewquestion', 'question'));
} else {
print_string('nopermissionadd', 'question');
}
echo '</div>';
}