本文整理汇总了PHP中question_type::save_question方法的典型用法代码示例。如果您正苦于以下问题:PHP question_type::save_question方法的具体用法?PHP question_type::save_question怎么用?PHP question_type::save_question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_type
的用法示例。
在下文中一共展示了question_type::save_question方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_question
public function save_question($question, $fromform)
{
if (!empty($fromform->fixdollars)) {
$this->fix_dollars_in_form_data($fromform);
}
return parent::save_question($question, $fromform);
}
示例2: save_question
public function save_question($question, $form)
{
// Make very sure that descriptions can'e be created with a grade of
// anything other than 0.
$form->defaultmark = 0;
return parent::save_question($question, $form);
}
示例3: save_question
/**
* this version save the available data at the different steps of the question editing process
* without using global $SESSION as storage between steps
* at the first step $wizardnow = 'question'
* when creating a new question
* when modifying a question
* when copying as a new question
* the general parameters and answers are saved using parent::save_question
* then the datasets are prepared and saved
* at the second step $wizardnow = 'datasetdefinitions'
* the datadefs final type are defined as private, category or not a datadef
* at the third step $wizardnow = 'datasetitems'
* the datadefs parameters and the data items are created or defined
*
* @param object question
* @param object $form
* @param int $course
* @param PARAM_ALPHA $wizardnow should be added as we are coming from question2.php
*/
public function save_question($question, $form)
{
global $DB;
if ($this->wizardpagesnumber() == 1 || $question->qtype == 'calculatedsimple') {
$question = parent::save_question($question, $form);
return $question;
}
$wizardnow = optional_param('wizardnow', '', PARAM_ALPHA);
$id = optional_param('id', 0, PARAM_INT);
// Question id.
// In case 'question':
// For a new question $form->id is empty
// when saving as new question.
// The $question->id = 0, $form is $data from question2.php
// and $data->makecopy is defined as $data->id is the initial question id.
// Edit case. If it is a new question we don't necessarily need to
// return a valid question object.
// See where we're coming from.
switch ($wizardnow) {
case '':
case 'question':
// Coming from the first page, creating the second.
if (empty($form->id)) {
// or a new question $form->id is empty.
$question = parent::save_question($question, $form);
// Prepare the datasets using default $questionfromid.
$this->preparedatasets($form);
$form->id = $question->id;
$this->save_dataset_definitions($form);
if (isset($form->synchronize) && $form->synchronize == 2) {
$this->addnamecategory($question);
}
} else {
if (!empty($form->makecopy)) {
$questionfromid = $form->id;
$question = parent::save_question($question, $form);
// Prepare the datasets.
$this->preparedatasets($form, $questionfromid);
$form->id = $question->id;
$this->save_as_new_dataset_definitions($form, $questionfromid);
if (isset($form->synchronize) && $form->synchronize == 2) {
$this->addnamecategory($question);
}
} else {
// Editing a question.
$question = parent::save_question($question, $form);
// Prepare the datasets.
$this->preparedatasets($form, $question->id);
$form->id = $question->id;
$this->save_dataset_definitions($form);
if (isset($form->synchronize) && $form->synchronize == 2) {
$this->addnamecategory($question);
}
}
}
break;
case 'datasetdefinitions':
// Calculated options.
// It cannot go here without having done the first page,
// so the question_calculated_options should exist.
// We only need to update the synchronize field.
if (isset($form->synchronize)) {
$optionssynchronize = $form->synchronize;
} else {
$optionssynchronize = 0;
}
$DB->set_field('question_calculated_options', 'synchronize', $optionssynchronize, array('question' => $question->id));
if (isset($form->synchronize) && $form->synchronize == 2) {
$this->addnamecategory($question);
}
$this->save_dataset_definitions($form);
break;
case 'datasetitems':
$this->save_dataset_items($question, $form);
$this->save_question_calculated($question, $form);
break;
default:
print_error('invalidwizardpage', 'question');
break;
}
return $question;
//.........这里部分代码省略.........
示例4: save_question
public function save_question($question, $form) {
$form->name = '';
// Name is not a required field for random questions, but
// parent::save_question Assumes that it is.
return parent::save_question($question, $form);
}
示例5: save_question
public function save_question($authorizedquestion, $form)
{
$question = qtype_multianswer_extract_question($form->questiontext);
if (isset($authorizedquestion->id)) {
$question->id = $authorizedquestion->id;
}
$question->category = $authorizedquestion->category;
$form->defaultmark = $question->defaultmark;
$form->questiontext = $question->questiontext;
$form->questiontextformat = 0;
$form->options = clone $question->options;
unset($question->options);
return parent::save_question($question, $form);
}
示例6: save_question
/**
*
* @param type $question The current question
* @param type $form The question editing form data
* @return type object
* Sets the default mark as 1* the number of gaps
* Does not allow setting any other value per space/field at the moment
*/
public function save_question($question, $form)
{
$gaps = $this->get_gaps($question, $form->delimitchars, $form->questiontext['text']);
/* count the number of gaps
* this is used to set the maximum
* value for the whole question. Value for
* each gap can be only 0 or 1
*/
$form->defaultmark = count($gaps);
return parent::save_question($question, $form);
}
示例7: save_question
public function save_question($question, $form)
{
$form->name = '';
// In case someone set the question text to true/false in the old style, set it properly.
if ($form->questiontext['text']) {
$form->questiontext['text'] = '1';
} else {
$form->questiontext['text'] = '0';
}
$form->tags = array();
// Name is not a required field for random questions, but
// parent::save_question Assumes that it is.
return parent::save_question($question, $form);
}
示例8: save_question
public function save_question($question, $form)
{
$form->name = '';
$form->questiontextformat = FORMAT_MOODLE;
$form->tags = array();
// Name is not a required field for random questions, but
// parent::save_question Assumes that it is.
return parent::save_question($question, $form);
}
示例9: save_question
public function save_question($question, $form)
{
$form->isnew = empty($question->id);
return parent::save_question($question, $form);
}