ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Exercise\Settings\SettingsGUI Class Reference
+ Collaboration diagram for ILIAS\Exercise\Settings\SettingsGUI:

Public Member Functions

 __construct (protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id)
 
 executeCommand ()
 

Protected Member Functions

 edit ()
 
 getEditForm ()
 
 save ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Exercise\Settings\SettingsGUI::__construct ( protected InternalDataService  $data,
protected InternalDomainService  $domain,
protected InternalGUIService  $gui,
protected int  $obj_id 
)

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

35 {
36 }

Member Function Documentation

◆ edit()

ILIAS\Exercise\Settings\SettingsGUI::edit ( )
protected

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

52 : void
53 {
54 $mt = $this->gui->ui()->mainTemplate();
55 $form = $this->getEditForm();
56 $mt->setContent($form->render());
57 }

References ILIAS\Exercise\Settings\SettingsGUI\getEditForm().

+ Here is the call graph for this function:

◆ executeCommand()

ILIAS\Exercise\Settings\SettingsGUI::executeCommand ( )

Definition at line 38 of file class.SettingsGUI.php.

38 : void
39 {
40 $ctrl = $this->gui->ctrl();
41 $next_class = $ctrl->getNextClass($this);
42 $cmd = $ctrl->getCmd("edit");
43
44 switch ($next_class) {
45 default:
46 if (in_array($cmd, ["edit", "save"])) {
47 $this->$cmd();
48 }
49 }
50 }

◆ getEditForm()

ILIAS\Exercise\Settings\SettingsGUI::getEditForm ( )
protected

Definition at line 59 of file class.SettingsGUI.php.

59 : FormAdapterGUI
60 {
61 $settings = $this->domain->exerciseSettings()->getByObjId($this->obj_id);
62 $random_manager = $this->domain->assignment()->randomAssignments(new \ilObjExercise($this->obj_id, false));
63 $lng = $this->domain->lng();
64
65 $mand = \ilExAssignment::countMandatory($this->obj_id);
66 $pass_nr_min = max($mand, 1);
67 $pass_nr_max = \ilExAssignment::count($this->obj_id);
68
69 $form = $this->gui
70 ->form(self::class, "save")
71 ->section("general", $lng->txt('exc_edit_exercise'))
72 ->addStdTitleAndDescription($this->obj_id, "exc")
73 ->section("avail", $lng->txt('rep_activation_availability'))
74 ->addOnline($this->obj_id, "exc")
75 ->section("pres", $lng->txt('obj_presentation'))
76 ->addStdTile($this->obj_id, "exc");
77
78 $form = $form
79 ->section("pass_exc", $lng->txt('exc_passing_exc'))
80 ->switch(
81 "pass_mode",
82 $lng->txt("exc_pass_mode"),
83 (!$random_manager->canBeDeactivated() && $settings->getPassMode() == \ilObjExercise::PASS_MODE_RANDOM)
84 ? $lng->txt("exc_pass_mode_not_changeable_info") . " " .
85 implode(" ", $random_manager->getDeniedDeactivationReasons())
86 : "",
87 $settings->getPassMode()
88 )
89 ->group(
91 $lng->txt("exc_pass_all"),
92 $lng->txt("exc_pass_all_info")
93 )
94 ->group(
96 $lng->txt("exc_pass_minimum_nr"),
97 $lng->txt("exc_pass_minimum_nr_info")
98 )
99 ->number(
100 "pass_nr",
101 $lng->txt("exc_min_nr"),
102 $lng->txt("exc_min_nr_info"),
103 $settings->getPassNr(),
104 $pass_nr_min,
105 $pass_nr_max
106 )->required()
107 ->group(
109 $lng->txt("exc_random_selection"),
110 !$random_manager->canBeActivated() && $settings->getPassMode() != \ilObjExercise::PASS_MODE_RANDOM
111 ? $lng->txt("exc_random_selection_not_changeable_info") . " " . implode(
112 " ",
113 $random_manager->getDeniedActivationReasons()
114 )
115 : $lng->txt("exc_random_selection_info"),
116 (!$random_manager->canBeActivated() && $settings->getPassMode() != \ilObjExercise::PASS_MODE_RANDOM)
117 )
118 ->number(
119 "nr_random_mand",
120 $lng->txt("exc_nr_random_mand"),
121 "",
122 $settings->getNrMandatoryRandom(),
123 1,
124 \ilExAssignment::count($this->obj_id)
125 )
126 ->required()
127 ->end()
128 ->disabled((!$random_manager->canBeDeactivated() && $settings->getPassMode() == \ilObjExercise::PASS_MODE_RANDOM));
129
130 $form = $form
131 ->switch(
132 "completion_by_submission",
133 $lng->txt("exc_passed_status_determination"),
134 "",
135 $settings->getCompletionBySubmission() ? "1" : "0"
136 )
137 ->group("0", $lng->txt("exc_completion_by_tutor"))
138 ->group(
139 "1",
140 $lng->txt("exc_completion_by_submission"),
141 $lng->txt("exc_completion_by_submission_info")
142 )->end();
143
144 $form = $form
145 ->section("publishing", $lng->txt('exc_publishing'))
146 ->checkbox(
147 "show_submissions",
148 $lng->txt("exc_show_submissions"),
149 $lng->txt("exc_show_submissions_info"),
150 $settings->getShowSubmissions()
151 );
152
153 $form = $form
154 ->section("notification", $lng->txt('exc_notification'))
155 ->checkbox(
156 "notification",
157 $lng->txt("exc_submission_notification"),
158 $lng->txt("exc_submission_notification_info"),
161 $this->domain->user()->getId(),
162 $this->obj_id
163 )
164 );
165
166 $form = $form
167 ->section("feedback", $lng->txt('exc_feedback'))
168 ->checkbox(
169 "exc_settings_feedback_mail",
170 $lng->txt("exc_settings_feedback_mail"),
171 $lng->txt("exc_settings_feedback_mail_info"),
172 $settings->hasTutorFeedbackMail()
173 )
174 ->checkbox(
175 "exc_settings_feedback_file",
176 $lng->txt("exc_settings_feedback_file"),
177 $lng->txt("exc_settings_feedback_file_info"),
178 $settings->hasTutorFeedbackFile()
179 )
180 ->checkbox(
181 "exc_settings_feedback_text",
182 $lng->txt("exc_settings_feedback_text"),
183 $lng->txt("exc_settings_feedback_text_info"),
184 $settings->hasTutorFeedbackText()
185 );
186
187 $form = $form->addAdditionalFeatures(
188 $this->obj_id,
189 [
191 ]
192 );
193
194 return $form;
195 }
static count(int $a_ex_id)
static countMandatory(int $a_ex_id)
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
Class ilObjExercise.
global $lng
Definition: privfeed.php:31

