ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Survey\Tasks\DerivedTaskProvider Class Reference

Exercise derived task provider. More...

+ Inheritance diagram for ILIAS\Survey\Tasks\DerivedTaskProvider:
+ Collaboration diagram for ILIAS\Survey\Tasks\DerivedTaskProvider:

Public Member Functions

 __construct (\ilTaskService $task_service, \ilAccess $access, \ilLanguage $lng)
 Constructor. More...
 
 isActive ()
 Is provider active?
Returns
bool
More...
 
 getTasks (int $user_id)
 Get providers.
Parameters
int$user_id
Returns
ilDerivedTask[]
More...
 

Protected Member Functions

 getFirstRefIdWithPermission ($perm, int $obj_id, int $user_id)
 Get first ref id for an object id with permission. More...
 

Protected Attributes

 $task_service
 
 $access
 
 $lng
 
 $inv_manager
 
 $set_repo
 
 $svy_360_manager
 

Detailed Description

Exercise derived task provider.

Author
.de

Definition at line 17 of file class.DerivedTaskProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Survey\Tasks\DerivedTaskProvider::__construct ( \ilTaskService  $task_service,
\ilAccess  $access,
\ilLanguage  $lng 
)

Constructor.

Definition at line 52 of file class.DerivedTaskProvider.php.

References ILIAS\Survey\Tasks\DerivedTaskProvider\$access, ILIAS\Survey\Tasks\DerivedTaskProvider\$lng, and ILIAS\Survey\Tasks\DerivedTaskProvider\$task_service.

53  {
54  $this->access = $access;
55  $this->task_service = $task_service;
56  $this->lng = $lng;
57 
58  $this->lng->loadLanguageModule("svy");
59 
60  $this->inv_manager = new InvitationsManager();
61  $this->set_repo = new SettingsDBRepository();
62  $this->svy_360_manager = new Survey360Manager();
63  }

Member Function Documentation

◆ getFirstRefIdWithPermission()

ILIAS\Survey\Tasks\DerivedTaskProvider::getFirstRefIdWithPermission (   $perm,
int  $obj_id,
int  $user_id 
)
protected

Get first ref id for an object id with permission.

Parameters
int$obj_id
int$user_id
Returns
int

Definition at line 150 of file class.DerivedTaskProvider.php.

References ILIAS\Survey\Tasks\DerivedTaskProvider\$access, and ilObject\_getAllReferences().

Referenced by ILIAS\Survey\Tasks\DerivedTaskProvider\getTasks().

150  : int
151  {
153 
154  foreach (\ilObject::_getAllReferences($obj_id) as $ref_id) {
155  if ($access->checkAccessOfUser($user_id, $perm, "", $ref_id)) {
156  return $ref_id;
157  }
158  }
159  return 0;
160  }
static _getAllReferences($a_id)
get all reference ids of object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTasks()

ILIAS\Survey\Tasks\DerivedTaskProvider::getTasks ( int  $user_id)

Get providers.

Parameters
int$user_id
Returns
ilDerivedTask[]

Implements ilDerivedTaskProvider.

Definition at line 76 of file class.DerivedTaskProvider.php.

References ILIAS\Survey\Tasks\DerivedTaskProvider\$access, ILIAS\Survey\Tasks\DerivedTaskProvider\$lng, ilObject\_lookupTitle(), and ILIAS\Survey\Tasks\DerivedTaskProvider\getFirstRefIdWithPermission().

76  : array
77  {
78  $lng = $this->lng;
79 
80  $tasks = [];
81 
82  // open assignments
83  $survey_ids = $this->inv_manager->getOpenInvitationsOfUser($user_id);
84  if (count($survey_ids) > 0) {
85  $obj_ids = $this->set_repo->getObjIdsForSurveyIds($survey_ids);
86  $access = $this->set_repo->getAccessSettings($survey_ids);
87  foreach ($obj_ids as $survey_id => $obj_id) {
88  $ref_id = $this->getFirstRefIdWithPermission("read", $obj_id, $user_id);
89  if ($ref_id > 0) {
90  $title = str_replace("%1", \ilObject::_lookupTitle($obj_id), $lng->txt("svy_finish_survey"));
91  $tasks[] = $this->task_service->derived()->factory()->task(
92  $title,
93  $ref_id,
94  (int) $access[$survey_id]->getEndDate(),
95  (int) $access[$survey_id]->getStartDate()
96  );
97  }
98  }
99  }
100 
101  // open raters in 360
102  $survey_ids = $this->svy_360_manager->getOpenSurveysForRater($user_id);
103  if (count($survey_ids) > 0) {
104  $obj_ids = $this->set_repo->getObjIdsForSurveyIds($survey_ids);
105  $access = $this->set_repo->getAccessSettings($survey_ids);
106  foreach ($obj_ids as $survey_id => $obj_id) {
107  $ref_id = $this->getFirstRefIdWithPermission("read", $obj_id, $user_id);
108  if ($ref_id > 0) {
109  $title = str_replace("%1", \ilObject::_lookupTitle($obj_id), $lng->txt("svy_finish_survey"));
110  $tasks[] = $this->task_service->derived()->factory()->task(
111  $title,
112  $ref_id,
113  (int) $access[$survey_id]->getEndDate(),
114  (int) $access[$survey_id]->getStartDate()
115  );
116  }
117  }
118  }
119 
120  // unclosed 360 survey of appraisee
121  $survey_ids = $this->svy_360_manager->getOpenSurveysForAppraisee($user_id);
122  if (count($survey_ids) > 0) {
123  $obj_ids = $this->set_repo->getObjIdsForSurveyIds($survey_ids);
124  $access = $this->set_repo->getAccessSettings($survey_ids);
125  foreach ($obj_ids as $survey_id => $obj_id) {
126  $ref_id = $this->getFirstRefIdWithPermission("read", $obj_id, $user_id);
127  if ($ref_id > 0) {
128  $title = str_replace("%1", \ilObject::_lookupTitle($obj_id), $lng->txt("svy_finish_survey"));
129  $tasks[] = $this->task_service->derived()->factory()->task(
130  $title,
131  $ref_id,
132  (int) $access[$survey_id]->getEndDate(),
133  (int) $access[$survey_id]->getStartDate()
134  );
135  }
136  }
137  }
138 
139  return $tasks;
140  }
getFirstRefIdWithPermission($perm, int $obj_id, int $user_id)
Get first ref id for an object id with permission.
static _lookupTitle($a_id)
lookup object title
+ Here is the call graph for this function:

◆ isActive()

ILIAS\Survey\Tasks\DerivedTaskProvider::isActive ( )

Is provider active?

Returns
bool

Implements ilDerivedTaskProvider.

Definition at line 68 of file class.DerivedTaskProvider.php.

68  : bool
69  {
70  return true;
71  }

Field Documentation

◆ $access

◆ $inv_manager

ILIAS\Survey\Tasks\DerivedTaskProvider::$inv_manager
protected

Definition at line 37 of file class.DerivedTaskProvider.php.

◆ $lng

ILIAS\Survey\Tasks\DerivedTaskProvider::$lng
protected

◆ $set_repo

ILIAS\Survey\Tasks\DerivedTaskProvider::$set_repo
protected

Definition at line 42 of file class.DerivedTaskProvider.php.

◆ $svy_360_manager

ILIAS\Survey\Tasks\DerivedTaskProvider::$svy_360_manager
protected

Definition at line 47 of file class.DerivedTaskProvider.php.

◆ $task_service

ILIAS\Survey\Tasks\DerivedTaskProvider::$task_service
protected

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