本文整理汇总了PHP中question_edit_form::question_edit_form方法的典型用法代码示例。如果您正苦于以下问题:PHP question_edit_form::question_edit_form方法的具体用法?PHP question_edit_form::question_edit_form怎么用?PHP question_edit_form::question_edit_form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_edit_form
的用法示例。
在下文中一共展示了question_edit_form::question_edit_form方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fullclone
function question_edit_multianswer_form(&$submiturl, &$question, &$category, &$contexts, $formeditable = true)
{
global $QTYPES, $SESSION, $CFG, $DB;
$this->regenerate = true;
if ("1" == optional_param('reload', '', PARAM_INT)) {
$this->reload = true;
} else {
$this->reload = false;
}
// $this->question = $question;
$this->used_in_quiz = false;
// echo "<p> question <pre>";print_r($question);echo "</pre></p>";
if (isset($question->id) && $question->id != 0) {
$this->savedquestiondisplay = fullclone($question);
if ($list = $DB->get_records('quiz_question_instances', array('question' => $question->id))) {
foreach ($list as $key => $li) {
$this->nb_of_quiz++;
if ($att = $DB->get_records('quiz_attempts', array('quiz' => $li->quiz, 'preview' => '0'))) {
$this->nb_of_attempts += count($att);
$this->used_in_quiz = true;
}
}
}
}
parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable);
}
示例2: array
function question_edit_calculatedmulti_form(&$submiturl, &$question, &$category, &$contexts, $formeditable = true)
{
global $QTYPES, $SESSION, $CFG, $DB;
$this->question = $question;
$this->qtypeobj =& $QTYPES[$this->question->qtype];
if ("1" == optional_param('reload', '', PARAM_INT)) {
$this->reload = true;
} else {
$this->reload = false;
}
if (!$this->reload) {
// use database data as this is first pass
if (isset($this->question->id)) {
// remove prefix #{..}# if exists
$this->initialname = $question->name;
$regs = array();
if (preg_match('~#\\{([^[:space:]]*)#~', $question->name, $regs)) {
$question->name = str_replace($regs[0], '', $question->name);
}
}
} else {
}
parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable);
}
示例3: array
//.........这里部分代码省略.........
$newdatasetvalues = false;
for ($key = 1; $key <= sizeof($olddef); $key++) {
$def = $olddef[$key];
$this->datasetdefs[$def] = new stdClass();
$this->datasetdefs[$def]->type = 1;
$this->datasetdefs[$def]->category = 0;
// $this->datasets[$key]->name = $datasetname;
$this->datasetdefs[$def]->options = $oldoptions[$key];
$this->datasetdefs[$def]->calcmin = $calcmin[$key];
$this->datasetdefs[$def]->calcmax = $calcmax[$key];
$this->datasetdefs[$def]->calclength = $calclength[$key];
//then compare with new values
if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~', $this->datasetdefs[$def]->options, $regs)) {
if ($this->datasetdefs[$def]->calcmin != $regs[2] || $this->datasetdefs[$def]->calcmax != $regs[3] || $this->datasetdefs[$def]->calclength != $regs[4]) {
$newdatasetvalues = true;
}
}
$this->datasetdefs[$def]->options = "uniform:" . $this->datasetdefs[$def]->calcmin . ":" . $this->datasetdefs[$def]->calcmax . ":" . $this->datasetdefs[$def]->calclength;
}
// detect new datasets
$newdataset = false;
foreach ($mandatorydatasets as $datasetname) {
if (!isset($this->datasetdefs["1-0-{$datasetname}"])) {
$key = "1-0-{$datasetname}";
$this->datasetdefs[$key] = new stdClass();
//"1-0-$datasetname";
$this->datasetdefs[$key]->type = 1;
$this->datasetdefs[$key]->category = 0;
$this->datasetdefs[$key]->name = $datasetname;
$this->datasetdefs[$key]->options = "uniform:1.0:10.0:1";
$newdataset = true;
} else {
$this->datasetdefs["1-0-{$datasetname}"]->name = $datasetname;
}
}
// remove obsolete datasets
$datasettoremove = false;
foreach ($this->datasetdefs as $defkey => $datasetdef) {
if (!isset($datasetdef->name)) {
$datasettoremove = true;
unset($this->datasetdefs[$defkey]);
}
}
}
// handle reload
// create items if $newdataset and noofitems > 0 and !$newdatasetvalues
// eliminate any items if $newdatasetvalues
// eliminate any items if $datasettoremove, $newdataset, $newdatasetvalues
if ($datasettoremove || $newdataset || $newdatasetvalues) {
foreach ($this->datasetdefs as $defkey => $datasetdef) {
$datasetdef->itemcount = 0;
unset($datasetdef->items);
}
}
$maxnumber = -1;
if ("" != optional_param('addbutton')) {
$maxnumber = optional_param('selectadd');
foreach ($this->datasetdefs as $defid => $datasetdef) {
$datasetdef->itemcount = $maxnumber;
unset($datasetdef->items);
for ($numberadded = 1; $numberadded <= $maxnumber; $numberadded++) {
$datasetitem = new stdClass();
$datasetitem->itemnumber = $numberadded;
$datasetitem->id = 0;
$datasetitem->value = $this->qtypeobj->generate_dataset_item($datasetdef->options);
$this->datasetdefs[$defid]->items[$numberadded] = $datasetitem;
}
//for number added
}
// datasetsdefs end
$this->maxnumber = $maxnumber;
} else {
// Handle reload dataset items
if ("" != optional_param('definition') && !($datasettoremove || $newdataset || $newdatasetvalues)) {
$i = 1;
$fromformdefinition = optional_param('definition');
$fromformnumber = optional_param('number');
$fromformitemid = optional_param('itemid');
ksort($fromformdefinition);
foreach ($fromformdefinition as $key => $defid) {
$addeditem = new stdClass();
$addeditem->id = $fromformitemid[$i];
$addeditem->value = $fromformnumber[$i];
$addeditem->itemnumber = ceil($i / count($this->datasetdefs));
$this->datasetdefs[$defid]->items[$addeditem->itemnumber] = $addeditem;
$this->datasetdefs[$defid]->itemcount = $i;
$i++;
}
}
if (isset($addeditem->itemnumber) && $this->maxnumber < $addeditem->itemnumber) {
$this->maxnumber = $addeditem->itemnumber;
if (!empty($this->datasetdefs)) {
foreach ($this->datasetdefs as $datasetdef) {
$datasetdef->itemcount = $this->maxnumber;
}
}
}
}
parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable);
}