You are here

protected function OpignoAssessmentTestCase::_setOGAssessment in Opigno 7.0

Set the assessment options on the OG node.

Parameters

string $type = 'all': Set the type of assessment. Either 'all', 'some' or 'no'

array $quizzes = array(): An array of quiz nids for assessment. Only used if $type = 'some'

string $rule = 'average': The assessment rule. Either 'average' or 'average_neg'

integer $average = 5: The average grade required to pass

integet $min = NULL: The minimum grade required to pass. Only used if $rule = 'average_neg'

1 call to OpignoAssessmentTestCase::_setOGAssessment()
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 209
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 _setOGAssessment($type = 'all', $quizzes = array(), $rule = 'average', $average = 5, $min = NULL) {

  // Go to node edit form
  $this
    ->drupalGet("node/{$this->og_nid}/edit");

  // Prepare fields
  $edit = array(
    'opigno_assessment[option]' => $type,
  );
  if ($type == 'all' || $type == 'some') {
    $edit['opigno_assessment[rule]'] = $rule;
    $edit['opigno_assessment[average]'] = $average;

    // Only some quizzes ?
    if ($type == 'some') {
      $edit['opigno_assessment[quizzes][]'] = $quizzes;
    }

    // Minimum grade required ?
    if ($rule == 'average_neg') {
      $edit['opigno_assessment[min]'] = $min;
    }
  }

  // Submit
  $this
    ->drupalPost($this
    ->getURL(), $edit, 'Save');
}