public function ShortAnswerUnitTest::createShortAnswerQuestion in Quiz 7
Same name and namespace in other branches
- 6.6 question_types/short_answer/short_answer.test \ShortAnswerUnitTest::createShortAnswerQuestion()
- 6.4 question_types/short_answer/short_answer.test \ShortAnswerUnitTest::createShortAnswerQuestion()
- 7.4 question_types/short_answer/short_answer.test \ShortAnswerUnitTest::createShortAnswerQuestion()
1 call to ShortAnswerUnitTest::createShortAnswerQuestion()
- ShortAnswerUnitTest::unitTestShortAnswerCreateQuestionNode in question_types/
short_answer/ short_answer.test
File
- question_types/
short_answer/ short_answer.test, line 90
Class
Code
public function createShortAnswerQuestion() {
// score range
$score_min = 1;
$score_max = 16;
// evaluation type
$evaluation = array(
0 => 'exact_match',
1 => 'case_insensitive_match',
2 => 'regular_expression',
3 => 'manual_score',
);
// short answer question node attributes
$this->title = $this
->randomName($this
->getRandSize());
$this->body = $this
->randomName($this
->getRandSize());
$this->correct_answer = $this
->randomName($this
->getRandSize());
$this->maximum_score = rand($score_min, $score_max);
$this->correct_answer_evaluation = array_rand($evaluation);
// array of node attributes to create a test node
$settings = array(
'type' => $this->question_node_type,
'title' => $this->title,
'body' => $this->body,
'correct_answer' => $this->correct_answer,
'maximum_score' => $this->maximum_score,
'correct_answer_evaluation' => $this->correct_answer_evaluation,
'revisions' => TRUE,
);
return $this
->drupalCreateNode($settings);
}