You are here

public function MatchingUnitTest::createMatchingQuestion in Quiz 7

Same name and namespace in other branches
  1. 6.6 question_types/matching/matching.test \MatchingUnitTest::createMatchingQuestion()
  2. 6.4 question_types/matching/matching.test \MatchingUnitTest::createMatchingQuestion()
  3. 7.4 question_types/matching/matching.test \MatchingUnitTest::createMatchingQuestion()
1 call to MatchingUnitTest::createMatchingQuestion()
MatchingUnitTest::unitTestCreateMatchingQuestionNode in question_types/matching/matching.test

File

question_types/matching/matching.test, line 92
Unit tests for the matching Module.

Class

MatchingUnitTest
@file Unit tests for the matching Module.

Code

public function createMatchingQuestion() {

  // matching question node attributes
  $this->title = $this
    ->randomName(mt_rand($this->min, $this->max));
  $this->body = $this
    ->randomName($this
    ->getRandSize());

  // array of node attributes to create a test node
  $settings = array(
    'type' => $this->question_node_type,
    'title' => $this->title,
    'body' => $this->body,
    'revisions' => TRUE,
  );
  $this->match = array();
  $form_size = variable_get('quiz_matching_form_size', 5);

  // generate rand match question, answer and feedback
  for ($i = 1; $i < $form_size; $i++) {
    $settings['match'][$i]['question'] = $this->match[$i]['question'] = $this
      ->randomName($this
      ->getRandSize());
    $setting['match'][$i]['answer'] = $this->match[$i]['answer'] = $this
      ->randomName($this
      ->getRandSize());
    $settings['match'][$i]['feedback'] = $this->match[$i]['feedback'] = $this
      ->randomName($this
      ->getRandSize());
  }

  // create drupal node
  return $this
    ->drupalCreateNode($settings);
}