This commit is contained in:
@ -16,6 +16,7 @@ const QDB_DEV_GLASS_POINTS = [
|
||||
|
||||
require_once __DIR__ . '/app_answers.php';
|
||||
require_once __DIR__ . '/submissions.php';
|
||||
require_once __DIR__ . '/scoring.php';
|
||||
|
||||
/**
|
||||
* @return array{imported: array, skipped: array, errors: string[]}
|
||||
@ -36,6 +37,7 @@ function qdb_import_dev_fixture(PDO $pdo, array $fixture): array
|
||||
'completions' => 0,
|
||||
'submissions' => 0,
|
||||
'answers' => 0,
|
||||
'scoringRecomputed' => 0,
|
||||
];
|
||||
$skipped = [
|
||||
'admins' => 0,
|
||||
@ -48,6 +50,7 @@ function qdb_import_dev_fixture(PDO $pdo, array $fixture): array
|
||||
|
||||
$coachIdByUsername = [];
|
||||
$supervisorIdByUsername = [];
|
||||
$affectedClients = [];
|
||||
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$now = time();
|
||||
@ -218,9 +221,23 @@ function qdb_import_dev_fixture(PDO $pdo, array $fixture): array
|
||||
}
|
||||
|
||||
$imported['completions']++;
|
||||
$affectedClients[$clientCode] = true;
|
||||
$variant++;
|
||||
}
|
||||
|
||||
$upperPrefix = strtoupper(rtrim($prefix, '_'));
|
||||
$devClientStmt = $pdo->prepare('SELECT clientCode FROM client WHERE clientCode LIKE :pfx');
|
||||
$devClientStmt->execute([':pfx' => $upperPrefix . '%']);
|
||||
foreach ($devClientStmt->fetchAll(PDO::FETCH_COLUMN) as $cc) {
|
||||
$affectedClients[(string)$cc] = true;
|
||||
}
|
||||
if ($affectedClients !== []) {
|
||||
$imported['scoringRecomputed'] = qdb_recompute_scores_for_clients(
|
||||
$pdo,
|
||||
array_keys($affectedClients)
|
||||
);
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
} catch (Throwable $e) {
|
||||
if ($pdo->inTransaction()) {
|
||||
|
||||
Reference in New Issue
Block a user