public function OpignoAssessmentTestCase::testAssessmentSingleQuiz in Opigno 7.0
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 71 - Defines a Unit test for quiz assessments and module settings.
Class
- OpignoAssessmentTestCase
- @file Defines a Unit test for quiz assessments and module settings.
Code
public function testAssessmentSingleQuiz() {
$this
->assertTrue(0);
return;
// Assess all quizzes
$this
->_setOGAssessment('all');
// Add a quizz with 2 questions
$nid = $this
->_addQuiz(array(
array(
'type' => 'matching',
'match[1][question]' => 'A',
'match[1][answer]' => 'A',
'match[2][question]' => 'B',
'match[2][answer]' => 'B',
),
array(
'type' => 'matching',
'match[1][question]' => 'A',
'match[1][answer]' => 'A',
'match[2][question]' => 'B',
'match[2][answer]' => 'B',
),
));
// Take quiz, 100% correct
$this
->_takeQuiz($nid, array(
array(
'tries[1]' => 'A',
'tries[2]' => 'B',
),
array(
'tries[1]' => 'A',
'tries[2]' => 'B',
),
));
$this
->assertText('You have successfully completed the course. Your grade is 10/10', 'Assessment was successfull. Passed with 10/10 grade.');
// Take quiz, 50% correct
$this
->_takeQuiz($nid, array(
array(
'tries[1]' => 'A',
'tries[2]' => 'B',
),
array(
'tries[1]' => 'B',
'tries[2]' => 'A',
),
));
$this
->assertText('You have successfully completed the course. Your grade is 5/10', 'Assessment was successfull. Passed with 5/10 grade.');
// Assess all quizzes, but must have 7/10 minumum to pass
$this
->_setOGAssessment('all', array(), 'average', 7);
// Take quiz, 50% correct
$this
->_takeQuiz($nid, array(
array(
'tries[1]' => 'A',
'tries[2]' => 'B',
),
array(
'tries[1]' => 'B',
'tries[2]' => 'A',
),
));
$this
->assertText('You completed the course. However, your average grade is lower than the minimum allowed. Minimum to pass is 7, your grade is 5', 'Assessment was successfull. Failed with 5/10 grade.');
}