ILIAS  release_8 Revision v8.23
ilObjTestScoreSettingsDatabaseRepository Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilObjTestScoreSettingsDatabaseRepository:
+ Collaboration diagram for ilObjTestScoreSettingsDatabaseRepository:

Public Member Functions

 __construct (ilDBInterface $db)
 
 getForObjFi (int $obj_fi)
 
 getFor (int $test_id)
 
 store (ilObjTestScoreSettings $settings)
 

Data Fields

const TABLE_NAME = 'tst_tests'
 
const STORAGE_DATE_FORMAT = 'YmdHis'
 

Protected Member Functions

 doSelect (string $where_part)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 21 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjTestScoreSettingsDatabaseRepository::__construct ( ilDBInterface  $db)

Definition at line 28 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

References $db.

Member Function Documentation

◆ doSelect()

ilObjTestScoreSettingsDatabaseRepository::doSelect ( string  $where_part)
protected

Definition at line 45 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

References $query, $res, ILIAS\LTI\ToolProvider\$settings, and ILIAS\Repository\int().

Referenced by getFor(), and getForObjFi().

46  {
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 //print_bs_with_res_sp
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  . 'result_tax_filters' . PHP_EOL
58  . 'FROM ' . self::TABLE_NAME . PHP_EOL
59  . $where_part;
60 
61  $res = $this->db->query($query);
62 
63  if ($this->db->numRows($res) == 0) {
64  throw new \Exception('no score settings: ' . $where_part);
65  }
66 
67  $row = $this->db->fetchAssoc($res);
68 
69  $reporting_date = $row['reporting_date'];
70  if ($reporting_date) {
71  $reporting_date = \DateTimeImmutable::createFromFormat(
72  self::STORAGE_DATE_FORMAT,
73  $reporting_date,
74  new DateTimeZone('UTC')
75  );
76  } else {
77  $reporting_date = null;
78  }
79 
80  $test_id = (int) $row['test_id'];
81  $tax_filter_ids = unserialize((string) ($row['result_tax_filters']));
82  if ($tax_filter_ids === false) {
83  $tax_filter_ids = [];
84  }
85 
87  $test_id,
88  (new ilObjTestSettingsScoring($test_id))
89  ->withCountSystem((int) $row['count_system'])
90  ->withScoreCutting((int) $row['score_cutting'])
91  ->withPassScoring((int) $row['pass_scoring']),
92  (new ilObjTestSettingsResultSummary($test_id))
93  ->withScoreReporting((int) $row['score_reporting'])
94  ->withReportingDate($reporting_date)
95  ->withShowGradingStatusEnabled((bool) $row['show_grading_status'])
96  ->withShowGradingMarkEnabled((bool) $row['show_grading_mark'])
97  ->withPassDeletionAllowed((bool) $row['pass_deletion_allowed']),
98  //->withShowPassDetails derived from results_presentation with bit RESULTPRES_BIT_PASS_DETAILS
99  (new ilObjTestSettingsResultDetails($test_id))
100  ->withResultsPresentation((int)$row['results_presentation'])
101  ->withPrintBestSolutionWithResult((bool) $row['print_bs_with_res'])
102  ->withShowExamIdInTestResults((bool) $row['examid_in_test_res'])
103  ->withExportSettings((int) $row['exportsettings'])
104  ->withTaxonomyFilterIds($tax_filter_ids),
105  (new ilObjTestSettingsGamification($test_id))
106  ->withHighscoreEnabled((bool) $row['highscore_enabled'])
107  ->withHighscoreAnon((bool) $row['highscore_anon'])
108  ->withHighscoreAchievedTS((bool) $row['highscore_achieved_ts'])
109  ->withHighscoreScore((bool) $row['highscore_score'])
110  ->withHighscorePercentage((bool) $row['highscore_percentage'])
111  ->withHighscoreHints((bool) $row['highscore_hints'])
112  ->withHighscoreWTime((bool) $row['highscore_wtime'])
113  ->withHighscoreOwnTable((bool) $row['highscore_own_table'])
114  ->withHighscoreTopTable((bool) $row['highscore_top_table'])
115  ->withHighscoreTopNum((int) $row['highscore_top_num'])
116  );
117 
118  return $settings;
119  }
$res
Definition: ltiservices.php:69
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFor()

ilObjTestScoreSettingsDatabaseRepository::getFor ( int  $test_id)

Implements ScoreSettingsRepository.

Definition at line 39 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

References doSelect().

40  {
41  $where_part = 'WHERE test_id = ' . $this->db->quote($test_id, 'integer');
42  return $this->doSelect($where_part);
43  }
+ Here is the call graph for this function:

◆ getForObjFi()

ilObjTestScoreSettingsDatabaseRepository::getForObjFi ( int  $obj_fi)

Definition at line 33 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

References doSelect().

34  {
35  $where_part = 'WHERE obj_fi = ' . $this->db->quote($obj_fi, 'integer');
36  return $this->doSelect($where_part);
37  }
+ Here is the call graph for this function:

◆ store()

ilObjTestScoreSettingsDatabaseRepository::store ( ilObjTestScoreSettings  $settings)

Implements ScoreSettingsRepository.

Definition at line 121 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

References ilObjTestScoreSettings\getGamificationSettings(), ilObjTestScoreSettings\getResultDetailsSettings(), ilObjTestScoreSettings\getResultSummarySettings(), ilObjTestScoreSettings\getScoringSettings(), and ilObjTestScoreSettings\getTestId().

121  : void
122  {
123  $values = array_merge(
124  $settings->getScoringSettings()->toStorage(),
125  $settings->getResultSummarySettings()->toStorage(),
126  $settings->getResultDetailsSettings()
127  ->withShowPassDetails($settings->getResultSummarySettings()->getShowPassDetails())
128  ->toStorage(),
129  $settings->getGamificationSettings()->toStorage()
130  );
131 
132  $this->db->update(
133  self::TABLE_NAME,
134  $values,
135  ['test_id' => ['integer', $settings->getTestId()]]
136  );
137  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilObjTestScoreSettingsDatabaseRepository::$db
protected

Definition at line 26 of file class.ilObjTestScoreSettingsDatabaseRepository.php.

Referenced by __construct().

◆ STORAGE_DATE_FORMAT

const ilObjTestScoreSettingsDatabaseRepository::STORAGE_DATE_FORMAT = 'YmdHis'

◆ TABLE_NAME

const ilObjTestScoreSettingsDatabaseRepository::TABLE_NAME = 'tst_tests'

The documentation for this class was generated from the following file: