19 declare(strict_types=1);
35 $where_part =
'WHERE obj_fi = ' . $this->db->quote($obj_fi,
'integer');
41 $where_part =
'WHERE test_id = ' . $this->db->quote($test_id,
'integer');
47 $query =
'SELECT ' . PHP_EOL
48 .
'test_id,' . PHP_EOL
49 .
'count_system, score_cutting, pass_scoring,' . PHP_EOL
50 .
'score_reporting, reporting_date,' . PHP_EOL
51 .
'show_grading_status, show_grading_mark, pass_deletion_allowed,' . PHP_EOL
52 .
'print_bs_with_res,' . PHP_EOL
53 .
'examid_in_test_res,' . PHP_EOL
54 .
'results_presentation,' . PHP_EOL
55 .
'exportsettings,' . PHP_EOL
56 .
'highscore_enabled, highscore_anon, highscore_achieved_ts, highscore_score, highscore_percentage, highscore_hints, highscore_wtime, highscore_own_table, highscore_top_table, highscore_top_num' . PHP_EOL
57 .
'FROM ' . self::TABLE_NAME . PHP_EOL
60 $res = $this->db->query($query);
62 if ($this->db->numRows(
$res) == 0) {
63 throw new \Exception(
'no score settings: ' . $where_part);
66 $row = $this->db->fetchAssoc(
$res);
68 $reporting_date = $row[
'reporting_date'];
69 if ($reporting_date) {
70 $reporting_date = \DateTimeImmutable::createFromFormat(
71 self::STORAGE_DATE_FORMAT,
76 $reporting_date = null;
79 $test_id = (
int) $row[
'test_id'];
84 ->withCountSystem((
int) $row[
'count_system'])
85 ->withScoreCutting((
int) $row[
'score_cutting'])
86 ->withPassScoring((
int) $row[
'pass_scoring']),
88 ->withScoreReporting((
int) $row[
'score_reporting'])
89 ->withReportingDate($reporting_date)
90 ->withShowGradingStatusEnabled((
bool) $row[
'show_grading_status'])
91 ->withShowGradingMarkEnabled((
bool) $row[
'show_grading_mark'])
92 ->withPassDeletionAllowed((
bool) $row[
'pass_deletion_allowed']),
95 ->withResultsPresentation((
int)$row[
'results_presentation'])
96 ->withShowExamIdInTestResults((
bool) $row[
'examid_in_test_res'])
97 ->withExportSettings((
int) $row[
'exportsettings']),
99 ->withHighscoreEnabled((
bool) $row[
'highscore_enabled'])
100 ->withHighscoreAnon((
bool) $row[
'highscore_anon'])
101 ->withHighscoreAchievedTS((
bool) $row[
'highscore_achieved_ts'])
102 ->withHighscoreScore((
bool) $row[
'highscore_score'])
103 ->withHighscorePercentage((
bool) $row[
'highscore_percentage'])
104 ->withHighscoreHints((
bool) $row[
'highscore_hints'])
105 ->withHighscoreWTime((
bool) $row[
'highscore_wtime'])
106 ->withHighscoreOwnTable((
bool) $row[
'highscore_own_table'])
107 ->withHighscoreTopTable((
bool) $row[
'highscore_top_table'])
108 ->withHighscoreTopNum((
int) $row[
'highscore_top_num'])
116 $values = array_merge(
128 [
'test_id' => [
'integer', $settings->
getTestId()]]
doSelect(string $where_part)
store(ilObjTestScoreSettings $settings)
const STORAGE_DATE_FORMAT
getGamificationSettings()
getResultDetailsSettings()
getResultSummarySettings()
__construct(ilDBInterface $db)