You are here

protected function OpignoAssessmentTestCase::_addQuiz in Opigno 7.0

Create a quiz and add questions directly.

Parameters

array $questions = array(): An array of questions with type and specific fields.

integer $ponderation = 1: The ponderation of this quiz in the assessment.

1 call to OpignoAssessmentTestCase::_addQuiz()
OpignoAssessmentTestCase::testAssessmentSingleQuiz in modules/opigno_assessment/tests/opigno_assessment.test
Test taking a single quiz. Assessment should work for both "all" and "single" quiz options in the OG node.

File

modules/opigno_assessment/tests/opigno_assessment.test, line 149
Defines a Unit test for quiz assessments and module settings.

Class

OpignoAssessmentTestCase
@file Defines a Unit test for quiz assessments and module settings.

Code

protected function _addQuiz($questions = array(), $ponderation = 1) {
  $nid = $this
    ->addOGContent('quiz', $this->og_gid, $this->privileged_user, array(
    'opigno_assessment[ponderation]' => $ponderation,
  ));
  foreach ($questions as $question) {
    $this
      ->drupalGet("node/add/{$question['type']}?quiz_nid={$nid}&quiz_vid={$nid}");
    $edit = array(
      'body[und][0][value]' => $this
        ->randomString(16),
      'title',
    );
    $edit = !empty($question['edit']) ? $question['edit'] + $edit : $edit;
    $this
      ->drupalPost($this
      ->getURL(), $edit, 'Save');
  }
  return $nid;
}