break;
            case 'csv':
            default:
                $export->exportCompleteReportCSV($documentPath, null, $loadExtraData, null, $_GET['exerciseId']);
                exit;
                break;
        }
    } else {
        api_not_allowed(true);
    }
}
//Send student email @todo move this code in a class, library
if (isset($_REQUEST['comments']) && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor || $allowCoachFeedbackExercises)) {
    //filtered by post-condition
    $id = intval($_GET['exeid']);
    $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
    if (empty($track_exercise_info)) {
        api_not_allowed();
    }
    $test = $track_exercise_info['title'];
    $student_id = $track_exercise_info['exe_user_id'];
    $session_id = $track_exercise_info['session_id'];
    $lp_id = $track_exercise_info['orig_lp_id'];
    //$lp_item_id        = $track_exercise_info['orig_lp_item_id'];
    $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
    $course_info = api_get_course_info();
    // Teacher data
    $teacher_info = api_get_user_info(api_get_user_id());
    $from_name = api_get_person_name($teacher_info['firstname'], $teacher_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
    $url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id=' . $track_exercise_info['exe_id'] . '&' . api_get_cidreq() . '&show_headers=1&id_session=' . $session_id;
    $my_post_info = array();
 /**
  * @Route("/score-attempt/{exeId}/jury/{juryId}")
  * @Method({"GET"})
  */
 public function scoreAttemptAction($exeId, $juryId)
 {
     $userId = $this->getUser()->getUserId();
     $trackExercise = \ExerciseLib::get_exercise_track_exercise_info($exeId);
     if (empty($trackExercise)) {
         $this->createNotFoundException();
     }
     /** @var \Chamilo\CoreBundle\Entity\Jury $jury */
     $jury = $this->getRepository()->find($juryId);
     if (empty($jury)) {
         $this->createNotFoundException('Jury does not exists');
     }
     if ($jury->getExerciseId() != $trackExercise['exe_exo_id']) {
         $this->createNotFoundException('Exercise attempt is not related with this jury.');
     }
     $members = $jury->getMembers();
     $criteria = Criteria::create()->where(Criteria::expr()->eq("userId", $userId))->setFirstResult(0)->setMaxResults(1);
     /** @var JuryMembers $member */
     $member = $members->matching($criteria)->first();
     if (empty($member)) {
         $this->createNotFoundException('You are not part of the jury.');
     }
     $students = $member->getStudents();
     $criteria = Criteria::create()->where(Criteria::expr()->eq("userId", $trackExercise['exe_user_id']))->setFirstResult(0)->setMaxResults(1);
     /** @var JuryMembers $member */
     $student = $students->matching($criteria)->first();
     if (empty($student)) {
         $this->createNotFoundException('You are not assigned to this user.');
     }
     // Setting member only for president.
     if ($this->isGranted('ROLE_JURY_PRESIDENT')) {
         // Relating user with president
         if ($member) {
             $this->getManager()->getRepository('Chamilo\\CoreBundle\\Entity\\JuryMembers')->assignUserToJuryMember($trackExercise['exe_user_id'], $member->getId());
         }
     }
     $questionScoreTypeModel = array();
     $criteria = array('exeId' => $exeId, 'juryUserId' => $userId);
     $trackJury = $this->getManager()->getRepository('Chamilo\\CoreBundle\\Entity\\TrackAttemptJury')->findBy($criteria);
     if ($trackJury) {
         $this->get('session')->getFlashBag()->add('info', "You already review this exercise attempt.");
         /** @var TrackAttemptJury $track */
         foreach ($trackJury as $track) {
             $questionScoreTypeModel[$track->getQuestionId()] = $track->getQuestionScoreNameId();
         }
     }
     $questionList = explode(',', $trackExercise['data_tracking']);
     $exerciseResult = \ExerciseLib::getExerciseResult($trackExercise);
     $counter = 1;
     $objExercise = new \Exercise($trackExercise['c_id']);
     $objExercise->read($trackExercise['exe_exo_id']);
     $totalScore = $totalWeighting = 0;
     $show_media = true;
     $tempParentId = null;
     $mediaCounter = 0;
     $media_list = array();
     $modelType = $objExercise->getScoreTypeModel();
     $options = array();
     if ($modelType) {
         /** @var \Chamilo\CoreBundle\Entity\QuestionScore $questionScoreName */
         $questionScore = $this->get('orm.em')->getRepository('Chamilo\\CoreBundle\\Entity\\QuestionScore')->find($modelType);
         if ($questionScore) {
             $items = $questionScore->getItems();
             /** @var \Chamilo\CoreBundle\Entity\QuestionScoreName  $score */
             foreach ($items as $score) {
                 $options[$score->getId() . ':' . $score->getScore()] = $score;
             }
         }
     } else {
         return $this->createNotFoundException('The exercise does not contain a model type.');
     }
     $exerciseContent = null;
     foreach ($questionList as $questionId) {
         ob_start();
         $choice = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : null;
         // Creates a temporary Question object
         /** @var \Question $objQuestionTmp */
         $objQuestionTmp = \Question::read($questionId);
         if ($objQuestionTmp->parent_id != 0) {
             if (!in_array($objQuestionTmp->parent_id, $media_list)) {
                 $media_list[] = $objQuestionTmp->parent_id;
                 $show_media = true;
             }
             if ($tempParentId == $objQuestionTmp->parent_id) {
                 $mediaCounter++;
             } else {
                 $mediaCounter = 0;
             }
             $counterToShow = chr(97 + $mediaCounter);
             $tempParentId = $objQuestionTmp->parent_id;
         }
         $questionWeighting = $objQuestionTmp->selectWeighting();
         $answerType = $objQuestionTmp->selectType();
         $question_result = $objExercise->manageAnswers($exeId, $questionId, $choice, 'exercise_show', array(), false, true, true);
         $questionScore = $question_result['score'];
         $totalScore += $question_result['score'];
         $my_total_score = $questionScore;
         $my_total_weight = $questionWeighting;
         $totalWeighting += $questionWeighting;
         $score = array();
         $score['result'] = get_lang('Score') . " : " . \ExerciseLib::show_score($my_total_score, $my_total_weight, false, false);
         $score['pass'] = $my_total_score >= $my_total_weight ? true : false;
         $score['type'] = $answerType;
         $score['score'] = $my_total_score;
         $score['weight'] = $my_total_weight;
         $score['comments'] = isset($comnt) ? $comnt : null;
         $contents = ob_get_clean();
         $question_content = '<div class="question_row">';
         $question_content .= $objQuestionTmp->return_header($objExercise->feedback_type, $counter, $score, $show_media, $mediaCounter);
         $question_content .= '</table>';
         // display question category, if any
         $question_content .= \Testcategory::getCategoryNamesForQuestion($questionId);
         $question_content .= $contents;
         $defaultValue = isset($questionScoreTypeModel[$questionId]) ? $questionScoreTypeModel[$questionId] : null;
         //$question_content .= \Display::select('options['.$questionId.']', $options, $defaultValue);
         foreach ($options as $value => $score) {
             $attributes = array();
             if ($score->getId() == $defaultValue) {
                 $attributes = array('checked' => 'checked');
             }
             $question_content .= '<label>';
             $question_content .= \Display::input('radio', 'options[' . $questionId . ']', $value, $attributes) . ' <span title="' . $score->getDescription() . '" data-toggle="tooltip" > ' . $score->getName() . ' </span>';
             $question_content .= '</label>';
         }
         $question_content .= '</div>';
         $exerciseContent .= $question_content;
         $counter++;
     }
     $template = $this->get('template');
     $template->assign('exercise', $exerciseContent);
     $template->assign('exe_id', $exeId);
     $template->assign('jury_id', $juryId);
     $response = $this->get('template')->render_template($this->getTemplatePath() . 'score_attempt.tpl');
     return new Response($response, 200, array());
 }
 /**
  * Returns the exercise result
  * @param 	int		attempt id
  * @return 	float 	exercise result
  */
 public function get_exercise_result($exe_id)
 {
     $result = array();
     $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($exe_id);
     if (!empty($track_exercise_info)) {
         $totalScore = 0;
         $objExercise = new Exercise();
         $objExercise->read($track_exercise_info['exe_exo_id']);
         if (!empty($track_exercise_info['data_tracking'])) {
             $question_list = explode(',', $track_exercise_info['data_tracking']);
         }
         foreach ($question_list as $questionId) {
             $question_result = $objExercise->manage_answer($exe_id, $questionId, '', 'exercise_show', array(), false, true, false, $objExercise->selectPropagateNeg());
             $totalScore += $question_result['score'];
         }
         if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
             $totalScore = 0;
         }
         $result = array('score' => $totalScore, 'weight' => $track_exercise_info['exe_weighting']);
     }
     return $result;
 }
<?php

/* For licensing terms, see /license.txt */
/**
 * This file generates the ActionScript variables code used by the
 * HotSpot .swf
 * @package chamilo.exercise
 * @author Toon Keppens, Julio Montoya adding hotspot "medical" support
 */
include '../inc/global.inc.php';
// Set vars
$questionId = intval($_GET['modifyAnswers']);
$exe_id = intval($_GET['exe_id']);
$objQuestion = Question::read($questionId);
$trackExerciseInfo = ExerciseLib::get_exercise_track_exercise_info($exe_id);
$objExercise = new Exercise(api_get_course_int_id());
$objExercise->read($trackExerciseInfo['exe_exo_id']);
$em = Database::getManager();
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
$picturePath = $documentPath . '/images';
$pictureName = $objQuestion->selectPicture();
$pictureSize = getimagesize($picturePath . '/' . $objQuestion->selectPicture());
$pictureWidth = $pictureSize[0];
$pictureHeight = $pictureSize[1];
$course_id = api_get_course_int_id();
// Init
$data = [];
$data['type'] = 'solution';
$data['lang'] = ['Square' => get_lang('Square'), 'Ellipse' => get_lang('Ellipse'), 'Polygon' => get_lang('Polygon'), 'HotspotStatus1' => get_lang('HotspotStatus1'), 'HotspotStatus2Polygon' => get_lang('HotspotStatus2Polygon'), 'HotspotStatus2Other' => get_lang('HotspotStatus2Other'), 'HotspotStatus3' => get_lang('HotspotStatus3'), 'HotspotShowUserPoints' => get_lang('HotspotShowUserPoints'), 'ShowHotspots' => get_lang('ShowHotspots'), 'Triesleft' => get_lang('Triesleft'), 'HotspotExerciseFinished' => get_lang('HotspotExerciseFinished'), 'NextAnswer' => get_lang('NextAnswer'), 'Delineation' => get_lang('Delineation'), 'CloseDelineation' => get_lang('CloseDelineation'), 'Oar' => get_lang('Oar'), 'ClosePolygon' => get_lang('ClosePolygon'), 'DelineationStatus1' => get_lang('DelineationStatus1')];
$data['image'] = $objQuestion->selectPicturePath();
$data['image_width'] = $pictureWidth;