ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilStudyProgrammeUserProgressDB.php
Go to the documentation of this file.
1 <?php
2 require_once("./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
3 require_once("./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
4 
12 {
13 
23  public function getInstance($a_assignment_id, $a_program_id, $a_user_id)
24  {
25  return new ilStudyProgrammeUserProgress(array($a_assignment_id, $a_program_id, $a_user_id));
26  }
27 
34  public function getInstanceById($a_prgrs_id)
35  {
36  $prgrs = ilStudyProgrammeProgress::find($a_prgrs_id);
37  if ($prgrs === null) {
38  throw new ilException("Unknown progress id $a_prgrs_id.");
39  }
40  return new ilStudyProgrammeUserProgress($prgrs);
41  }
42 
50  public function getInstancesForUser($a_program_id, $a_user_id)
51  {
52  $progresses = ilStudyProgrammeProgress::where(array( "prg_id" => $a_program_id
53  , "usr_id" => $a_user_id
54  ))->get();
55  return array_values(array_map(function ($dat) {
56  return new ilStudyProgrammeUserProgress($dat);
57  }, $progresses));
58  }
59 
70  public static function getInstanceForAssignment($a_program_id, $a_assignment_id)
71  {
72  $progresses = ilStudyProgrammeProgress::where(array( "prg_id" => $a_program_id
73  , "assignment_id" => $a_assignment_id
74  ))->get();
75  if (count($progresses) == 0) {
76  require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
77  throw new ilStudyProgrammeNoProgressForAssignmentException("ilStudyProgrammeUserProgress::getInstanceForAssignment: "
78  . "Assignment '$a_assignment_id' does not belong to program "
79  . "'$a_program_id'");
80  }
81  return new ilStudyProgrammeUserProgress(array_shift($progresses));
82  }
83 
94  public static function getInstancesForAssignment($a_assignment_id)
95  {
96  $progresses = ilStudyProgrammeProgress::where(array( "assignment_id" => $a_assignment_id
97  ))->get();
98  if (count($progresses) == 0) {
99  require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
100  throw new ilStudyProgrammeNoProgressForAssignmentException("ilStudyProgrammeUserProgress::getInstancesForAssignment: "
101  . "Can't find progresses for assignment '$a_assignment_id'.");
102  }
103  return array_map(function ($dat) {
104  return new ilStudyProgrammeUserProgress($dat);
105  }, $progresses);
106  }
107 
114  public static function getInstancesForProgram($a_program_id)
115  {
116  $progresses = ilStudyProgrammeProgress::where(array( "prg_id" => $a_program_id
117  ))->get();
118  return array_values(array_map(function ($dat) {
119  return new ilStudyProgrammeUserProgress($dat);
120  }, $progresses));
121  }
122 
126  public function statusToRepr($a_status)
127  {
128  global $DIC;
129  $lng = $DIC['lng'];
130  $lng->loadLanguageModule("prg");
131 
133  return $lng->txt("prg_status_in_progress");
134  }
136  return $lng->txt("prg_status_completed");
137  }
139  return $lng->txt("prg_status_accredited");
140  }
142  return $lng->txt("prg_status_not_relevant");
143  }
144  if ($a_status == ilStudyProgrammeProgress::STATUS_FAILED) {
145  return $lng->txt("prg_status_failed");
146  }
147  throw new ilException("Unknown status: '$a_status'");
148  }
149 }
static getInstancesForProgram($a_program_id)
Get the instances for a program node.
static getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
global $DIC
Definition: saml.php:7
statusToRepr($a_status)
Get a user readable representation of a status.
static getInstancesForAssignment($a_assignment_id)
Get the instance for an assignment.
Storage implementation for ilStudyProgrammeUserProgress.
Exception is thrown when a progress for some programme node and assignment is missing.
static where($where, $operator=null)
getInstanceById($a_prgrs_id)
Get an instance by progress id.
$lng
getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
getInstance($a_assignment_id, $a_program_id, $a_user_id)
Get an instance.
Represents the progress of a user at one node of a study programme.