ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExerciseDerivedTaskProvider Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilExerciseDerivedTaskProvider:
+ Collaboration diagram for ilExerciseDerivedTaskProvider:

Public Member Functions

 __construct (ilTaskService $task_service, ilAccess $access, ilLanguage $lng, ilExerciseDerivedTaskAction $derived_task_action, \ILIAS\Exercise\PermanentLink\PermanentLinkManager $link_manager)
 
 isActive ()
 Is provider active? More...
 
 getTasks (int $user_id)
 

Protected Member Functions

 getFirstRefIdWithPermission (string $perm, int $obj_id, int $user_id)
 

Protected Attributes

ILIAS Exercise PermanentLink PermanentLinkManager $link_manager
 
ilTaskService $task_service
 
ilExerciseDerivedTaskAction $task_action
 
ilAccess $access
 
ilLanguage $lng
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Exercise derived task provider

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilExerciseDerivedTaskProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ilExerciseDerivedTaskProvider::__construct ( ilTaskService  $task_service,
ilAccess  $access,
ilLanguage  $lng,
ilExerciseDerivedTaskAction  $derived_task_action,
\ILIAS\Exercise\PermanentLink\PermanentLinkManager  $link_manager 
)

Definition at line 32 of file class.ilExerciseDerivedTaskProvider.php.

References $access, $link_manager, $lng, $task_service, ILIAS\Repository\access(), and ILIAS\Repository\lng().

38  {
39  $this->access = $access;
40  $this->task_service = $task_service;
41  $this->task_action = $derived_task_action;
42  $this->lng = $lng;
43  $this->link_manager = $link_manager;
44 
45  $this->lng->loadLanguageModule("exc");
46  }
ILIAS Exercise PermanentLink PermanentLinkManager $link_manager
+ Here is the call graph for this function:

Member Function Documentation

◆ getFirstRefIdWithPermission()

ilExerciseDerivedTaskProvider::getFirstRefIdWithPermission ( string  $perm,
int  $obj_id,
int  $user_id 
)
protected

Definition at line 110 of file class.ilExerciseDerivedTaskProvider.php.

References $access, $ref_id, ilObject\_getAllReferences(), and ilAccess\checkAccessOfUser().

Referenced by getTasks().

114  : int {
116 
117  foreach (ilObject::_getAllReferences($obj_id) as $ref_id) {
118  if ($access->checkAccessOfUser($user_id, $perm, "", $ref_id)) {
119  return $ref_id;
120  }
121  }
122  return 0;
123  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=0, ?int $a_tree_id=0)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTasks()

ilExerciseDerivedTaskProvider::getTasks ( int  $user_id)
Exceptions
ilExcUnknownAssignmentTypeException
Returns
[]

Implements ilDerivedTaskProvider.

Definition at line 57 of file class.ilExerciseDerivedTaskProvider.php.

References $lng, $ref_id, $user_id, getFirstRefIdWithPermission(), ilExcAssMemberState\getInstanceByIds(), ILIAS\Repository\int(), and ilLanguage\txt().

57  : array
58  {
59  $lng = $this->lng;
60 
61  $tasks = [];
62 
63  // open assignments
64  foreach ($this->task_action->getOpenAssignmentsOfUser($user_id) as $ass) {
65  $ref_id = $this->getFirstRefIdWithPermission("read", $ass->getExerciseId(), $user_id);
66  if ($ref_id == 0) {
67  continue;
68  }
69  $state = ilExcAssMemberState::getInstanceByIds($ass->getId(), $user_id);
70  $title = str_replace("%1", $ass->getTitle(), $lng->txt("exc_task_submission"));
71  $tasks[] = $this->task_service->derived()->factory()->task(
72  $title,
73  $ref_id,
74  $state->getOfficialDeadline(),
75  (int) $state->getGeneralStart()
76  )->withUrl($this->link_manager->getPermanentLink($ref_id, $ass->getId()));
77  }
78 
79  // open peer feedbacks
80  foreach ($this->task_action->getOpenPeerReviewsOfUser($user_id) as $ass) {
81  $ref_id = $this->getFirstRefIdWithPermission("read", $ass->getExerciseId(), $user_id);
82  if ($ref_id == 0) {
83  continue;
84  }
85  $state = ilExcAssMemberState::getInstanceByIds($ass->getId(), $user_id);
86  $title = str_replace("%1", $ass->getTitle(), $lng->txt("exc_task_peer_feedback"));
87  $tasks[] = $this->task_service->derived()->factory()->task(
88  $title,
89  $ref_id,
90  $state->getPeerReviewDeadline(),
91  0
92  );
93  }
94 
95  // open gradings
96  foreach ($this->task_action->getOpenGradingsOfUser($user_id) as $ass) {
97  $ref_id = $this->getFirstRefIdWithPermission("write", $ass->getExerciseId(), $user_id);
98  if ($ref_id == 0) {
99  continue;
100  }
101  $title = str_replace("%1", $ass->getTitle(), $lng->txt("exc_task_grading"));
102  $tasks[] = $this->task_service->derived()->factory()->task($title, $ref_id, 0, 0);
103  }
104 
105  return $tasks;
106  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$ref_id
Definition: ltiauth.php:65
static getInstanceByIds(int $a_ass_id, int $a_user_id=0)
getFirstRefIdWithPermission(string $perm, int $obj_id, int $user_id)
+ Here is the call graph for this function:

◆ isActive()

ilExerciseDerivedTaskProvider::isActive ( )

Is provider active?

Implements ilDerivedTaskProvider.

Definition at line 48 of file class.ilExerciseDerivedTaskProvider.php.

48  : bool
49  {
50  return true;
51  }

Field Documentation

◆ $access

ilAccess ilExerciseDerivedTaskProvider::$access
protected

◆ $link_manager

ILIAS Exercise PermanentLink PermanentLinkManager ilExerciseDerivedTaskProvider::$link_manager
protected

Definition at line 26 of file class.ilExerciseDerivedTaskProvider.php.

Referenced by __construct().

◆ $lng

ilLanguage ilExerciseDerivedTaskProvider::$lng
protected

Definition at line 30 of file class.ilExerciseDerivedTaskProvider.php.

Referenced by __construct(), and getTasks().

◆ $task_action

ilExerciseDerivedTaskAction ilExerciseDerivedTaskProvider::$task_action
protected

Definition at line 28 of file class.ilExerciseDerivedTaskProvider.php.

◆ $task_service

ilTaskService ilExerciseDerivedTaskProvider::$task_service
protected

Definition at line 27 of file class.ilExerciseDerivedTaskProvider.php.

Referenced by __construct().


The documentation for this class was generated from the following file: