Esempio n. 1
0
 /**
  * Downloads all dyslexia scores as a .csv-file.
  */
 public function download()
 {
     if (current_role() !== UserRole::Admin) {
         flashdata(lang('not_authorized'));
         redirect('/dyslexia/', 'refresh');
     }
     $csv = dyslexia_to_csv($this->dyslexiaModel->get_all_dyslexias());
     // Generate filename
     $filename = 'dyslexia_' . mdate("%Y%m%d_%H%i", time()) . '.csv';
     // Download the file
     force_download($filename, $csv);
 }
Esempio n. 2
0
 /**
  * Downloads all dyslexia data of an experiment as a .csv-file.
  * @param integer $experiment_id
  */
 public function download_dyslexia($experiment_id)
 {
     // Retrieve the scores and convert to .csv
     $participants = $this->experimentModel->get_participants_by_experiment($experiment_id, TRUE);
     $result = array();
     foreach ($participants as $participant) {
         $result = array_merge($result, $this->dyslexiaModel->get_dyslexias_by_participant($participant->id));
     }
     $csv = dyslexia_to_csv($result, $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 . '_dyslexia_' . mdate("%Y%m%d_%H%i", time()) . '.csv';
     // Download the file
     force_download($filename, $csv);
 }