ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssQuestionSkillAssignmentImportFails.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
15  protected $settings;
16 
20  protected $parentObjId;
21 
26  public function __construct($parentObjId)
27  {
28  $this->parentObjId = $parentObjId;
29  }
30 
34  protected function getSettings()
35  {
36  if ($this->settings === null) {
37  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportList.php';
38  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentRegistry.php';
39  $this->settings = new ilAssQuestionSkillAssignmentRegistry(new ilSetting('assimportfails'));
40  }
41 
42  return $this->settings;
43  }
44 
48  protected function getParentObjId()
49  {
50  return $this->parentObjId;
51  }
52 
56  protected function buildSettingsKey()
57  {
58  return 'failed_imp_qsa_parentobj_' . $this->getParentObjId();
59  }
60 
64  public function getFailedImports()
65  {
66  $value = $this->getSettings()->getStringifiedImports($this->buildSettingsKey(), null);
67 
68  if ($value !== null) {
69  return unserialize($value);
70  }
71 
72  return null;
73  }
74 
79  {
80  $this->getSettings()->setStringifiedImports($this->buildSettingsKey(), serialize($assignmentList));
81  }
82 
85  public function deleteRegisteredImportFails()
86  {
87  $this->getSettings()->deleteStringifiedImports($this->buildSettingsKey());
88  }
89 
93  public function failedImportsRegistered()
94  {
95  return $this->getFailedImports() !== null;
96  }
97 
103  {
104  $handledSkills = array();
105  $msg = $lng->txt('tst_failed_imp_qst_skl_assign');
106 
107  $msg .= '<ul>';
108  foreach ($this->getFailedImports() as $assignmentImport) {
109  $sklBaseId = $assignmentImport->getImportSkillBaseId();
110  $sklTrefId = $assignmentImport->getImportSkillTrefId();
111 
112  if (isset($handledSkills["$sklBaseId:$sklTrefId"])) {
113  continue;
114  }
115 
116  $handledSkills["$sklBaseId:$sklTrefId"] = true;
117 
118  $msg .= '<li>' . $assignmentImport->getImportSkillTitle() . '</li>';
119  }
120  $msg .= '</ul>';
121 
122  return $msg;
123  }
124 }
settings()
Definition: settings.php:2
__construct($parentObjId)
ilAssQuestionSkillAssignmentImportFails constructor.
$lng
Class ilAssQuestionSkillAssignmentRegistry.
language handling
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
registerFailedImports(ilAssQuestionSkillAssignmentImportList $assignmentList)