ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLOTestAssignment.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12  private $assignment_id = 0;
13  private $container_id = 0;
14  private $assignment_type = 0;
15  private $objective_id = 0;
16  private $test_ref_id = 0;
17 
18 
23  public function __construct($a_id = 0)
24  {
25  $this->setAssignmentId($a_id);
26  $this->read();
27  }
28 
29  public function setAssignmentId($a_id)
30  {
31  $this->assignment_id = $a_id;
32  }
33 
34  public function getAssignmentId()
35  {
36  return $this->assignment_id;
37  }
38 
39  public function setContainerId($a_id)
40  {
41  $this->container_id = $a_id;
42  }
43 
44  public function getContainerId()
45  {
46  return $this->container_id;
47  }
48 
49  public function setAssignmentType($a_type)
50  {
51  $this->assignment_type = $a_type;
52  }
53 
54  public function getAssignmentType()
55  {
57  }
58 
59  public function setObjectiveId($a_id)
60  {
61  $this->objective_id = $a_id;
62  }
63 
64  public function getObjectiveId()
65  {
66  return $this->objective_id;
67  }
68 
69  public function setTestRefId($a_id)
70  {
71  $this->test_ref_id = $a_id;
72  }
73 
74  public function getTestRefId()
75  {
76  return $this->test_ref_id;
77  }
78 
83  public function save()
84  {
85  if ($this->getAssignmentId()) {
86  return $this->update();
87  } else {
88  return $this->create();
89  }
90  }
91 
96  public function create()
97  {
98  global $ilDB;
99 
100  $this->setAssignmentId($ilDB->nextId('loc_tst_assignments'));
101  $query = 'INSERT INTO loc_tst_assignments (assignment_id, container_id, assignment_type, objective_id, tst_ref_id) ' .
102  'VALUES ( ' .
103  $ilDB->quote($this->getAssignmentId(), 'integer') . ', ' .
104  $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
105  $ilDB->quote($this->getAssignmentType(), 'integer') . ', ' .
106  $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
107  $ilDB->quote($this->getTestRefId(), 'integer') . ' ' .
108  ') ';
109  $GLOBALS['ilLog']->write($query);
110  $ilDB->manipulate($query);
111  }
112 
117  public function update()
118  {
119  global $ilDB;
120 
121  $query = 'UPDATE loc_tst_assignments ' .
122  'SET container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
123  'assignment_type = ' . $ilDB->quote($this->getAssignmentType(), 'integer') . ', ' .
124  'objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
125  'tst_ref_id = ' . $ilDB->quote($this->getTestRefId(), 'integer') . ' ' .
126  'WHERE assignment_id = ' . $ilDB->quote($this->getAssignmentId(), 'integer');
127  $ilDB->manipulate($query);
128  }
129 
135  public function delete()
136  {
137  global $ilDB;
138 
139  $query = 'DELETE FROM loc_tst_assignments ' .
140  'WHERE assignment_id = ' . $ilDB->quote($this->getAssignmentId(), 'integer') . ' ';
141  $ilDB->manipulate($query);
142  return true;
143  }
144 
150  public function read()
151  {
152  global $ilDB;
153 
154  if (!$this->getAssignmentId()) {
155  return false;
156  }
157 
158  $query = 'SELECT * FROM loc_tst_assignments ' .
159  'WHERE assignment_id = ' . $ilDB->quote($this->getAssignmentId(), 'integer') . ' ';
160  $res = $ilDB->query($query);
161  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
162  $this->setContainerId($row->container_id);
163  $this->setObjectiveId($row->objective_id);
164  $this->setAssignmentType($row->assignment_type);
165  $this->setTestRefId($row->tst_ref_id);
166  }
167  return true;
168  }
169 
175  public function cloneSettings($a_copy_id, $a_target_id, $a_objective_id)
176  {
177  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
179  $mappings = $options->getMappings();
180 
181  if (!array_key_exists($this->getTestRefId(), $mappings)) {
182  return false;
183  }
184 
185  $copy = new ilLOTestAssignment();
186  $copy->setContainerId($a_target_id);
187  $copy->setAssignmentType($this->getAssignmentType());
188  $copy->setObjectiveId($a_objective_id);
189  $copy->setTestRefId($mappings[$this->getTestRefId()]);
190  $copy->create();
191  }
192 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$a_type
Definition: workflow.php:92
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
read()
Read db entry type $ilDB.
update()
Update assignment type $ilDB.
$query
create()
Create new aassignment type $ilDB.
Settings for LO courses.
global $ilDB
__construct($a_id=0)
constructor
cloneSettings($a_copy_id, $a_target_id, $a_objective_id)
Clone assignments.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20