ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilIndividualAssessmentMembersStorageDB.php
Go to the documentation of this file.
1 <?php
2 require_once 'Modules/IndividualAssessment/interfaces/Members/interface.ilIndividualAssessmentMembersStorage.php';
3 require_once 'Modules/IndividualAssessment/classes/Members/class.ilIndividualAssessmentMembers.php';
4 require_once 'Modules/IndividualAssessment/classes/Members/class.ilIndividualAssessmentMember.php';
5 require_once 'Modules/IndividualAssessment/classes/class.ilObjIndividualAssessment.php';
11 
12  protected $db;
13 
14  public function __construct($ilDB) {
15  $this->db = $ilDB;
16  }
17 
21  public function loadMembers(ilObjIndividualAssessment $obj) {
22  $members = new ilIndividualAssessmentMembers($obj);
23  $obj_id = $obj->getId();
24  $sql = $this->loadMembersQuery($obj_id);
25  $res = $this->db->query($sql);
26  while($rec = $this->db->fetchAssoc($res)) {
27  $members = $members->withAdditionalRecord($rec);
28  }
29  return $members;
30  }
31 
35  public function loadMember(ilObjIndividualAssessment $obj, ilObjUser $usr) {
36  $obj_id = $obj->getId();
37  $usr_id = $usr->getId();
38  $sql = 'SELECT iassme.*'
39  .' FROM iass_members iassme'
40  .' JOIN usr_data usr ON iassme.usr_id = usr.usr_id'
41  .' LEFT JOIN usr_data ex ON iassme.examiner_id = ex.usr_id'
42  .' WHERE obj_id = '.$this->db->quote($obj_id, 'integer')
43  .' AND iassme.usr_id = '.$this->db->quote($usr_id,'integer');
44  $rec = $this->db->fetchAssoc($this->db->query($sql));
45  if($rec) {
46  $member = new ilIndividualAssessmentMember($obj, $usr, $rec);
47  return $member;
48  } else {
49  throw new ilIndividualAssessmentException("invalid usr-obj combination");
50  }
51  }
52 
56  public function updateMember(ilIndividualAssessmentMember $member) {
57  $sql = 'UPDATE iass_members SET '
58  .' '.ilIndividualAssessmentMembers::FIELD_LEARNING_PROGRESS.' = '.$this->db->quote($member->LPStatus(),'text')
59  .' ,'.ilIndividualAssessmentMembers::FIELD_EXAMINER_ID.' = '.$this->db->quote($member->examinerId(),'integer')
60  .' ,'.ilIndividualAssessmentMembers::FIELD_RECORD.' = '.$this->db->quote($member->record(),'text')
61  .' ,'.ilIndividualAssessmentMembers::FIELD_INTERNAL_NOTE.' = '.$this->db->quote($member->internalNote(),'text')
62  .' ,'.ilIndividualAssessmentMembers::FIELD_NOTIFY.' = '.$this->db->quote($member->notify() ? 1 : 0,'integer')
63  .' ,'.ilIndividualAssessmentMembers::FIELD_FINALIZED.' = '.$this->db->quote($member->finalized() ? 1 : 0,'integer')
64  .' ,'.ilIndividualAssessmentMembers::FIELD_NOTIFICATION_TS.' = '.$this->db->quote($member->notificationTS(),'integer')
65  .' WHERE obj_id = '.$this->db->quote($member->assessmentId(),'integer')
66  .' AND usr_id = '.$this->db->quote($member->id(),'integer');
67  $this->db->manipulate($sql);
68  }
69 
73  public function deleteMembers(ilObjIndividualAssessment $obj) {
74  $sql = "DELETE FROM iass_members WHERE obj_id = ".$this->db->quote($obj->getId(), 'integer');
75  $this->db->manipulate($sql);
76  }
77 
81  protected function loadMembersQuery($obj_id) {
82  return 'SELECT ex.firstname as '.ilIndividualAssessmentMembers::FIELD_EXAMINER_FIRSTNAME
87  .' ,iassme.*'
88  .' FROM iass_members iassme'
89  .' JOIN usr_data usr ON iassme.usr_id = usr.usr_id'
90  .' LEFT JOIN usr_data ex ON iassme.examiner_id = ex.usr_id'
91  .' WHERE obj_id = '.$this->db->quote($obj_id, 'integer');
92  }
93 
97  public function insertMembersRecord(ilObjIndividualAssessment $iass, array $record) {
98  $sql = 'INSERT INTO iass_members (obj_id,usr_id,record,learning_progress,notify) '
99  .' VALUES ('
100  .' '.$this->db->quote($iass->getId(),'integer')
101  .' ,'.$this->db->quote($record[ilIndividualAssessmentMembers::FIELD_USR_ID],'integer')
102  .' ,'.$this->db->quote($record[ilIndividualAssessmentMembers::FIELD_RECORD],'text')
103  .' ,'.$this->db->quote($record[ilIndividualAssessmentMembers::FIELD_LEARNING_PROGRESS],'integer')
104  .' ,'.$this->db->quote(0,'integer')
105  .' )';
106  $this->db->manipulate($sql);
107  }
108 
112  public function removeMembersRecord(ilObjIndividualAssessment $iass,array $record) {
113  $sql = 'DELETE FROM iass_members'
114  .' WHERE obj_id = '.$this->db->quote($iass->getId(), 'integer')
115  .' AND usr_id = '.$this->db->quote($record[ilIndividualAssessmentMembers::FIELD_USR_ID], 'integer');
116  $this->db->manipulate($sql);
117  }
118 }
loadMember(ilObjIndividualAssessment $obj, ilObjUser $usr)
Get ilIndividualAssessmentMember-object containing meberinfo associated with $obj and $usr...
deleteMembers(ilObjIndividualAssessment $obj)
Delete entries associated with members-object.
For the purpose of streamlining the grading and learning-process status definition outside of tests...
removeMembersRecord(ilObjIndividualAssessment $iass, array $record)
Remove a membership associated with a IndividualAssessment object inside storage.$record ...
examinerId()
Get the user id of the examiner.
notificationTS()
Get the timestamp, at which the notification was sent.
finalized()
Is this membership allready finalized?
insertMembersRecord(ilObjIndividualAssessment $iass, array $record)
Create a membership inside storage.$record
loadMembers(ilObjIndividualAssessment $obj)
Get ilIndividualAssessmentMembers-object containing meberinfo associated with $obj.ilIndividualAssessmentMembers
updateMember(ilIndividualAssessmentMember $member)
Create a new storage entry for member-object.
getId()
get object id public
Create styles array
The data for the language used.
Edit the record of a user, set LP.
notify()
Will the user be notified after finalization?
global $ilDB
assessmentId()
Get the ilObjIndividualAssessment id corresponding to this membership.
id()
Get the user id corresponding to this membership.
Member administration related logic, add and remove members, get the list of all members, etc.
LPStatus()
Get the LP-status corresponding to this membership.