$redirection = $CFG->wwwroot . '/mod/questionnaire/report.php?action=vall&sid=' . $sid . '&instance=' . $instance; } redirect($redirection, $deletedstr, -1); } else { error(get_string('couldnotdelresp', 'questionnaire'), $CFG->wwwroot . '/mod/questionnaire/report.php?action=vall&sid=' . $sid . '&instance=' . $instance); } break; case 'dcsv': // download as text (cvs) format //if (!($name = get_field('questionnaire_survey', 'name', 'id', $sid))) { if (!($name = get_field('questionnaire_survey', 'title', 'id', $sid))) { error(get_string('invalidsurveyid', 'questionnaire')); } if ($groupmode == 1 && $groupscount === 0 && !$user) { } else { $output = $questionnaire->generate_csv($rid = '', $user); // CSV // SEP. 2007 JR changed file extension to *.txt for non-English Excel users' sake // and changed separator to tabulation // JAN. 2008 added \r carriage return for better Windows implementation header("Content-Disposition: attachment; filename=\"{$name}.csv\""); header("Content-Type: text/comma-separated-values"); foreach ($output as $row) { $text = implode("\t", $row); echo $text . "\r\n"; } exit; break; } case 'vall': // view all responses
echo "<br />\n"; echo "<input type=\"submit\" name=\"submit\" value=\"" . get_string('download', 'questionnaire') . "\" />\n"; echo "</form>\n"; echo $OUTPUT->box_end(); echo $OUTPUT->footer('none'); exit; break; case 'dcsv': // Download responses data as text (cvs) format. require_capability('mod/questionnaire:downloadresponses', $context); // Use the questionnaire name as the file name. Clean it and change any non-filename characters to '_'. $name = clean_param($questionnaire->name, PARAM_FILE); $name = preg_replace("/[^A-Z0-9]+/i", "_", trim($name)); $choicecodes = optional_param('choicecodes', '0', PARAM_INT); $choicetext = optional_param('choicetext', '0', PARAM_INT); $output = $questionnaire->generate_csv('', $user, $choicecodes, $choicetext, $currentgroupid); // CSV // SEP. 2007 JR changed file extension to *.txt for non-English Excel users' sake // and changed separator to tabulation // JAN. 2008 added \r carriage return for better Windows implementation. header("Content-Disposition: attachment; filename={$name}.txt"); header("Content-Type: text/comma-separated-values"); foreach ($output as $row) { $text = implode("\t", $row); echo $text . "\r\n"; } exit; break; case 'vall': // View all responses. // View all responses.