fix unit tests as well as missing code
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -699,24 +699,33 @@ class CompetitionWinnersAdminService
|
||||
);
|
||||
|
||||
$quizIndex = (int) ($row->next_index ?? 1);
|
||||
$scoreExpression = 'ROUND(CASE
|
||||
WHEN (cs.score * 100.0 / NULLIF(ccw.question_count, 0)) < 0 THEN 0
|
||||
WHEN (cs.score * 100.0 / NULLIF(ccw.question_count, 0)) > 100 THEN 100
|
||||
ELSE (cs.score * 100.0 / NULLIF(ccw.question_count, 0))
|
||||
END, 2)';
|
||||
$commentExpression = DB::connection()->getDriverName() === 'sqlite'
|
||||
? "'Competition ' || cs.competition_id || ' normalized from ' || cs.score || '/' || ccw.question_count"
|
||||
: "CONCAT('Competition ', cs.competition_id, ' normalized from ', cs.score, '/', ccw.question_count)";
|
||||
$now = now()->toDateTimeString();
|
||||
|
||||
$sql = <<<'SQL'
|
||||
INSERT INTO quiz
|
||||
(student_id, school_id, class_section_id, updated_by, quiz_index, score, comment, semester, school_year, created_at, updated_at)
|
||||
SELECT
|
||||
cs.student_id,
|
||||
?,
|
||||
cs.class_section_id,
|
||||
?,
|
||||
?,
|
||||
ROUND(LEAST(100, GREATEST(0, (cs.score / NULLIF(ccw.question_count, 0)) * 100)), 2),
|
||||
CONCAT('Competition ', cs.competition_id, ' normalized from ', cs.score, '/', ccw.question_count),
|
||||
?,
|
||||
?,
|
||||
NOW(), NOW()
|
||||
FROM competition_scores cs
|
||||
JOIN competition_class_winners ccw
|
||||
ON ccw.competition_id = cs.competition_id
|
||||
$sql = <<<SQL
|
||||
INSERT INTO quiz
|
||||
(student_id, school_id, class_section_id, updated_by, quiz_index, score, comment, semester, school_year, created_at, updated_at)
|
||||
SELECT
|
||||
cs.student_id,
|
||||
?,
|
||||
cs.class_section_id,
|
||||
?,
|
||||
?,
|
||||
{$scoreExpression},
|
||||
{$commentExpression},
|
||||
?,
|
||||
?,
|
||||
?, ?
|
||||
FROM competition_scores cs
|
||||
JOIN competition_class_winners ccw
|
||||
ON ccw.competition_id = cs.competition_id
|
||||
AND ccw.class_section_id = cs.class_section_id
|
||||
WHERE cs.competition_id = ?
|
||||
AND cs.class_section_id = ?
|
||||
@@ -728,6 +737,8 @@ SQL;
|
||||
$quizIndex,
|
||||
$semester,
|
||||
$schoolYear,
|
||||
$now,
|
||||
$now,
|
||||
$competitionId,
|
||||
$cid,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user