function qformat_default::readquestions in Quiz 6.5
Same name and namespace in other branches
- 6.6 includes/moodle/question/format.php \qformat_default::readquestions()
Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
If your format does not use blank lines as a delimiter then you will need to override this method. Even then try to use readquestion for each question
Parameters
array lines array of lines from readdata:
Return value
array array of question objects
1 call to qformat_default::readquestions()
- qformat_default::importprocess in includes/
moodle/ question/ format.php - Process the file This method should not normally be overidden
9 methods override qformat_default::readquestions()
- qformat_aiken::readquestions in includes/
moodle/ question/ format/ aiken/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
- qformat_blackboard::readquestions in includes/
moodle/ question/ format/ blackboard/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
- qformat_blackboard_6::readquestions in includes/
moodle/ question/ format/ blackboard_6/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
- qformat_examview::readquestions in includes/
moodle/ question/ format/ examview/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
- qformat_hotpot::readquestions in includes/
moodle/ question/ format/ hotpot/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
File
- includes/
moodle/ question/ format.php, line 451
Class
- qformat_default
- Base class for question import and export formats.
Code
function readquestions($lines) {
$questions = array();
$currentquestion = array();
foreach ($lines as $line) {
$line = trim($line);
if (empty($line)) {
if (!empty($currentquestion)) {
if ($question = $this
->readquestion($currentquestion)) {
$questions[] = $question;
}
$currentquestion = array();
}
}
else {
$currentquestion[] = $line;
}
}
if (!empty($currentquestion)) {
// There may be a final question
if ($question = $this
->readquestion($currentquestion)) {
$questions[] = $question;
}
}
return $questions;
}