Skip to content

Commit

Permalink
PRG: 42557, completion_by should reference course directly
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen authored and lukastocker committed Dec 3, 2024
1 parent 1b94c73 commit 3675b9e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,9 @@ public function getCompletedCourses(int $usr_id): array
, "prg_obj_id" => $containing_prg->getId()
, "crsr_ref_id" => (int) $ref["child"]
, "crsr_id" => (int) $ref["obj_id"]
, "crs_ref_id" => (int) $crs_ref_id
, "crs_id" => (int) $crs_id

, "title" => ilContainerReference::_lookupTitle((int) $ref["obj_id"])
];
}
Expand Down Expand Up @@ -1839,11 +1842,12 @@ public function acknowledgeCourses(
$acting_usr_id = $this->getLoggedInUserId();
$assignment = $this->assignment_repository->get($assignment_id);
foreach ($nodes as $nodeinfo) {
[$node_obj_id, $courseref_obj_id] = $nodeinfo;
[$node_obj_id, $course_obj_id] = $nodeinfo;

$assignment = $assignment->succeed(
$this->settings_repository,
$node_obj_id,
$courseref_obj_id
$course_obj_id
);

$msg = sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public function viewCompletedCourses(array $assignments): Form
);
$options = [];
foreach ($completed_crss as $opt) {
$options[implode(';', [$ass->getId(), $opt['prg_obj_id'],$opt['crsr_id']])] = $opt['title'];
$options[implode(';', [$ass->getId(), $opt['prg_obj_id'],$opt['crs_id']])] = $opt['title'];
}

$completed_courses[] = $this->ui_factory->input()->field()->multiselect($label, $options);
Expand Down Expand Up @@ -728,11 +728,11 @@ public function confirmedAcknowledgeCourses()
if ($data) {
$acknowledge = [];
foreach ($data as $ack) {
[$assignment_id, $node_obj_id, $courseref_obj_id] = $ack;
[$assignment_id, $node_obj_id, $course_obj_id] = $ack;
if (! array_key_exists($assignment_id, $acknowledge)) {
$acknowledge[$assignment_id] = [];
}
$acknowledge[$assignment_id][] = [(int) $node_obj_id, (int) $courseref_obj_id];
$acknowledge[$assignment_id][] = [(int) $node_obj_id, (int) $course_obj_id];
}
foreach ($acknowledge as $ass_id => $nodes) {
$this->object->acknowledgeCourses(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ protected function fillRow($row): void
$out = [];
foreach ($completion_by_obj_ids as $completion_by_obj_id) {
$type = ilObject::_lookupType($completion_by_obj_id);
if ($type === 'crsr') {
$target_obj_id = ilContainerReference::_lookupTargetId($completion_by_obj_id);
$out[] = $this->getCompletionLink($target_obj_id, $completion_by);
if ($type === 'crs') {
$out[] = $this->getCompletionLink($completion_by_obj_id, $completion_by);
} else {
$target_obj_id = $completion_by_obj_id;
$out[] = $this->getCompletionLink(
Expand Down Expand Up @@ -350,7 +349,7 @@ protected function getMultiCommands(): array
'markAccreditedMulti' => $this->lng->txt('prg_multi_mark_accredited'),
'unmarkAccreditedMulti' => $this->lng->txt('prg_multi_unmark_accredited'),
];
if($this->prg->isCertificateActive()) {
if ($this->prg->isCertificateActive()) {
$permissions_for_edit_individual_plan['updateCertificateMulti'] = $this->lng->txt('prg_multi_update_certificate');
$permissions_for_edit_individual_plan['removeCertificateMulti'] = $this->lng->txt('prg_multi_remove_certificate');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,15 @@ public static function lookupTitle(int $obj_id): string
return ilObject::_lookupTitle($obj_id);
case 'prg':
$title = ilObject::_lookupTitle($obj_id);
if(ilObject::_isInTrash(ilObjStudyProgramme::getRefIdFor($obj_id))) {
if (ilObject::_isInTrash(ilObjStudyProgramme::getRefIdFor($obj_id))) {
return sprintf('(%s)', $title);
}
return $title;
case 'crsr':
$title = ilContainerReference::_lookupTitle($obj_id);
$target_obj_id = ilContainerReference::_lookupTargetId($obj_id);
$refs = ilObject::_getAllReferences($target_obj_id);
case 'crs':
$title = ilObject::_lookupTitle($obj_id);
$refs = ilObject::_getAllReferences($obj_id);
$target_ref_id = array_shift($refs) ?? null;
if($target_ref_id === null || ilObject::_isInTrash($target_ref_id)) {
if ($target_ref_id === null || ilObject::_isInTrash($target_ref_id)) {
return sprintf('(%s)', $title);
}
return $title;
Expand Down

0 comments on commit 3675b9e

Please sign in to comment.