/** * {@inheritdoc} */ public function export() { if (empty($this->item_id)) { throw new TransactionExportException('Undefined item_id'); } $attempt_id = $this->item_id; $attempt = get_exercise_results_by_attempt($attempt_id); if (empty($attempt)) { throw new TransactionExportException(sprintf('There is no exercise attempt information associated with exe_id "%d" in the database.', $attempt_id)); } $exercise = new Exercise(); $exercise_stat_info = $exercise->getStatTrackExerciseInfoByExeId($attempt_id); if (empty($exercise_stat_info)) { throw new TransactionExportException(sprintf('There is no exercise stat information associated with exe_id "%d" in the database.', $attempt_id)); } // Exercise read expects course id set. $exercise->course_id = $exercise_stat_info['c_id']; if (!$exercise->read($exercise_stat_info['exe_exo_id'])) { throw new TransactionExportException(sprintf('The associated exercise id "%d" does not currently exist in the database.', $exercise_stat_info['exe_exo_id'])); } // Prepare the export. $this->data['stat_info'] = $exercise_stat_info; $this->data['attempt_info'] = $attempt; $content = (array) $this; return json_encode($content); }
// general parameters passed via POST/GET if (empty($origin)) { $origin = Security::remove_XSS($_REQUEST['origin']); } if (empty($objExercise)) { $objExercise = $_SESSION['objExercise']; } if (empty($remind_list)) { $remind_list = isset($_REQUEST['remind_list']) ? $_REQUEST['remind_list'] : null; } $exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0; if (empty($objExercise)) { // Redirect to the exercise overview // Check if the exe_id exists $objExercise = new Exercise(); $exercise_stat_info = $objExercise->getStatTrackExerciseInfoByExeId($exe_id); if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) { if ($exercise_stat_info['status'] == 'incomplete') { $objExercise->read($exercise_stat_info['exe_exo_id']); } else { header("Location: overview.php?exerciseId=" . $exercise_stat_info['exe_exo_id']); exit; } } else { api_not_allowed(true); } } $gradebook = ''; if (isset($_SESSION['gradebook'])) { $gradebook = $_SESSION['gradebook']; }