Skip to content

Commit

Permalink
Internal: Fix score calculation across reports and interfaces - refs …
Browse files Browse the repository at this point in the history
…BT#22096
  • Loading branch information
christianbeeznest committed Dec 3, 2024
1 parent 9b1f1e6 commit 248d6fd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
6 changes: 1 addition & 5 deletions public/main/inc/lib/TrackingCourseLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,7 @@ public static function getUserData(
$totalSurveys = 0;
$totalExercises = ExerciseLib::get_all_exercises(
$courseInfo,
$sessionId,
false,
null,
false,
3
$sessionId
);

if (empty($sessionId)) {
Expand Down
4 changes: 3 additions & 1 deletion public/main/inc/lib/exercise.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,9 @@ public static function get_all_exercises(

$repo = Container::getQuizRepository();

return $repo->findAllByCourse($course, $session, (string) $search, $active);
return $repo->findAllByCourse($course, $session, (string) $search, $active)
->getQuery()
->getResult();
}

/**
Expand Down
9 changes: 3 additions & 6 deletions public/main/inc/lib/tracking.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2640,19 +2640,15 @@ public static function get_exercise_student_average_best_attempt(
$sessionId
) {
$result = 0;

if ($exercise_list instanceof \Doctrine\ORM\QueryBuilder) {
$exercise_list = $exercise_list->getQuery()->getResult();
}

if (!empty($exercise_list) && (is_array($exercise_list) || $exercise_list instanceof \Countable)) {
foreach ($exercise_list as $exercise_data) {
$exercise_id = $exercise_data->getIid();
$best_attempt = Event::get_best_attempt_exercise_results_per_user(
$user_id,
$exercise_id,
$courseId,
$sessionId
$sessionId,
false
);

if (!empty($best_attempt) && !empty($best_attempt['max_score'])) {
Expand Down Expand Up @@ -2940,6 +2936,7 @@ public static function get_avg_student_score(
WHERE
lp_id IN (".implode(',', $lp_list).")
$condition_user1
$sessionCondition
GROUP BY lp_id, user_id";
//AND session_id = $sessionId

Expand Down
4 changes: 3 additions & 1 deletion src/CourseBundle/Repository/CQuizRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public function findAllByCourse(
$this->addCategoryQueryBuilder($categoryId, $qb);
$this->addActiveQueryBuilder($active, $qb);
$this->addNotDeletedQueryBuilder($qb);
$this->addTitleQueryBuilder($title, $qb);
if (!empty($title)) {
$this->addTitleQueryBuilder($title, $qb);
}

return $qb;
}
Expand Down

0 comments on commit 248d6fd

Please sign in to comment.