5require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
 
   29                        $this->progress = $a_ids_or_model;
 
   32                        if (count($a_ids_or_model) != 3) {
 
   33                                throw new ilException(
"ilStudyProgrammeUserProgress::__construct: " 
   34                                                                         .
"expected array with 3 items.");
 
   40                        $this->progress = array_shift(
 
   42                                                        ( 
"assignment_id" => $a_ids_or_model[0]
 
   43                                                        , 
"prg_id" => $a_ids_or_model[1]
 
   44                                                        , 
"usr_id" => $a_ids_or_model[2]
 
   47                if ($this->progress === 
null) {
 
   48                        throw new ilException(
"ilStudyProgrammeUserProgress::__construct: Could not find progress.");
 
   61        static public function getInstance($a_assignment_id, $a_program_id, $a_user_id) {
 
   72                $prgrs = ilStudyProgrammeProgress::find($a_prgrs_id);
 
   73                if ($prgrs === 
null) {
 
   74                        throw new ilException(
"Unknown progress id $a_prgrs_id.");
 
   88                                                        ( 
"prg_id" => $a_program_id
 
   89                                                        , 
"usr_id" => $a_user_id
 
   91                return array_values(array_map(
function($dat) {
 
  108                                                        ( 
"prg_id" => $a_program_id
 
  109                                                        , 
"assignment_id" => $a_assignment_id
 
  111                if (count($progresses) == 0) {
 
  112                        require_once(
"Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
 
  114                                                                (
"ilStudyProgrammeUserProgress::getInstanceForAssignment: " 
  115                                                                .
"Assignment '$a_assignment_id' does not belong to program " 
  133                                                        ( 
"assignment_id" => $a_assignment_id
 
  135                if (count($progresses) == 0) {
 
  136                        require_once(
"Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
 
  138                                                                (
"ilStudyProgrammeUserProgress::getInstancesForAssignment: " 
  139                                                                .
"Can't find progresses for assignment '$a_assignment_id'.");
 
  141                return array_map(
function($dat) {
 
  154                                                        ( 
"prg_id" => $a_program_id
 
  156                return array_values(array_map(
function($dat) {
 
  167                $lng->loadLanguageModule(
"prg");
 
  170                        return $lng->txt(
"prg_status_in_progress");
 
  173                        return $lng->txt(
"prg_status_completed");
 
  176                        return $lng->txt(
"prg_status_accredited");
 
  179                        return $lng->txt(
"prg_status_not_relevant");
 
  181                throw new ilException(
"Unknown status: '$a_status'");
 
  195                require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
 
  198                        throw new ilException(
"ilStudyProgrammeUserAssignment::getStudyProgramme: " 
  199                                                                 .
"could not find ref_id for program '" 
  200                                                                 .$this->progress->getNodeId().
"'.");
 
  211                require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
 
  221                return $this->progress->getId();
 
  230                return $this->progress->getNodeId();
 
  239                return $this->progress->getUserId();
 
  248                return $this->progress->getStatus();
 
  258                return $this->progress->getAmountOfPoints();
 
  271                return $this->progress->getCurrentAmountOfPoints();
 
  280                return $this->progress->getLastChange();
 
  289                return $this->progress->getLastChangeBy();
 
  298                return $this->progress->getCompletionBy();
 
  304        public function delete() {
 
  305                $this->progress->delete();
 
  323                                throw new ilException(
"ilStudyProgrammeUserProgress::markAccredited: " 
  324                                                                         .
"Can't mark as accredited since program is outdated.");
 
  329                                           ->setCompletionBy($a_user_id)
 
  332                require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
 
  349                        throw new ilException(
"Expected status ACCREDITED.");
 
  353                                           ->setCompletionBy(
null)
 
  373                                           ->setCompletionBy($a_user_id)
 
  374                                           ->setLastChangeBy($a_user_id)
 
  392                        throw new ilException(
"Expected status IN_PROGRESS.");
 
  396                                           ->setCompletionBy($a_user_id)
 
  397                                           ->setLastChangeBy($a_user_id)
 
  415                $this->progress->setAmountOfPoints($a_points)
 
  416                                           ->setLastChangeBy($a_user_id)
 
  440                $children = $prg->getChildren();
 
  441                $ass = $this->progress->getAssignmentId();
 
  442                $points = array_map(
function($child) use ($ass, $only_relevant) {
 
  443                        $relevant = $child->getProgressForAssignment($ass)->
isRelevant();
 
  455                return array_reduce($points, 
function($a, $b) { 
return $a + $b; }, 0);
 
  477                foreach ($children_progress as 
$progress) {
 
  543                $this->progress->setAmountOfPoints($prg->getPoints())
 
  567                $add = 
function($a, $b) { 
return $a + $b; };
 
  568                $get_points = 
function($child) {
 
  569                        if (!$child->isSuccessful()) {
 
  572                        return $child->getAmountOfPoints();
 
  575                $achieved_points = array_reduce(array_map($get_points, $this->
getChildrenProgress()), $add);
 
  576                if (!$achieved_points) {
 
  577                        $achieved_points = 0;
 
  582                $this->progress->setCurrentAmountOfPoints($achieved_points);
 
  585                        require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
 
  591                $this->progress->update();
 
  599                        if($child->isSuccessful()) {
 
  612                        $parent->updateStatus();
 
  633                        throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 
  634                                                                 .
"The node '".$prg->getId().
"' is not in LP_COMPLETED mode.");
 
  637                        throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 
  638                                                                 .
"This progress does belong to user '".$this->
getUserId()
 
  639                                                                 .
"' and not to user '$a_usr_id'");
 
  641                if (!in_array($a_obj_id, $prg->getLPChildrenIds())) {
 
  642                        throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 
  643                                                                 .
"Object '$a_obj_id' is no child of node '".$prg->getId().
"'.");
 
  647                                           ->setCompletionBy($a_obj_id)
 
  650                require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
 
  663                $parent = $prg->getParent();
 
  672                return $parent->getProgressForAssignment($this->progress->getAssignmentId());
 
  684                        throw new ilException(
"ilStudyProgrammeUserProgress::getChildrenProgress: " 
  685                                                                 .
"There is some problem in the implementation. This " 
  686                                                                 .
"method should only be callled for nodes in points " 
  690                $ass_id = $this->progress->getAssignmentId();
 
  691                return array_map(
function($child) use ($ass_id) {
 
  692                        return $child->getProgressForAssignment($ass_id);
 
  693                }, $prg->getChildren());
 
  705                $children = $prg->getChildren();
 
  706                $ass_id = $this->progress->getAssignmentId();
 
  708                foreach ($children as $child) {
 
  709                        $prgrs = $child->getProgressForAssignment($ass_id);
 
  710                        if (!$prgrs->isSuccessful()) {
 
  713                        $names[] = $child->getTitle();
 
  732                if ($a_node_id == $a_root_prg_id) {
 
  746                require_once(
"Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
static _getAllReferences($a_id)
get all reference ids of object
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
Exception is thrown when a progress for some programme node and assignment is missing.
Class ilStudyProgrammeProgress.
const STATUS_NOT_RELEVANT
static getInstance($a_id)
Get an instance.
Represents the progress of a user at one node of a study programme.
markNotRelevant($a_user_id)
Set the node to be not relevant for the user.
getCompletionBy()
Get the id of the user or course that lead to completion of this node.
const ACTION_SHOW_INDIVIDUAL_PLAN
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to.
static getInstance($a_assignment_id, $a_program_id, $a_user_id)
Get an instance.
markRelevant($a_user_id)
Set the node to be relevant for the user.
getMaximumPossibleAmountOfPoints($only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node.
getStatus()
Get the status of the progress.
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes.
static statusToRepr($a_status)
Get a user readable representation of a status.
getId()
Get the id of the progress.
getNamesOfCompletedOrAccreditedChildren()
Get a list with the names of the children of this node that a were completed or accredited for the gi...
__construct($a_ids_or_model)
Throws when id does not refer to a study programme progress.
canBeCompleted()
Check whether the user can achieve enough points on the subnodes to be able to complete this node.
getNodeId()
Get the id of the program node the progress belongs to.
static getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
isAccredited()
Check whether the user was accredited on this node.
unmarkAccredited()
Set the node to in progress.
const ACTION_MARK_ACCREDITED
isSuccessful()
Check whether the user was successful on this node.
setLPCompleted($a_obj_id, $a_usr_id)
Set this node to be completed due to a completed learning progress.
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
static getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
static getInstancesForAssignment($a_assignment_id)
Get the instance for an assignment.
static getPossibleActions($a_node_id, $a_root_prg_id, $a_status)
Get a list with possible actions on a progress record.
setRequiredAmountOfPoints($a_points, $a_user_id)
Set the amount of points the user is required to have to complete this node.
getAssignment()
Get the assignment this progress belongs to.
updateParentStatus()
Update the status of the parent of this node.
static getInstanceById($a_prgrs_id)
Get an instance by progress id.
getUserId()
Get the id of the user who is assigned.
getAmountOfPoints()
Get the amount of points needed to complete the node.
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.
getStudyProgramme()
Get the program node where this progress belongs to was made.
static getInstancesForProgram($a_program_id)
Get the instances for a program node.
const ACTION_UNMARK_ACCREDITED
getParentProgress()
Get the progress on the parent node for the same assignment this progress belongs to.
markAccredited($a_user_id)
Mark this progress as accredited.
updateFromProgramNode()
Update the progress from its program node.
isRelevant()
Check whether this node is relevant for the user.
getLastChange()
Get the timestamp when the last change was made on this progress.
getLastChangeBy()
Get the id of the user who did the last change on this progress.