estou fazendo uma customização na importação de questionário do moodle versão 2.6.1.
Estou fazendo a alteração no Formato Aiken, hoje ele funciona assim:
pergunta.
A) resposta
B) resposta
C) resposta
D) resposta
ANSWER: A
Quero que ele importe também o feedback geral, desta forma:
pergunta.
A) resposta
B) resposta
C) resposta
D) resposta
ANSWER: A
FEEDBACKGERAL: aqui o feedback geral da questão
Para isso estou fuçando no código, abaixo o código e em negrito como configurei ele, se alguém puder me dar uma luz agradeceria.
<?php
defined('MOODLE_INTERNAL') || die();
*/
class qformat_aiken extends qformat_default {
public function provide_import() {
return true;
}
public function readquestions($lines) {
$questions = array();
$question = $this->defaultquestion();
$endchar = chr(13);
foreach ($lines as $line) {
$stp = strpos($line, $endchar, 0);
$newlines = explode($endchar, $line);
$linescount = count($newlines);
for ($i=0; $i < $linescount; $i++) {
$nowline = trim($newlines[$i]);
// Go through the array and build an object called $question
// When done, add $question to $questions.
if (strlen($nowline) < 2) {
continue;
}
if (preg_match('/^[A-Z][).][ \t]/', $nowline)) {
// A choice. Trim off the label and space, then save.
$question->answer[] = $this->text_field(
htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES));
$question->fraction[] = 0;
$question->feedback[] = $this->text_field('');
} else if (preg_match('/^ANSWER:/', $nowline)) {
// The line that indicates the correct answer. This question is finised.
$ans = trim(substr($nowline, strpos($nowline, ':') + 1));
$ans = substr($ans, 0, 1);
// We want to map A to 0, B to 1, etc.
$rightans = ord($ans) - ord('A');
$question->fraction[$rightans] = 1;
$questions[] = $question;
//feedback geral
} else if (preg_match('/^FEEDBACKGERAL:/', $nowline)) {
$feed= trim(substr($nowline, strpos($nowline, ':') + 1));
$feed= substr($feed, 0, 1);
$question->feedback[0] = $feed;
$questions[] = $question;
// Clear array for next question set.
$question = $this->defaultquestion();
continue;
} else {
// Must be the first line of a new question, since no recognised prefix.
$question->qtype = 'multichoice';
$question->name = $this->create_default_question_name($nowline, get_string('questionname', 'question'));
$question->questiontext = htmlspecialchars(trim($nowline), ENT_NOQUOTES);
$question->questiontextformat = FORMAT_HTML;
$question->generalfeedback = array();
$question->generalfeedbackformat = FORMAT_HTML;
$question->single = 1;
$question->answer = array();
$question->fraction = array();
$question->feedback = array();
$question->correctfeedback = $this->text_field('');
$question->partiallycorrectfeedback = $this->text_field('');
$question->incorrectfeedback = $this->text_field('');
}
}
}
return $questions;
}
protected function text_field($text) {
return array(
'text' => htmlspecialchars(trim($text), ENT_NOQUOTES),
'format' => FORMAT_HTML,
'files' => array(),
);
}
public function readquestion($lines) {
// This is no longer needed but might still be called by default.php.
return;
}
}