getRepository('ChamiloCoreBundle:TrackEExercises')->find($_REQUEST['id']); if (empty($trackedExercise)) { exit; } $studentId = $trackedExercise->getExeUserId(); $exerciseId = $trackedExercise->getExeExoId(); $exeId = $trackedExercise->getExeId(); if ($studentId != intval($_REQUEST['user']) || $exerciseId != intval($_REQUEST['exercise']) ) { exit; } $questionList = $trackedExercise->getDataTracking(); if (empty($questionList)) { exit; } $questionList = explode(',', $questionList); $exercise = new Exercise($courseId); $exercise->read($exerciseId); $totalScore = 0; $totalWeight = 0; $useEvaluationPlugin = false; $pluginEvaluation = QuestionOptionsEvaluationPlugin::create(); if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) { $formula = $pluginEvaluation->getFormulaForExercise($exerciseId); if (!empty($formula)) { $useEvaluationPlugin = true; } } if (!$useEvaluationPlugin) { foreach ($questionList as $questionId) { $question = Question::read($questionId, api_get_course_info()); $totalWeight += $question->selectWeighting(); // We're inside *one* question. Go through each possible answer for this question if ($question->type === MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { $result = $exercise->manage_answer( $exeId, $questionId, [], 'exercise_result', [], false, true, false, $exercise->selectPropagateNeg(), [], [], true ); } else { $result = $exercise->manage_answer( $exeId, $questionId, [], 'exercise_result', [], false, true, false, $exercise->selectPropagateNeg(), [], [], true ); } // Adding the new score. $totalScore += $result['score']; } $remindList = $trackedExercise->getQuestionsToCheck(); if (!empty($remindList)) { $remindList = explode(',', $remindList); } } else { $totalScore = $pluginEvaluation->getResultWithFormula($exeId, $formula); $totalWeight = $pluginEvaluation->getMaxScore(); } $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $sql = "UPDATE $table SET score = '$totalScore', max_score = '$totalWeight' WHERE exe_id = $exeId"; Database::query($sql); echo $totalScore.'/'.$totalWeight;