Skip to content

Commit 873ee73

Browse files
committed
Minor: Exercise: Optimize use of new variable in get_student_stats_by_question() - refs #3428
1 parent d3da7ce commit 873ee73

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

main/inc/lib/exercise.lib.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,31 +3816,29 @@ public static function get_student_stats_by_question(
38163816
$session_id = (int) $session_id;
38173817
$courseId = api_get_course_int_id($course_code);
38183818

3819-
if (empty($session_id)) {
3820-
$courseCondition = "
3819+
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
3820+
FROM $track_exercises e
3821+
";
3822+
if (true == $onlyStudent) {
3823+
$courseCondition = '';
3824+
if (empty($session_id)) {
3825+
$courseCondition = "
38213826
INNER JOIN $courseUser c
38223827
ON (
38233828
e.exe_user_id = c.user_id AND
38243829
e.c_id = c.c_id AND
38253830
c.status = ".STUDENT."
38263831
AND relation_type <> 2
3827-
)
3828-
";
3829-
} else {
3830-
$courseCondition = "
3832+
)";
3833+
} else {
3834+
$courseCondition = "
38313835
INNER JOIN $courseUser c
38323836
ON (
38333837
e.exe_user_id = c.user_id AND
38343838
e.c_id = c.c_id AND
38353839
c.status = 0
3836-
)
3837-
";
3838-
}
3839-
3840-
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
3841-
FROM $track_exercises e
3842-
";
3843-
if ($onlyStudent == true) {
3840+
)";
3841+
}
38443842
$sql .= $courseCondition;
38453843
}
38463844
$sql .= "

0 commit comments

Comments
 (0)