References $lng, ilExAssignment\count(), ilExAssignment\countMandatory(), ilObjectServiceSettingsGUI\CUSTOM_METADATA, ilNotification\hasNotification(), ilObjExercise\PASS_MODE_ALL, ilObjExercise\PASS_MODE_NR, ilObjExercise\PASS_MODE_RANDOM, and ilNotification\TYPE_EXERCISE_SUBMISSION.

Referenced by ILIAS\Exercise\Settings\SettingsGUI\edit(), and ILIAS\Exercise\Settings\SettingsGUI\save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ILIAS\Exercise\Settings\SettingsGUI::save ( )
protected

Definition at line 197 of file class.SettingsGUI.php.

197 : void
198 {
199 $mt = $this->gui->ui()->mainTemplate();
200 $form = $this->getEditForm();
201 $ctrl = $this->gui->ctrl();
202 $lng = $this->domain->lng();
203
204 $old_settings = $this->domain->exerciseSettings()->getByObjId($this->obj_id);
205
206 if ($form->isValid()) {
207
208 $form->saveStdTitleAndDescription($this->obj_id, "exc");
209 $form->saveStdTile($this->obj_id, "exc");
210 $form->saveOnline($this->obj_id, "exc");
211
212 $feedback = 0;
213 $feedback += $form->getData("exc_settings_feedback_mail")
215 : 0;
216 $feedback += $form->getData("exc_settings_feedback_file")
218 : 0;
219 $feedback += $form->getData("exc_settings_feedback_text")
221 : 0;
222 $settings = $this->data->settings(
223 $this->obj_id,
224 $old_settings->getInstruction(), // obsolete?
225 $old_settings->getTimeStamp(), // obsolete?
226 $form->getData("pass_mode"),
227 (int) $form->getData("nr_random_mand"),
228 (int) $form->getData("pass_nr"),
229 (bool) $form->getData("show_submissions"),
230 (bool) $form->getData("completion_by_submission"),
231 (int) $old_settings->getCertificateVisibility(), // obsolete?
232 $feedback
233 );
234 $this->domain->exerciseSettings()->update($settings);
235
238 $this->domain->user()->getId(),
239 $this->obj_id,
240 (bool) $form->getData("notification")
241 );
242 $form->saveAdditionalFeatures(
243 $this->obj_id,
245 );
246
247 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
248 $ctrl->redirectByClass(self::class, "edit");
249 } else {
250 $mt = $this->gui->ui()->mainTemplate();
251 $mt->setContent($form->render());
252 }
253 }
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.

References $lng, ilObjectServiceSettingsGUI\CUSTOM_METADATA, ILIAS\Exercise\Settings\SettingsGUI\getEditForm(), ilNotification\setNotification(), ilObjExercise\TUTOR_FEEDBACK_FILE, ilObjExercise\TUTOR_FEEDBACK_MAIL, ilObjExercise\TUTOR_FEEDBACK_TEXT, and ilNotification\TYPE_EXERCISE_SUBMISSION.

+ Here is the call graph for this function:

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