Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

Quiz attempt walk through using data from csv file.

Author: Jamie Pratt <me@jamiep.org>
Copyright: 2013 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 368 lines (16 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: mod_quiz_attempt_walkthrough_from_csv_testcase  - X-Ref

Quiz attempt walk through using data from csv file.

test_walkthrough_from_csv($quizsettings, $csvdata)   X-Ref
The only test in this class. This is run multiple times depending on how many sets of files there are in fixtures/
directory.

param: array $quizsettings of settings read from csv file quizzes.csv
param: array $csvdata of data read from csv file "questionsXX.csv", "stepsXX.csv" and "resultsXX.csv".

create_quiz($quizsettings, $qs)   X-Ref
No description

create_quiz_simulate_attempts_and_check_results($quizsettings, $csvdata)   X-Ref
Create quiz, simulate attempts and check results (if resultsXX.csv exists).

param: array $quizsettings Quiz overrides for this quiz.
param: array $csvdata Data loaded from csv files for this test.

get_full_path_of_csv_file($setname, $test)   X-Ref
Get full path of CSV file.

param: string $setname
param: string $test
return: string full path of file.

load_csv_data_file($setname, $test='')   X-Ref
Load dataset from CSV file "{$setname}{$test}.csv".

param: string $setname
param: string $test
return: array

explode_dot_separated_keys_to_make_subindexs(array $row)   X-Ref
Break down row of csv data into sub arrays, according to column names.

param: array $row from csv file with field names with parts separate by '.'.
return: array the row with each part of the field name following a '.' being a separate sub array's index.

get_data_for_walkthrough()   X-Ref
Data provider method for test_walkthrough_from_csv. Called by PHPUnit.

return: array One array element for each run of the test. Each element contains an array with the params for

walkthrough_attempts($steps)   X-Ref

param: $steps array the step data from the csv file.
return: array attempt no as in csv file => the id of the quiz_attempt as stored in the db.

check_attempts_results($results, $attemptids)   X-Ref

param: $results array the results data from the csv file.
param: $attemptids array attempt no as in csv file => the id of the quiz_attempt as stored in the db.

check_attempt_results($result, $attemptobj)   X-Ref
Check that attempt results are as specified in $result.

param: array        $result             row of data read from csv file.
param: quiz_attempt $attemptobj         the attempt object loaded from db.