ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
87  return $this->update();
88  }
89  else
90  {
91  return $this->create();
92  }
93  }
94 
99  public function create()
100  {
101  global $ilDB;
102 
103  $this->setAssignmentId($ilDB->nextId('loc_tst_assignments'));
104  $query = 'INSERT INTO loc_tst_assignments (assignment_id, container_id, assignment_type, objective_id, tst_ref_id) '.
105  'VALUES ( '.
106  $ilDB->quote($this->getAssignmentId(),'integer').', '.
107  $ilDB->quote($this->getContainerId(),'integer').', '.
108  $ilDB->quote($this->getAssignmentType(),'integer').', '.
109  $ilDB->quote($this->getObjectiveId(),'integer').', '.
110  $ilDB->quote($this->getTestRefId(),'integer').' '.
111  ') ';
112  $GLOBALS['ilLog']->write($query);
113  $ilDB->manipulate($query);
114 
115  }
116 
121  public function update()
122  {
123  global $ilDB;
124 
125  $query = 'UPDATE loc_tst_assignments '.
126  'SET container_id = '.$ilDB->quote($this->getContainerId(),'integer').', '.
127  'assignment_type = '.$ilDB->quote($this->getAssignmentType(),'integer').', '.
128  'objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').', '.
129  'tst_ref_id = '.$ilDB->quote($this->getTestRefId(),'integer').' '.
130  'WHERE assignment_id = '.$ilDB->quote($this->getAssignmentId(),'integer');
131  $ilDB->manipulate($query);
132  }
133 
139  public function delete()
140  {
141  global $ilDB;
142 
143  $query = 'DELETE FROM loc_tst_assignments '.
144  'WHERE assignment_id = '.$ilDB->quote($this->getAssignmentId(),'integer').' ';
145  $ilDB->manipulate($query);
146  return TRUE;
147  }
148 
154  public function read()
155  {
156  global $ilDB;
157 
158  if(!$this->getAssignmentId())
159  {
160  return FALSE;
161  }
162 
163  $query = 'SELECT * FROM loc_tst_assignments '.
164  'WHERE assignment_id = '.$ilDB->quote($this->getAssignmentId(),'integer').' ';
165  $res = $ilDB->query($query);
166  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
167  {
168  $this->setContainerId($row->container_id);
169  $this->setObjectiveId($row->objective_id);
170  $this->setAssignmentType($row->assignment_type);
171  $this->setTestRefId($row->tst_ref_id);
172  }
173  return TRUE;
174  }
175 
181  public function cloneSettings($a_copy_id, $a_target_id, $a_objective_id)
182  {
183  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
185  $mappings = $options->getMappings();
186 
187  if(!array_key_exists($this->getTestRefId(), $mappings))
188  {
189  return FALSE;
190  }
191 
192  $copy = new ilLOTestAssignment();
193  $copy->setContainerId($a_target_id);
194  $copy->setAssignmentType($this->getAssignmentType());
195  $copy->setObjectiveId($a_objective_id);
196  $copy->setTestRefId($mappings[$this->getTestRefId()]);
197  $copy->create();
198  }
199 }
200 ?>
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$a_type
Definition: workflow.php:93
static _getInstance($a_copy_id)
Get instance of copy wizard options.
if(!is_array($argv)) $options
read()
Read db entry type $ilDB.
update()
Update assignment type $ilDB.
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.