ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveySkillThresholds.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  protected ilObjSurvey $survey;
26  protected ilDBInterface $db;
28  protected array $threshold = [];
29 
30  public function __construct(ilObjSurvey $a_survey)
31  {
32  global $DIC;
33 
34  $this->db = $DIC->database();
35  $this->survey = $a_survey;
36  $this->read();
37  }
38 
39  public function read(): void
40  {
41  $ilDB = $this->db;
42 
43  $set = $ilDB->query(
44  "SELECT * FROM svy_skill_threshold " .
45  " WHERE survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
46  );
47  while ($rec = $ilDB->fetchAssoc($set)) {
48  $this->threshold[(int) $rec['level_id']][(int) $rec['tref_id']] = (int) $rec['threshold'];
49  }
50  }
51 
55  public function getThresholds(): array
56  {
57  return $this->threshold;
58  }
59 
60  public function writeThreshold(
61  int $a_base_skill_id,
62  int $a_tref_id,
63  int $a_level_id,
64  int $a_threshold
65  ): void {
66  $ilDB = $this->db;
67 
68  $ilDB->replace(
69  "svy_skill_threshold",
70  array("survey_id" => array("integer", $this->survey->getId()),
71  "base_skill_id" => array("integer", $a_base_skill_id),
72  "tref_id" => array("integer", $a_tref_id),
73  "level_id" => array("integer", $a_level_id)
74  ),
75  array("threshold" => array("integer", $a_threshold))
76  );
77  }
78 
79  public function cloneTo(ilObjSurvey $target_survey, array $mapping) : void
80  {
81  $target_thresholds = new self($target_survey);
82  $set = $this->db->queryF("SELECT * FROM svy_skill_threshold " .
83  " WHERE survey_id = %s ",
84  ["integer"],
85  [$this->survey->getId()]
86  );
87  while ($rec = $this->db->fetchAssoc($set)) {
88  $target_thresholds->writeThreshold(
89  (int) $rec["base_skill_id"],
90  (int) $rec["tref_id"],
91  (int) $rec["level_id"],
92  (int) $rec["threshold"]
93  );
94  }
95  }
96 }
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
cloneTo(ilObjSurvey $target_survey, array $mapping)
writeThreshold(int $a_base_skill_id, int $a_tref_id, int $a_level_id, int $a_threshold)