Questionnaire: missing date exporting to CSV

Questionnaire: missing date exporting to CSV

door Alfonso Marrodán -
Aantal antwoorden: 4
Moodle 1.8.2+ and Questionnaire v2007010801.

When exporting the questionnaire, into the CSV file, not appear the answers of "Date" questions. The rest of the data are present in CSV file.

Also, this date fields are displayed correctly in "View by Response" and "View all Responses".

No errors in httpd's log.

Exporting the questionnaire with responses to other Moodle (1.6.4+) with the same Questionnaire's version (v2007010801), dates are exported correctly to CSV.

Any idea?
Gemiddelde van de beoordelingen:  -
Als antwoord op Alfonso Marrodán

Re: Questionnaire: missing date exporting to CSV

door Carlos Chiarella -
Hello,

I had the same problem and this is what I did.
Go to your locallib.php file. Find the line that says:
// --------------------- response_date ---------------------

A few lines below there is a foreach loop:
foreach ($row as $key => $val) {
if (!is_numeric($key)) {
// convert date from yyyy-mm-dd database format to actual QUESTIONNAIREDATEFORMAT
if (preg_match('/\d\d\d\d-\d\d-\d\d/', $val)) {
$dateparts = split('-', $val);
$val = mktime(0, 0, 0, $dateparts[1], $dateparts[2], $dateparts[0]); // Unix timestamp
$val = userdate ( $val, QUESTIONNAIREDATEFORMAT);
$newrow[] = $val; // JR JR 1945-03-14
}
}
}

Change this code for:
foreach ($row as $key => $val) {
if (!is_numeric($key)) {
// convert date from yyyy-mm-dd database format to actual QUESTIONNAIREDATEFORMAT
if (preg_match('/\d\d\d\d-\d\d-\d\d/', $val)) {
$dateparts = split('-', $val);
$val = mktime(0, 0, 0, $dateparts[1], $dateparts[2], $dateparts[0]); // Unix timestamp
$val = userdate ( $val, QUESTIONNAIREDATEFORMAT);
$newrow[] = $val; // JR JR 1945-03-14
} else {
$newrow[] = $val;
}
}
}

I only added an else, as you can see. I hope this helps.

Carlos

Gemiddelde van de beoordelingen:  -
Als antwoord op Carlos Chiarella

Re: Questionnaire: missing date exporting to CSV

door Joseph Rézeau -
Foto van Core developers Foto van Particularly helpful Moodlers Foto van Plugin developers Foto van Testers Foto van Translators
Hi Carlos,
Please note that this bug has been corrected in latest version of Questionnaire module. I still need a little time to merge all recent fixes and improvements into 1.7 and 1.8 versions, but note that latest version will work with moodle 1.7 and 1.8.
Joseph
Gemiddelde van de beoordelingen:  -