Esempio n. 1
0
 /**
  * Downloads all scores of participants of an experiment as a .csv-file.
  * @param integer $experiment_id
  * @param string $test_code
  */
 public function download_scores($experiment_id, $test_code)
 {
     // Retrieve the scores and convert to .csv
     $table = $this->get_results_table($experiment_id, $test_code);
     $csv = scores_to_csv($test_code, $table, $experiment_id);
     // Generate filename
     $experiment_name = $this->experimentModel->get_experiment_by_id($experiment_id)->name;
     $escaped = preg_replace('/[^A-Za-z0-9_\\-]/', '_', $experiment_name);
     $filename = $escaped . '_' . mdate("%Y%m%d_%H%i", time()) . '.csv';
     // Download the file
     force_download($filename, $csv);
 }
Esempio n. 2
0
 /**
  * Downloads all scores of participants of a testsurvey as a .csv-file.
  * @param integer $testsurvey_id
  */
 public function download_scores($testsurvey_id)
 {
     $testsurvey = $this->testSurveyModel->get_testsurvey_by_id($testsurvey_id);
     $test = $this->testSurveyModel->get_test_by_testsurvey($testsurvey);
     // Retrieve the scores and convert to .csv
     $table = $this->get_results_table($testsurvey_id);
     $csv = scores_to_csv($test->code, $table);
     // Generate filename
     $escaped = preg_replace('/[^A-Za-z0-9_\\-]/', '_', testsurvey_name($testsurvey));
     $filename = $escaped . '_' . mdate("%Y%m%d_%H%i", time()) . '.csv';
     // Download the file
     force_download($filename, $csv);
 }