本文整理汇总了PHP中question_type::initialise_question_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP question_type::initialise_question_instance方法的具体用法?PHP question_type::initialise_question_instance怎么用?PHP question_type::initialise_question_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_type
的用法示例。
在下文中一共展示了question_type::initialise_question_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$this->initialise_question_answers($question, $questiondata);
$this->initialise_combined_feedback($question, $questiondata);
$question->places = array();
$counter = 1;
foreach ($questiondata->options->answers as $choicedata) {
/* fraction contains a 1 */
if (strpos($choicedata->fraction, '1') !== false) {
$question->places[$counter] = $choicedata->answer;
$counter++;
}
}
/* Will put empty places '' where there is no text content.
* l for left delimiter r for right delimiter
*/
$l = substr($question->delimitchars, 0, 1);
$r = substr($question->delimitchars, 1, 1);
$nonfieldregex = '/\\' . $l . '.*?\\' . $r . '/';
$bits = preg_split($nonfieldregex, $question->questiontext, null, PREG_SPLIT_DELIM_CAPTURE);
$question->textfragments[0] = array_shift($bits);
$i = 1;
while (!empty($bits)) {
$question->textfragments[$i] = array_shift($bits);
$i += 1;
}
}
示例2: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->shufflechoices = $questiondata->options->shuffleanswers;
$this->initialise_combined_feedback($question, $questiondata, true);
$question->choices = array();
$choiceindexmap = array();
// Store the choices in arrays by group.
foreach ($questiondata->options->drags as $dragdata) {
$choice = $this->make_choice($dragdata);
if (array_key_exists($choice->choice_group(), $question->choices)) {
$question->choices[$choice->choice_group()][$dragdata->no] = $choice;
} else {
$question->choices[$choice->choice_group()][1] = $choice;
}
end($question->choices[$choice->choice_group()]);
$choiceindexmap[$dragdata->no] = array($choice->choice_group(), key($question->choices[$choice->choice_group()]));
}
$question->places = array();
$question->rightchoices = array();
$i = 1;
foreach ($questiondata->options->drops as $dropdata) {
list($group, $choiceindex) = $choiceindexmap[$dropdata->choice];
$dropdata->group = $group;
$question->places[$dropdata->no] = $this->make_place($dropdata);
$question->rightchoices[$dropdata->no] = $choiceindex;
}
}
示例3: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->responseformat = $questiondata->options->responseformat;
$question->graderinfo = $questiondata->options->graderinfo;
$question->graderinfoformat = $questiondata->options->graderinfoformat;
}
示例4: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata) {
parent::initialise_question_instance($question, $questiondata);
$question->responseformat = $questiondata->options->responseformat;
$question->responsefieldlines = $questiondata->options->responsefieldlines;
$question->attachments = $questiondata->options->attachments;
$question->graderinfo = $questiondata->options->graderinfo;
$question->graderinfoformat = $questiondata->options->graderinfoformat;
$question->responselimitpolicy = $questiondata->options->responselimitpolicy;
$question->wordlimit = $questiondata->options->wordlimit;
$question->charlimit = $questiondata->options->charlimit;
}
示例5: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->responseformat = $questiondata->options->responseformat;
$question->responsefieldlines = $questiondata->options->responsefieldlines;
$question->attachments = $questiondata->options->attachments;
$question->graderinfo = $questiondata->options->graderinfo;
$question->graderinfoformat = $questiondata->options->graderinfoformat;
$question->responsetemplate = $questiondata->options->responsetemplate;
$question->responsetemplateformat = $questiondata->options->responsetemplateformat;
}
示例6: initialise_question_instance
/**
* Initialise the common question_definition fields.
*
* @param question_definition $question the question_definition we are creating.
* @param object $questiondata the question data loaded from the database.
*/
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->rows = $questiondata->options->rows;
$question->cols = $questiondata->options->cols;
$question->weights = $questiondata->options->weights;
$question->grademethod = $questiondata->options->grademethod;
$question->multiple = $questiondata->options->multiple;
}
示例7: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$availablesaquestions = $this->get_available_saquestions_from_category($question->category, $questiondata->options->subcats);
$question->shufflestems = false;
$question->stems = array();
$question->choices = array();
$question->right = array();
$this->initialise_combined_feedback($question, $questiondata);
$question->questionsloader = new qtype_randomsamatch_question_loader($availablesaquestions, $questiondata->options->choose);
}
示例8: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata) {
parent::initialise_question_instance($question, $questiondata);
$question->shufflestems = $questiondata->options->shuffleanswers;
$this->initialise_combined_feedback($question, $questiondata, true);
$question->stems = array();
$question->choices = array();
$question->right = array();
foreach ($questiondata->options->subquestions as $matchsub) {
$ans = $matchsub->answertext;
$key = array_search($matchsub->answertext, $question->choices);
if ($key === false) {
$key = $matchsub->id;
$question->choices[$key] = $matchsub->answertext;
}
if ($matchsub->questiontext !== '') {
$question->stems[$matchsub->id] = $matchsub->questiontext;
$question->stemformat[$matchsub->id] = $matchsub->questiontextformat;
$question->right[$matchsub->id] = $key;
}
}
}
示例9: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata) {
question_type::initialise_question_instance($question, $questiondata);
$question->shuffleanswers = $questiondata->options->shuffleanswers;
$question->answernumbering = $questiondata->options->answernumbering;
if (!empty($questiondata->options->layout)) {
$question->layout = $questiondata->options->layout;
} else {
$question->layout = qtype_multichoice_single_question::LAYOUT_VERTICAL;
}
$question->synchronised = $questiondata->options->synchronize;
$this->initialise_combined_feedback($question, $questiondata, true);
$this->initialise_question_answers($question, $questiondata);
foreach ($questiondata->options->answers as $a) {
$question->answers[$a->id]->correctanswerlength = $a->correctanswerlength;
$question->answers[$a->id]->correctanswerformat = $a->correctanswerformat;
}
$question->datasetloader = new qtype_calculated_dataset_loader($questiondata->id);
}
示例10: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->shuffleanswers = $questiondata->options->shuffleanswers;
$question->answernumbering = $questiondata->options->answernumbering;
if (!empty($questiondata->options->layout)) {
$question->layout = $questiondata->options->layout;
} else {
$question->layout = qtype_multichoice_single_question::LAYOUT_VERTICAL;
}
$question->correctfeedback = $questiondata->options->correctfeedback;
$question->correctfeedbackformat = $questiondata->options->correctfeedbackformat;
$question->incorrectfeedback = $questiondata->options->incorrectfeedback;
$question->incorrectfeedbackformat = $questiondata->options->incorrectfeedbackformat;
$question->shownumcorrect = $questiondata->options->shownumcorrect;
$this->initialise_question_answers($question, $questiondata, false);
}
示例11: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
// TODO.
parent::initialise_question_instance($question, $questiondata);
}
示例12: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->usecase = $questiondata->options->usecase;
$question->usehint = $questiondata->options->usehint;
$question->studentshowalternate = $questiondata->options->studentshowalternate;
$this->initialise_question_answers($question, $questiondata);
$qid = $question->id;
}
示例13: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
global $DB;
$answers = $questiondata->options->answers;
$question->generalfeedback = $answers[$questiondata->options->answer]->feedback;
$question->generalfeedbackformat = $answers[$questiondata->options->answer]->feedbackformat;
$question->answerid = $questiondata->options->answer;
//$question->rightanswer = 10;
$getanswers = $DB->get_records('question_answers', array('question' => $question->id), 'id ASC');
$answerval = array_shift($getanswers);
if ($answerval) {
$question->rightanswer = $answerval->answer;
}
$getanswers = $DB->get_records('question_classdiagram', array('question' => $question->id), 'id ASC');
$answerval = array_shift($getanswers);
if ($answerval) {
$question->class_marks = $answerval->class_marks;
$question->class_name_marks = $answerval->class_name_marks;
$question->class_attribute_marks = $answerval->class_attribute_marks;
$question->class_extra_marks = $answerval->class_extra_marks;
$question->association_marks = $answerval->association_marks;
$question->association_type_marks = $answerval->association_type_marks;
$question->association_cardinality_marks = $answerval->association_cardinality_marks;
$question->association_extra_marks = $answerval->association_extra_marks;
$question->generalization_marks = $answerval->generalization_marks;
$question->generalization_type_marks = $answerval->generalization_type_marks;
$question->generalization_extra_marks = $answerval->generalization_extra_marks;
}
}
示例14: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
$question->shuffleanswers = $questiondata->options->shuffleanswers;
$question->qdifficulty = $questiondata->options->qdifficulty;
if (!empty($questiondata->options->layout)) {
$question->layout = $questiondata->options->layout;
} else {
$question->layout = qtype_turmultiplechoice_single_question::LAYOUT_VERTICAL;
}
$this->initialise_combined_feedback($question, $questiondata, true);
$this->initialise_question_answers($question, $questiondata, false);
}
示例15: initialise_question_instance
protected function initialise_question_instance(question_definition $question, $questiondata)
{
parent::initialise_question_instance($question, $questiondata);
foreach ($questiondata->options as $field => $value) {
if (!isset($question->{$field})) {
$question->{$field} = $value;
}
}
}