From 2cf4503d490ff961bade54ef9368952bc058407b Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 14:52:46 +0100 Subject: [PATCH 01/69] Compare submission first implementation --- .../classes/class.ilExerciseManagementGUI.php | 86 +++++++++++++++++-- .../class.ilExerciseSubmissionTableGUI.php | 6 ++ 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index be15aeeff7c8..6c603b64a35b 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -515,10 +515,7 @@ function listTextAssignmentObject() { $this->initFilter(); - //tabs - $this->tabs_gui->clearTargets(); - $this->tabs_gui->setBackTarget($this->lng->txt("back"), - $this->ctrl->getLinkTarget($this, "members")); + $this->setBackToMembers(); $button_print = $this->ui_factory->button()->standard($this->lng->txt('print'), "#") ->withOnLoadCode(function($id) { @@ -583,6 +580,72 @@ function listTextAssignmentObject() $this->tpl->setContent($report_html); } + /** + * TODO -> Deal with the redirection after update the grade via action button. + * + * Extract the data collection to another method. List and compare use this. DRY + */ + public function compareTextAssignmentsObject() + { + $this->setBackToMembers(); + + //TODO -> Find best way to create title for this list of panels. + $report_html = ""; + //TODO create proper title. + $report_title = $this->lng->txt("exc_compare_submissions"); + $report_html .= "

".$report_title."

"; + + //peer review object for this assignment + $peer_review = new ilExPeerReview($this->assignment); + + //participant ids selected via checkboxes + $participants = array_keys($this->getMultiActionUserIds()); + + foreach($participants as $participant_id) + { + + $submission = new ilExSubmission($this->assignment,$participant_id); + + //submission data array + $file = reset($submission->getFiles()); + + //user data + //TODO refactor the data collection to a method. + $user = new ilObjUser($file["user_id"]); + $uname = $user->getFirstname()." ".$user->getLastname(); + + $data = array( + "uid" => $file["user_id"], + "uname" => $uname, + "udate" => $file["ts"], + "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1) // mob id to mob src + ); + + //get data peer and assign it + $data["peer"] = array(); + foreach($peer_review->getPeerReviewsByPeerId($file['user_id']) as $key => $value) + { + $data["peer"][] = $value['giver_id']; + } + + $data["fb_received"] = count($data["peer"]); + $data["fb_given"] = $peer_review->countGivenFeedback(true, $file["user_id"]); + + $submission_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); + + if(is_array($submission_data)) + { + $data = array_merge($data, $submission_data); + + $report_html .= $this->getReportPanel($data); + $total_reports++; + + } + } + + $this->tpl->setContent($report_html); + } + public function getReportPanel($a_data) { $modal = $this->getEvaluationModal($a_data); @@ -627,7 +690,9 @@ public function getReportPanel($a_data) ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get()))))->withActions($actions); $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); - if(array_key_exists("peer", $a_data) && $this->filter["feedback"] == "submission_feedback") + //if(array_key_exists("peer", $a_data) && $this->filter["feedback"] == "submission_feedback") + //TODO READ WHAT IS THIS SUBMISSION FEEDBACK DOING + if(array_key_exists("peer", $a_data) { $feedback_tpl->setCurrentBlock("feedback"); foreach($a_data["peer"] as $peer_id) @@ -2160,5 +2225,16 @@ function initFilter() $submit->setCommand("listTextAssignment"); $this->toolbar->addButtonInstance($submit); } + + /** + * Add the Back link to the tabs. (used in submission list and submission compare) + */ + protected function setBackToMembers() + { + //tabs + $this->tabs_gui->clearTargets(); + $this->tabs_gui->setBackTarget($this->lng->txt("back"), + $this->ctrl->getLinkTarget($this, "members")); + } } diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index d4d718b2dc85..44241be13d6f 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -97,6 +97,12 @@ function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item // multi actions $this->addMultiCommand("saveStatusSelected", $this->lng->txt("exc_save_selected")); + + // TODO get rid of the constant from ilExAssignment. Get this value from ilExAssignmentTypes + if($this->mode == self::MODE_BY_ASSIGNMENT && $this->ass->getType() == ilExAssignment::TYPE_TEXT) + { + $this->addMultiCommand("compareTextAssignments",$this->lng->txt("exc_compare_text_submissions")); + } $this->setFormName("ilExcIDlForm"); From 697fe023dc6cbeb0161dd8c085a63ffb2d57148e Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 15:17:26 +0100 Subject: [PATCH 02/69] missing parenthesis --- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 6c603b64a35b..5a386ab0c92c 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -692,7 +692,7 @@ public function getReportPanel($a_data) $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); //if(array_key_exists("peer", $a_data) && $this->filter["feedback"] == "submission_feedback") //TODO READ WHAT IS THIS SUBMISSION FEEDBACK DOING - if(array_key_exists("peer", $a_data) + if(array_key_exists("peer", $a_data)) { $feedback_tpl->setCurrentBlock("feedback"); foreach($a_data["peer"] as $peer_id) From c93a2e5be2deea0fb8b5c2d546278aa4be12aadb Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 15:40:23 +0100 Subject: [PATCH 03/69] Fix filter feedback --- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 5a386ab0c92c..ca74bb561603 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -690,9 +690,8 @@ public function getReportPanel($a_data) ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get()))))->withActions($actions); $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); - //if(array_key_exists("peer", $a_data) && $this->filter["feedback"] == "submission_feedback") - //TODO READ WHAT IS THIS SUBMISSION FEEDBACK DOING - if(array_key_exists("peer", $a_data)) + //if no feedback filter the feedback is displayed. Can be list submissions or compare submissions. + if(array_key_exists("peer", $a_data) && ($this->filter["feedback"] == "submission_feedback") || $this->filter["feedback"] == "") { $feedback_tpl->setCurrentBlock("feedback"); foreach($a_data["peer"] as $peer_id) @@ -2189,8 +2188,6 @@ function initFilter() if($_POST["filter_feedback"]) { $this->filter["feedback"] = trim(ilUtil::stripSlashes($_POST["filter_feedback"])); - } else { - $this->filter["feedback"] = "submission_feedback"; } $this->lng->loadLanguageModule("search"); From a2ee6b52322a8e4dd6572e1135a93cd257eaa066 Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 15:44:26 +0100 Subject: [PATCH 04/69] changes in Feedback filter constants --- .../Exercise/classes/class.ilExerciseManagementGUI.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index ca74bb561603..a003d4cda7cc 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -66,8 +66,8 @@ class ilExerciseManagementGUI const VIEW_PARTICIPANT = 2; const VIEW_GRADES = 3; - const FEEDBACK_ONLY_SUBMISSION = "submission_feedback"; - const FEEDBACK_FULL_SUBMISSION = "submission_only"; + const FEEDBACK_ONLY_SUBMISSION = "submission_only"; + const FEEDBACK_FULL_SUBMISSION = "submission_feedback"; const GRADE_NOT_GRADED = "notgraded"; const GRADE_PASSED = "passed"; @@ -691,7 +691,7 @@ public function getReportPanel($a_data) $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); //if no feedback filter the feedback is displayed. Can be list submissions or compare submissions. - if(array_key_exists("peer", $a_data) && ($this->filter["feedback"] == "submission_feedback") || $this->filter["feedback"] == "") + if(array_key_exists("peer", $a_data) && ($this->filter["feedback"] == self::FEEDBACK_FULL_SUBMISSION) || $this->filter["feedback"] == "") { $feedback_tpl->setCurrentBlock("feedback"); foreach($a_data["peer"] as $peer_id) @@ -2206,8 +2206,8 @@ function initFilter() $si_feedback = new ilSelectInputGUI($this->lng->txt("feedback"), "filter_feedback"); $options = array( - "submission_feedback" => $this->lng->txt("submissions_feedback"), - "submission_only" => $this->lng->txt("submissions_only") + self::FEEDBACK_FULL_SUBMISSION => $this->lng->txt("submissions_feedback"), + self::FEEDBACK_ONLY_SUBMISSION => $this->lng->txt("submissions_only") ); $si_feedback->setOptions($options); $si_feedback->setValue($this->filter["feedback"]); From 72aab7b5ac04023d6598aeab96543856d8df767b Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 16:24:20 +0100 Subject: [PATCH 05/69] Refactor: avoid duplicate code when gathering data from reviews --- .../classes/class.ilExerciseManagementGUI.php | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index a003d4cda7cc..b63ecba36e20 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -525,8 +525,8 @@ function listTextAssignmentObject() $this->toolbar->addComponent($button_print); //retrieve data - $peer_review = new ilExPeerReview($this->assignment); - $peer_data = $peer_review->getAllPeerReviews(); + //$peer_review = new ilExPeerReview($this->assignment); + //$peer_data = $peer_review->getAllPeerReviews(); include_once "Services/User/classes/class.ilUserUtil.php"; include_once "Services/RTE/classes/class.ilRTE.php"; @@ -540,28 +540,12 @@ function listTextAssignmentObject() { if(trim($file["atext"])) { - $user = new ilObjUser($file["user_id"]); - $uname = $user->getFirstname()." ".$user->getLastname(); - $data = array( - "uid" => $file["user_id"], - "uname" => $uname, - "udate" => $file["ts"], - "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1) // mob id to mob src - ); - - if(isset($peer_data[$file["user_id"]])) - { - $data["peer"] = array_keys($peer_data[$file["user_id"]]); - } - - $data["fb_received"] = count($data["peer"]); - $data["fb_given"] = $peer_review->countGivenFeedback(true, $file["user_id"]); - + $feedback_data = $this->collectFeedbackDataFromPeer($file); $submission_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); if(is_array($submission_data)) { - $data = array_merge($data, $submission_data); + $data = array_merge($feedback_data, $submission_data); $report_html .= $this->getReportPanel($data); $total_reports++; @@ -595,51 +579,25 @@ public function compareTextAssignmentsObject() $report_title = $this->lng->txt("exc_compare_submissions"); $report_html .= "

".$report_title."

"; - //peer review object for this assignment - $peer_review = new ilExPeerReview($this->assignment); - //participant ids selected via checkboxes $participants = array_keys($this->getMultiActionUserIds()); foreach($participants as $participant_id) { - $submission = new ilExSubmission($this->assignment,$participant_id); //submission data array $file = reset($submission->getFiles()); - //user data - //TODO refactor the data collection to a method. - $user = new ilObjUser($file["user_id"]); - $uname = $user->getFirstname()." ".$user->getLastname(); - - $data = array( - "uid" => $file["user_id"], - "uname" => $uname, - "udate" => $file["ts"], - "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1) // mob id to mob src - ); - - //get data peer and assign it - $data["peer"] = array(); - foreach($peer_review->getPeerReviewsByPeerId($file['user_id']) as $key => $value) - { - $data["peer"][] = $value['giver_id']; - } - - $data["fb_received"] = count($data["peer"]); - $data["fb_given"] = $peer_review->countGivenFeedback(true, $file["user_id"]); + $feedback_data = $this->collectFeedbackDataFromPeer($file); $submission_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); if(is_array($submission_data)) { - $data = array_merge($data, $submission_data); - + $data = array_merge($feedback_data, $submission_data); $report_html .= $this->getReportPanel($data); $total_reports++; - } } @@ -2233,5 +2191,34 @@ protected function setBackToMembers() $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, "members")); } -} + /** + * @param $a_data array submission data + * @return $data array + */ + public function collectFeedbackDataFromPeer(array $a_data): array + { + $user = new ilObjUser($a_data["user_id"]); + $uname = $user->getFirstname()." ".$user->getLastname(); + + $data = array( + "uid" => $a_data["user_id"], + "uname" => $uname, + "udate" => $a_data["ts"], + "utext" => ilRTE::_replaceMediaObjectImageSrc($a_data["atext"], 1) // mob id to mob src + ); + + //get data peer and assign it + $peer_review = new ilExPeerReview($this->assignment); + $data["peer"] = array(); + foreach($peer_review->getPeerReviewsByPeerId($a_data['user_id']) as $key => $value) + { + $data["peer"][] = $value['giver_id']; + } + + $data["fb_received"] = count($data["peer"]); + $data["fb_given"] = $peer_review->countGivenFeedback(true, $a_data["user_id"]); + + return $data; + } +} \ No newline at end of file From bcd677290725a44e8da84a7c235e599490b8fab2 Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 29 Nov 2018 16:53:35 +0100 Subject: [PATCH 06/69] tpl for group of panels with the proper title. (members and compare lists) --- .../classes/class.ilExerciseManagementGUI.php | 24 ++++++++----------- .../class.ilExerciseSubmissionTableGUI.php | 2 +- .../default/tpl.exc_group_report_panels.html | 4 ++++ lang/ilias_en.lang | 4 +++- 4 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 Modules/Exercise/templates/default/tpl.exc_group_report_panels.html diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index b63ecba36e20..47bbb9aa3d61 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -524,17 +524,13 @@ function listTextAssignmentObject() $this->toolbar->addSeparator(); $this->toolbar->addComponent($button_print); - //retrieve data - //$peer_review = new ilExPeerReview($this->assignment); - //$peer_data = $peer_review->getAllPeerReviews(); - include_once "Services/User/classes/class.ilUserUtil.php"; include_once "Services/RTE/classes/class.ilRTE.php"; + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle()); + $report_html = ""; - //TODO create proper title. - $report_title = $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle(); - $report_html .= "

".$report_title."

"; $total_reports = 0; foreach(ilExSubmission::getAllAssignmentFiles($this->assignment->getExerciseId(), $this->assignment->getId()) as $file) { @@ -561,7 +557,8 @@ function listTextAssignmentObject() $report_html .= $mtpl->get(); } - $this->tpl->setContent($report_html); + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); } /** @@ -573,12 +570,10 @@ public function compareTextAssignmentsObject() { $this->setBackToMembers(); - //TODO -> Find best way to create title for this list of panels. - $report_html = ""; - //TODO create proper title. - $report_title = $this->lng->txt("exc_compare_submissions"); - $report_html .= "

".$report_title."

"; + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_compare_selected_submissions")); + $report_html = ""; //participant ids selected via checkboxes $participants = array_keys($this->getMultiActionUserIds()); @@ -601,7 +596,8 @@ public function compareTextAssignmentsObject() } } - $this->tpl->setContent($report_html); + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); } public function getReportPanel($a_data) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 44241be13d6f..b8d077bf4905 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -101,7 +101,7 @@ function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item // TODO get rid of the constant from ilExAssignment. Get this value from ilExAssignmentTypes if($this->mode == self::MODE_BY_ASSIGNMENT && $this->ass->getType() == ilExAssignment::TYPE_TEXT) { - $this->addMultiCommand("compareTextAssignments",$this->lng->txt("exc_compare_text_submissions")); + $this->addMultiCommand("compareTextAssignments",$this->lng->txt("exc_compare_submissions")); } $this->setFormName("ilExcIDlForm"); diff --git a/Modules/Exercise/templates/default/tpl.exc_group_report_panels.html b/Modules/Exercise/templates/default/tpl.exc_group_report_panels.html new file mode 100644 index 000000000000..28c1e829a0f7 --- /dev/null +++ b/Modules/Exercise/templates/default/tpl.exc_group_report_panels.html @@ -0,0 +1,4 @@ +

+{TITLE} +

+{CONTENT} \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index cc2e5d91afdf..2cd1ea4d85f0 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14953,4 +14953,6 @@ rbac#:#lso_edit_learning_progress#:#User can edit learning progress settings rbac#:#mcst_edit_learning_progress#:#User can edit learning progress settings dateplaner#:#btn_ical#:#iCal style#:#sty_type_code_block#:#Code (Block) -style#:#sty_type_code_inline#:#Code (Inline) \ No newline at end of file +style#:#sty_type_code_inline#:#Code (Inline) +exc#:#exc_compare_submissions#:#Compare submissions +exc#:#exc_compare_selected_submissions#:#Compare selected submissions \ No newline at end of file From 8e6cd4568c02a1869c89cb1b93e56f78de1d2bac Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 30 Nov 2018 17:31:52 +0100 Subject: [PATCH 07/69] Fixed and customized the mail notification for comments on wikis. --- Modules/Wiki/classes/class.ilWikiUtil.php | 81 +++++++++++++++------- Services/Notes/classes/class.ilNoteGUI.php | 8 ++- 2 files changed, 60 insertions(+), 29 deletions(-) diff --git a/Modules/Wiki/classes/class.ilWikiUtil.php b/Modules/Wiki/classes/class.ilWikiUtil.php index 171c5fa327e0..27a36fe96ab7 100755 --- a/Modules/Wiki/classes/class.ilWikiUtil.php +++ b/Modules/Wiki/classes/class.ilWikiUtil.php @@ -709,7 +709,7 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_action = "new"; } - + //TODO remove duplicate code foreach(array_unique($users) as $idx => $user_id) { if($user_id != $ilUser->getId() && @@ -719,17 +719,16 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); - $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle()); - $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; - - if($a_type == ilNotification::TYPE_WIKI_PAGE) + if($a_action == "comment") { - // update/delete - $message .= $ulng->txt('wiki_change_notification_page_body_'.$a_action).":\n\n"; + $subject = sprintf($ulng->txt('wiki_notification_comment'), $wiki->getTitle(), $page->getTitle()); + $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; + + $message .= $ulng->txt('wiki_notification_'.$a_action).":\n\n"; $message .= $ulng->txt('wiki').": ".$wiki->getTitle()."\n"; $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; - $message .= $ulng->txt('wiki_changed_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; - + $message .= $ulng->txt('wiki_comented_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; + if($snippet) { $message .= "\n".$ulng->txt('content')."\n". @@ -737,32 +736,62 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $snippet."\n". "----------------------------------------\n"; } - + // include comment/note text if($a_comment) - { + { $message .= "\n".$ulng->txt('comment').":\n\"".trim($a_comment)."\"\n"; - } - + } + $message .= "\n".$ulng->txt('wiki_change_notification_page_link').": ".$link; } else { - // new - $message .= $ulng->txt('wiki_change_notification_body_'.$a_action).":\n\n"; - $message .= $ulng->txt('wiki').": ".$wiki->getTitle()."\n"; - $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; - $message .= $ulng->txt('wiki_changed_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n\n"; - - if($snippet) + $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle()); + $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; + + if($a_type == ilNotification::TYPE_WIKI_PAGE) { - $message .= $ulng->txt('content')."\n". - "----------------------------------------\n". - $snippet."\n". - "----------------------------------------\n\n"; + // update/delete + $message .= $ulng->txt('wiki_change_notification_page_body_'.$a_action).":\n\n"; + $message .= $ulng->txt('wiki').": ".$wiki->getTitle()."\n"; + $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; + $message .= $ulng->txt('wiki_changed_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; + + if($snippet) + { + $message .= "\n".$ulng->txt('content')."\n". + "----------------------------------------\n". + $snippet."\n". + "----------------------------------------\n"; + } + + // include comment/note text + if($a_comment) + { + $message .= "\n".$ulng->txt('comment').":\n\"".trim($a_comment)."\"\n"; + } + + $message .= "\n".$ulng->txt('wiki_change_notification_page_link').": ".$link; + } + else + { + // new + $message .= $ulng->txt('wiki_change_notification_body_'.$a_action).":\n\n"; + $message .= $ulng->txt('wiki').": ".$wiki->getTitle()."\n"; + $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; + $message .= $ulng->txt('wiki_changed_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n\n"; + + if($snippet) + { + $message .= $ulng->txt('content')."\n". + "----------------------------------------\n". + $snippet."\n". + "----------------------------------------\n\n"; + } + + $message .= $ulng->txt('wiki_change_notification_link').": ".$link; } - - $message .= $ulng->txt('wiki_change_notification_link').": ".$link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); diff --git a/Services/Notes/classes/class.ilNoteGUI.php b/Services/Notes/classes/class.ilNoteGUI.php index 434f897811a9..ee37e2415ba6 100644 --- a/Services/Notes/classes/class.ilNoteGUI.php +++ b/Services/Notes/classes/class.ilNoteGUI.php @@ -1802,11 +1802,13 @@ protected function notifyObserver($a_action, $a_note) { foreach($this->observer as $item) { - $param = $a_note->getObject(); + $param = $a_note->getObject(); + //TODO refactor this, check what is this news_id from getObject + unset($param['news_id']); $param["action"] = $a_action; $param["note_id"] = $a_note->getId(); - - call_user_func_array($item, $param); + + call_user_func_array($item, $param); } } } From 5a4eef62b4b1e9145724d114cbbf2fe030819d28 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 3 Dec 2018 10:21:06 +0100 Subject: [PATCH 08/69] language variables --- Modules/Wiki/classes/class.ilWikiUtil.php | 5 ++--- lang/ilias_de.lang | 3 +++ lang/ilias_en.lang | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/Wiki/classes/class.ilWikiUtil.php b/Modules/Wiki/classes/class.ilWikiUtil.php index 27a36fe96ab7..0cdc67a5a664 100755 --- a/Modules/Wiki/classes/class.ilWikiUtil.php +++ b/Modules/Wiki/classes/class.ilWikiUtil.php @@ -709,7 +709,6 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_action = "new"; } - //TODO remove duplicate code foreach(array_unique($users) as $idx => $user_id) { if($user_id != $ilUser->getId() && @@ -721,13 +720,13 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, if($a_action == "comment") { - $subject = sprintf($ulng->txt('wiki_notification_comment'), $wiki->getTitle(), $page->getTitle()); + $subject = sprintf($ulng->txt('wiki_notification_comment_subject'), $wiki->getTitle(), $page->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; $message .= $ulng->txt('wiki_notification_'.$a_action).":\n\n"; $message .= $ulng->txt('wiki').": ".$wiki->getTitle()."\n"; $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; - $message .= $ulng->txt('wiki_comented_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; + $message .= $ulng->txt('wiki_commented_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; if($snippet) { diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index ba6d5274087e..383fb4498039 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14954,3 +14954,6 @@ rbac#:#mcst_edit_learning_progress#:#Lernfortschrittseinstellungen bearbeiten dateplaner#:#btn_ical#:#iCal style#:#sty_type_code_block#:#Code (Block) style#:#sty_type_code_inline#:#Code (Inline) +wiki#:#wiki_notification_comment_subject#:#A comment was added to %s: %s +wiki#:#wiki_notification_comment#:#the following Wiki Page has been commented. +wiki#:#wiki_commented_by#:#Commented by \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index cc2e5d91afdf..3c8ee3bc7b97 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14953,4 +14953,7 @@ rbac#:#lso_edit_learning_progress#:#User can edit learning progress settings rbac#:#mcst_edit_learning_progress#:#User can edit learning progress settings dateplaner#:#btn_ical#:#iCal style#:#sty_type_code_block#:#Code (Block) -style#:#sty_type_code_inline#:#Code (Inline) \ No newline at end of file +style#:#sty_type_code_inline#:#Code (Inline) +wiki#:#wiki_notification_comment_subject#:#A comment was added to %s: %s +wiki#:#wiki_notification_comment#:#the following Wiki Page has been commented. +wiki#:#wiki_commented_by#:#Commented by \ No newline at end of file From e1d342341953d17dd176996c5205e3ca5ec1f756 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 3 Dec 2018 15:49:18 +0100 Subject: [PATCH 09/69] Firsts steps for LM comments notifications --- .../classes/class.ilLMPresentationGUI.php | 86 ++++++++++++++++++- ...ass.ilLearningModuleNotificationSender.php | 8 ++ .../classes/class.ilNotification.php | 2 + lang/ilias_en.lang | 9 +- 4 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index c9be0a203a4f..3253eaf30ae7 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -246,6 +246,30 @@ function executeCommand() break; default: + if($_GET["ntf"]) + { + ilLoggerFactory::getRootLogger()->debug("PAGE ID = ".$this->getCurrentPageId()); + switch($_GET["ntf"]) + { + case 1: + ilNotification::setNotification(ilNotification::TYPE_LM, $this->user->getId(), $this->lm->getId(), false); + break; + + case 2: + ilNotification::setNotification(ilNotification::TYPE_LM, $this->user->getId(), $this->lm->getId(), true); + break; + + case 3: + //PAGE ID page id related to the learning module. + ilNotification::setNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $this->getCurrentPageId(), false); + break; + + case 4: + ilNotification::setNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $this->getCurrentPageId(), true); + break; + } + $ilCtrl->redirect($this,"layout"); + } $ret = $this->$cmd(); break; } @@ -1054,7 +1078,13 @@ function addHeaderAction($a_redraw = false) { $ilAccess = $this->access; $tpl = $this->tpl; - + + $lm_id = $this->lm->getId(); + $pg_id = $this->getCurrentPageId(); + + $this->lng->loadLanguageModule("content"); + + include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php"; $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, $this->lm->getType(), $_GET["ref_id"], $this->lm->getId()); @@ -1074,7 +1104,49 @@ function addHeaderAction($a_redraw = false) { $lg->enableRating(true, $this->lng->txt("lm_rating"), false, array("ilcommonactiondispatchergui", "ilratinggui")); - } + } + + // notification + if ($this->user->getId() != ANONYMOUS_USER_ID) + { + if(ilNotification::hasNotification(ilNotification::TYPE_LM, $this->user->getId(), $lm_id)) + { + $this->ctrl->setParameter($this, "ntf", 1); + if (ilNotification::hasOptOut($lm_id)) + { + $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_deactivate_lm"); + } + + $lg->addHeaderIcon("not_icon", + ilUtil::getImagePath("notification_on.svg"), + $this->lng->txt("cont_notification_activated")); + } + else + { + $this->ctrl->setParameter($this, "ntf", 2); + $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_activate_lm"); + + if(ilNotification::hasNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $page_id)) + { + $this->ctrl->setParameter($this, "ntf", 3); + $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_deactivate_page"); + + $lg->addHeaderIcon("not_icon", + ilUtil::getImagePath("notification_on.svg"), + $this->lng->txt("cont_page_notification_activated")); + } + else + { + $this->ctrl->setParameter($this, "ntf", 4); + $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_activate_page"); + + $lg->addHeaderIcon("not_icon", + ilUtil::getImagePath("notification_off.svg"), + $this->lng->txt("cont_notification_deactivated")); + } + } + $this->ctrl->setParameter($this, "ntf", ""); + } if(!$a_redraw) { @@ -4398,6 +4470,16 @@ function refreshToc() exit; } + //TODO the callback for this one. + function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) + { + $note = new ilNote($a_note_id); + $note = $note->getText(); + + include_once "./Services/Notification/classes/class.ilNotification.php"; + ilWikiUtil::sendNotification("comment", ilNotification::TYPE_WIKI_PAGE, $this->getWikiRefId(), $a_page_id, $note); + } + } ?> diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php b/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php new file mode 100644 index 000000000000..cb89c86e158c --- /dev/null +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php @@ -0,0 +1,8 @@ + Extended GPL, see docs/LICENSE */ + +//TODO create an interface for notifications contract. +class ilLearningModuleNotificationSender +{ + function sendNotification(); +} \ No newline at end of file diff --git a/Services/Notification/classes/class.ilNotification.php b/Services/Notification/classes/class.ilNotification.php index 02d760c8f8df..307658bbc18c 100644 --- a/Services/Notification/classes/class.ilNotification.php +++ b/Services/Notification/classes/class.ilNotification.php @@ -22,6 +22,8 @@ class ilNotification const TYPE_POLL = 6; const TYPE_LM_BLOCKED_USERS = 7; const TYPE_BOOK = 8; + const TYPE_LM = 9; + const TYPE_LM_PAGE = 10; const THRESHOLD = 180; // time between mails in minutes diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 3c8ee3bc7b97..c53e2c174640 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14956,4 +14956,11 @@ style#:#sty_type_code_block#:#Code (Block) style#:#sty_type_code_inline#:#Code (Inline) wiki#:#wiki_notification_comment_subject#:#A comment was added to %s: %s wiki#:#wiki_notification_comment#:#the following Wiki Page has been commented. -wiki#:#wiki_commented_by#:#Commented by \ No newline at end of file +wiki#:#wiki_commented_by#:#Commented by +content#:#cont_notification_activated#:#Notification Activated (Whole LM) +content#:#cont_page_notification_activated#:#Notification Activated (Single Page) +content#:#cont_notification_deactivate_lm#:#Deactivate Notification for Learning Module +content#:#cont_notification_deactivate_page#:#Deactivate Notification for Page +content#:#cont_notification_activate_lm#:#Activate Notification for Learning Module +content#:#cont_notification_activate_page#:#Activate Notification for Page +content#:#cont_notification_deactivated#:#Notification Deactivated \ No newline at end of file From a8d339bd6da9c5cac1037c2bf7c0f70806804495 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 12:01:29 +0100 Subject: [PATCH 10/69] Implement notifications for learning modules when new comment --- .../classes/class.ilLMPresentationGUI.php | 10 +- .../class.ilLearningModuleNotification.php | 157 ++++++++++++++++++ ...ass.ilLearningModuleNotificationSender.php | 8 - lang/ilias_de.lang | 13 +- lang/ilias_en.lang | 6 +- 5 files changed, 180 insertions(+), 14 deletions(-) create mode 100644 Modules/LearningModule/classes/class.ilLearningModuleNotification.php delete mode 100644 Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index 3253eaf30ae7..432b9462c26f 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -248,7 +248,6 @@ function executeCommand() default: if($_GET["ntf"]) { - ilLoggerFactory::getRootLogger()->debug("PAGE ID = ".$this->getCurrentPageId()); switch($_GET["ntf"]) { case 1: @@ -1220,6 +1219,9 @@ function ilLMNotes() $notes_gui->enablePublicNotes(); } + $callback = array($this, "observeNoteAction"); + $notes_gui->addObserver($callback); + if ($next_class == "ilnotegui") { $html = $this->ctrl->forwardCommand($notes_gui); @@ -4470,14 +4472,14 @@ function refreshToc() exit; } - //TODO the callback for this one. function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) { $note = new ilNote($a_note_id); $note = $note->getText(); - include_once "./Services/Notification/classes/class.ilNotification.php"; - ilWikiUtil::sendNotification("comment", ilNotification::TYPE_WIKI_PAGE, $this->getWikiRefId(), $a_page_id, $note); + include_once "./Modules/LearningModule/classes/class.ilLearningModuleNotification.php"; + $notification = new ilLearningModuleNotification("comment", ilNotification::TYPE_LM_PAGE, $this->lm, $a_page_id,note); + $notification->send(); } } diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php new file mode 100644 index 000000000000..03334b8a9f4d --- /dev/null +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -0,0 +1,157 @@ + + * @version $Id$ + * + * @ingroup ModulesIliasLearningModule + */ +class ilLearningModuleNotification +{ + /** + * @var ilObjUser + */ + protected $ilUser; + + /** + * @var ilAccessHandler + */ + protected $ilAccess; + + /** + * @var ilLanguage + */ + protected $lng; + + /** + * @var ilSetting + */ + protected $lm_set; + + /** + * @var string + */ + protected $action; + + /** + * @var int + */ + protected $type; + + /** + * @var ilObjLearningModule + */ + protected $learning_module; + + /** + * @var int + */ + protected $page_id; + + /** + * @var string + */ + protected $comment; + + /** + * ilLearningModuleNotification constructor. + * @param string $a_action + * @param int $a_type + * @param ilObjLearningModule $a_learning_module + * @param int $a_page_id + * @param string|null $a_comment + */ + public function __construct(string $a_action, int $a_type, ilObjLearningModule $a_learning_module, int $a_page_id, string $a_comment = null) + { + global $DIC; + + $this->ilUser = $DIC->user(); + $this->ilAccess = $DIC->access(); + $this->lng = $DIC->language(); + $this->lng->loadLanguageModule("content"); + $this->lm_set = new ilSetting("lm"); + $this->action = $a_action; + $this->type = $a_type; + $this->learning_module = $a_learning_module; + $this->page_id = $a_page_id; + $this->comment = $a_comment; + } + + protected function send() + { + //currently only notifications from new comments are implemented + if($this->action != "comment") + { + return; + } + + $lm_id = $this->learning_module->getId(); + $lm_ref_id = $this->learning_module->getRefId(); + + $pg_title = ilLMPageObject::_getPresentationTitle($this->page_id, + $this->learning_module->getPageHeader(), $this->learning_module->isActiveNumbering(), + $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lng); + + // #11138 //only comment implemented so always true. + $ignore_threshold = ($this->action == "comment"); + + $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, $this->page_id, $ignore_threshold); + + if ($this->type == ilNotification::TYPE_LM_PAGE) + { + $page_users = ilNotification::getNotificationsForObject($$this->type, $this->page_id, null, $ignore_threshold); + $users = array_merge($users, $page_users); + } + if(!sizeof($users)) + { + return; + } + + ilNotification::updateNotificationTime(ilNotification::TYPE_LM, $lm_id, $users, $this->page_id); + + // #15192 - should always be present + if($this->page_id) + { + // #18804 - see ilWikiPageGUI::preview() + $link = ilLink::_getLink("", "pg", null, $this->page_id."_".$lm_ref_id); + } + else + { + $link = ilLink::_getLink($lm_ref_id); + } + + foreach(array_unique($users) as $idx => $user_id) + { + if($user_id != $this->ilUser->getId() && + $this->ilAccess->checkAccessOfUser($user_id, 'read', '', $lm_ref_id)) + { + // use language of recipient to compose message + $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); + $ulng->loadLanguageModule('content'); + + $subject = sprintf($ulng->txt('cont_notification_comment_subject'), $this->learning_module->getTitle(), $pg_title); + $message = sprintf($ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; + + $message .= $ulng->txt('cont_notification_'.$this->action).":\n\n"; + $message .= $ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; + $message .= $ulng->txt('page').": ".$pg_title."\n"; + $message .= $ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; + + // include comment/note text + $message .= "\n".$ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; + + $message .= "\n".$ulng->txt('url').": ".$link; + + $mail_obj = new ilMail(ANONYMOUS_USER_ID); + $mail_obj->appendInstallationSignature(true); + $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), + "", "", $subject, $message, array(), array("system")); + } + } + } +} \ No newline at end of file diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php b/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php deleted file mode 100644 index cb89c86e158c..000000000000 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotificationSender.php +++ /dev/null @@ -1,8 +0,0 @@ - Extended GPL, see docs/LICENSE */ - -//TODO create an interface for notifications contract. -class ilLearningModuleNotificationSender -{ - function sendNotification(); -} \ No newline at end of file diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 383fb4498039..11659301e28a 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14956,4 +14956,15 @@ style#:#sty_type_code_block#:#Code (Block) style#:#sty_type_code_inline#:#Code (Inline) wiki#:#wiki_notification_comment_subject#:#A comment was added to %s: %s wiki#:#wiki_notification_comment#:#the following Wiki Page has been commented. -wiki#:#wiki_commented_by#:#Commented by \ No newline at end of file +wiki#:#wiki_commented_by#:#Commented by +content#:#cont_notification_activated#:#Notification Activated (Whole LM) +content#:#cont_page_notification_activated#:#Notification Activated (Single Page) +content#:#cont_notification_deactivate_lm#:#Deactivate Notification for Learning Module +content#:#cont_notification_deactivate_page#:#Deactivate Notification for Page +content#:#cont_notification_activate_lm#:#Activate Notification for Learning Module +content#:#cont_notification_activate_page#:#Activate Notification for Page +content#:#cont_notification_deactivated#:#Notification Deactivated +content#:#cont_notification_comment_subject#:#A comment was added to %s: %s +content#:#cont_change_notification_salutation#:#Hello %s, +content#:#cont_notification_comment#:#the following Learning Module Page has been commented +content#:#cont_commented_by#:#Commented by \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index c53e2c174640..6f0f45ea4ef9 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14963,4 +14963,8 @@ content#:#cont_notification_deactivate_lm#:#Deactivate Notification for Learning content#:#cont_notification_deactivate_page#:#Deactivate Notification for Page content#:#cont_notification_activate_lm#:#Activate Notification for Learning Module content#:#cont_notification_activate_page#:#Activate Notification for Page -content#:#cont_notification_deactivated#:#Notification Deactivated \ No newline at end of file +content#:#cont_notification_deactivated#:#Notification Deactivated +content#:#cont_notification_comment_subject#:#A comment was added to %s: %s +content#:#cont_change_notification_salutation#:#Hello %s, +content#:#cont_notification_comment#:#the following Learning Module Page has been commented +content#:#cont_commented_by#:#Commented by \ No newline at end of file From c8d3d8ba7784305294c1e5544f491646a6dd736f Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 12:19:27 +0100 Subject: [PATCH 11/69] missing german lang vars --- lang/ilias_de.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index cb7870e081a7..af756bf5527b 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14957,6 +14957,8 @@ rbac#:#mcst_edit_learning_progress#:#Lernfortschrittseinstellungen bearbeiten dateplaner#:#btn_ical#:#iCal style#:#sty_type_code_block#:#Code (Block) style#:#sty_type_code_inline#:#Code (Inline) +exc#:#exc_compare_submissions#:#Compare submissions +exc#:#exc_compare_selected_submissions#:#Compare selected submissions wiki#:#wiki_notification_comment_subject#:#A comment was added to %s: %s wiki#:#wiki_notification_comment#:#the following Wiki Page has been commented. wiki#:#wiki_commented_by#:#Commented by From 9def6fe004e69395d234466d7610ef96b916bd91 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 12:21:17 +0100 Subject: [PATCH 12/69] set send method public --- .../classes/class.ilLearningModuleNotification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 03334b8a9f4d..de7be6d24ec3 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -82,7 +82,7 @@ public function __construct(string $a_action, int $a_type, ilObjLearningModule $ $this->comment = $a_comment; } - protected function send() + public function send() { //currently only notifications from new comments are implemented if($this->action != "comment") From 23e0190fd9d120b444a74e8b91c8182c86ce6f05 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 12:24:29 +0100 Subject: [PATCH 13/69] typos --- Modules/LearningModule/classes/class.ilLMPresentationGUI.php | 2 +- .../classes/class.ilLearningModuleNotification.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index 432b9462c26f..4a59d06f747c 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -4478,7 +4478,7 @@ function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) $note = $note->getText(); include_once "./Modules/LearningModule/classes/class.ilLearningModuleNotification.php"; - $notification = new ilLearningModuleNotification("comment", ilNotification::TYPE_LM_PAGE, $this->lm, $a_page_id,note); + $notification = new ilLearningModuleNotification("comment", ilNotification::TYPE_LM_PAGE, $this->lm, $a_page_id,$note); $notification->send(); } diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index de7be6d24ec3..862d08273ac5 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -104,7 +104,7 @@ public function send() if ($this->type == ilNotification::TYPE_LM_PAGE) { - $page_users = ilNotification::getNotificationsForObject($$this->type, $this->page_id, null, $ignore_threshold); + $page_users = ilNotification::getNotificationsForObject($this->type, $this->page_id, null, $ignore_threshold); $users = array_merge($users, $page_users); } if(!sizeof($users)) From 78d73ee15004c41f1bf860605c9c68638589864f Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 14:42:23 +0100 Subject: [PATCH 14/69] Fix wiki comment action --- Modules/Wiki/classes/class.ilWikiUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Wiki/classes/class.ilWikiUtil.php b/Modules/Wiki/classes/class.ilWikiUtil.php index 0cdc67a5a664..6fa6dd8c8ab3 100755 --- a/Modules/Wiki/classes/class.ilWikiUtil.php +++ b/Modules/Wiki/classes/class.ilWikiUtil.php @@ -703,7 +703,7 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, // "fake" new (to enable snippet - if any) $current_version = array_shift($page->getHistoryEntries()); $current_version = $current_version["nr"]; - if(!$current_version) + if(!$current_version && $a_action != "comment") { $a_type = ilNotification::TYPE_WIKI; $a_action = "new"; From 48d23fa922900a7c4cfd9976caa10e3b865d14cb Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 15:10:08 +0100 Subject: [PATCH 15/69] Fix LM comment on page notification --- Modules/LearningModule/classes/class.ilLMPresentationGUI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index 4a59d06f747c..be349e09989e 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -1125,7 +1125,7 @@ function addHeaderAction($a_redraw = false) $this->ctrl->setParameter($this, "ntf", 2); $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_activate_lm"); - if(ilNotification::hasNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $page_id)) + if(ilNotification::hasNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $pg_id)) { $this->ctrl->setParameter($this, "ntf", 3); $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_deactivate_page"); From cdebf4d18fe14ced973ffee4fdc1894f3b83216a Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 15:30:24 +0100 Subject: [PATCH 16/69] Add ilLearningModuleNotification to autoload. --- Modules/LearningModule/classes/class.ilLMPresentationGUI.php | 1 - libs/composer/vendor/composer/autoload_classmap.php | 1 + libs/composer/vendor/composer/autoload_static.php | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index be349e09989e..7e00c16b76a8 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -4477,7 +4477,6 @@ function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) $note = new ilNote($a_note_id); $note = $note->getText(); - include_once "./Modules/LearningModule/classes/class.ilLearningModuleNotification.php"; $notification = new ilLearningModuleNotification("comment", ilNotification::TYPE_LM_PAGE, $this->lm, $a_page_id,$note); $notification->send(); } diff --git a/libs/composer/vendor/composer/autoload_classmap.php b/libs/composer/vendor/composer/autoload_classmap.php index 236997b08d28..407ad85dfea4 100644 --- a/libs/composer/vendor/composer/autoload_classmap.php +++ b/libs/composer/vendor/composer/autoload_classmap.php @@ -4777,6 +4777,7 @@ 'ilLearningModuleImporter' => $baseDir . '/../../Modules/LearningModule/classes/class.ilLearningModuleImporter.php', 'ilLearningModuleLP' => $baseDir . '/../../Modules/LearningModule/classes/class.ilLearningModuleLP.php', 'ilLearningModuleNewsRendererGUI' => $baseDir . '/../../Modules/LearningModule/classes/class.ilLearningModuleNewsRendererGUI.php', + 'ilLearningModuleNotification' => $baseDir . '/../../Modules/LearningModule/classes/class.ilLearningModuleNotification.php', 'ilLearningModulePageCollector' => $baseDir . '/../../Modules/LearningModule/classes/class.ilLearningModulePageCollector.php', 'ilLearningProgress' => $baseDir . '/../../Services/Tracking/classes/class.ilLearningProgress.php', 'ilLearningProgressAccess' => $baseDir . '/../../Services/Tracking/classes/class.ilLearningProgressAccess.php', diff --git a/libs/composer/vendor/composer/autoload_static.php b/libs/composer/vendor/composer/autoload_static.php index ae08f2cc57d9..2fc8c7ae6556 100644 --- a/libs/composer/vendor/composer/autoload_static.php +++ b/libs/composer/vendor/composer/autoload_static.php @@ -5085,6 +5085,7 @@ class ComposerStaticInit2fffdf922cf8fdbf1f62eec345993c83 'ilLearningModuleImporter' => __DIR__ . '/../..' . '/../../Modules/LearningModule/classes/class.ilLearningModuleImporter.php', 'ilLearningModuleLP' => __DIR__ . '/../..' . '/../../Modules/LearningModule/classes/class.ilLearningModuleLP.php', 'ilLearningModuleNewsRendererGUI' => __DIR__ . '/../..' . '/../../Modules/LearningModule/classes/class.ilLearningModuleNewsRendererGUI.php', + 'ilLearningModuleNotification' => __DIR__ . '/../..' . '/../../Modules/LearningModule/classes/class.ilLearningModuleNotification.php', 'ilLearningModulePageCollector' => __DIR__ . '/../..' . '/../../Modules/LearningModule/classes/class.ilLearningModulePageCollector.php', 'ilLearningProgress' => __DIR__ . '/../..' . '/../../Services/Tracking/classes/class.ilLearningProgress.php', 'ilLearningProgressAccess' => __DIR__ . '/../..' . '/../../Services/Tracking/classes/class.ilLearningProgressAccess.php', From ce7eb22e6add73ae32f4bf8356204ef9a332174b Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 15:54:31 +0100 Subject: [PATCH 17/69] method descriptions and remove comments --- .../classes/class.ilExerciseSubmissionTableGUI.php | 1 - .../classes/class.ilLMPresentationGUI.php | 10 ++++++++-- .../classes/class.ilLearningModuleNotification.php | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index b8d077bf4905..967c811a39a2 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -98,7 +98,6 @@ function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item $this->addMultiCommand("saveStatusSelected", $this->lng->txt("exc_save_selected")); - // TODO get rid of the constant from ilExAssignment. Get this value from ilExAssignmentTypes if($this->mode == self::MODE_BY_ASSIGNMENT && $this->ass->getType() == ilExAssignment::TYPE_TEXT) { $this->addMultiCommand("compareTextAssignments",$this->lng->txt("exc_compare_submissions")); diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index 7e00c16b76a8..79364305bb53 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -259,7 +259,6 @@ function executeCommand() break; case 3: - //PAGE ID page id related to the learning module. ilNotification::setNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $this->getCurrentPageId(), false); break; @@ -1083,7 +1082,6 @@ function addHeaderAction($a_redraw = false) $this->lng->loadLanguageModule("content"); - include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php"; $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, $this->lm->getType(), $_GET["ref_id"], $this->lm->getId()); @@ -4472,6 +4470,14 @@ function refreshToc() exit; } + /** + * Generate new ilNote and send Notifications to the users informing that there are new comments in the LM + * @param $a_lm_id + * @param $a_page_id + * @param $a_type + * @param $a_action + * @param $a_note_id + */ function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) { $note = new ilNote($a_note_id); diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 862d08273ac5..99095b1bd63f 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -82,6 +82,9 @@ public function __construct(string $a_action, int $a_type, ilObjLearningModule $ $this->comment = $a_comment; } + /** + * Generate notifications and send them if necessary + */ public function send() { //currently only notifications from new comments are implemented From 6c09effc88e7bab4402818760f870febf1e2fb7b Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 5 Dec 2018 16:31:52 +0100 Subject: [PATCH 18/69] Exc global setting to accept versioning for submissions --- .../class.ilObjExerciseAdministrationGUI.php | 29 +++++++++++-------- lang/ilias_de.lang | 4 ++- lang/ilias_en.lang | 2 ++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Modules/Exercise/classes/class.ilObjExerciseAdministrationGUI.php b/Modules/Exercise/classes/class.ilObjExerciseAdministrationGUI.php index 75735f321255..18b4342d94c7 100644 --- a/Modules/Exercise/classes/class.ilObjExerciseAdministrationGUI.php +++ b/Modules/Exercise/classes/class.ilObjExerciseAdministrationGUI.php @@ -22,12 +22,12 @@ class ilObjExerciseAdministrationGUI extends ilObjectGUI */ public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true) { - global $DIC; - - $this->lng = $DIC->language(); - $this->settings = $DIC->settings(); - $this->ctrl = $DIC->ctrl(); - $this->access = $DIC->access(); + global $DIC; + + $this->lng = $DIC->language(); + $this->settings = $DIC->settings(); + $this->ctrl = $DIC->ctrl(); + $this->access = $DIC->access(); $this->type = "excs"; parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output); @@ -97,8 +97,8 @@ public function getAdminTabs() */ public function editSettings($a_form = null) { - $lng = $this->lng; - $ilSetting = $this->settings; + $lng = $this->lng; + $ilSetting = $this->settings; $this->tabs_gui->setTabActive('settings'); @@ -115,7 +115,7 @@ public function editSettings($a_form = null) */ public function saveSettings() { - $ilCtrl = $this->ctrl; + $ilCtrl = $this->ctrl; $this->checkPermission("write"); @@ -124,6 +124,7 @@ public function saveSettings() { $exc_set = new ilSetting("excs"); $exc_set->set("add_to_pd", (bool)$form->getInput("pd")); + $exc_set->set("enable_versioning", (bool)$form->getInput("ev")); ilUtil::sendSuccess($this->lng->txt("settings_saved"),true); $ilCtrl->redirect($this, "editSettings"); @@ -138,7 +139,7 @@ public function saveSettings() */ public function cancel() { - $ilCtrl = $this->ctrl; + $ilCtrl = $this->ctrl; $ilCtrl->redirect($this, "view"); } @@ -150,8 +151,7 @@ public function cancel() */ protected function initFormSettings() { - $lng = $this->lng; - $ilAccess = $this->access; + $lng = $this->lng; include_once('Services/Form/classes/class.ilPropertyFormGUI.php'); $form = new ilPropertyFormGUI(); @@ -171,6 +171,11 @@ protected function initFormSettings() $pd->setChecked($exc_set->get("add_to_pd", true)); $form->addItem($pd); + $pd = new ilCheckboxInputGUI($lng->txt("exc_enable_versioning"), "ev"); + $pd->setInfo($lng->txt("exc_enable_versioning_info")); + $pd->setChecked($exc_set->get("enable_versioning", false)); + $form->addItem($pd); + return $form; } } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index af756bf5527b..c483d36fc51a 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14972,4 +14972,6 @@ content#:#cont_notification_deactivated#:#Notification Deactivated content#:#cont_notification_comment_subject#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment#:#the following Learning Module Page has been commented -content#:#cont_commented_by#:#Commented by \ No newline at end of file +content#:#cont_commented_by#:#Commented by +exercise#:#exc_enable_versioning#:#Enable versioning +exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index db654cd883f1..e1c124e30dd3 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14973,3 +14973,5 @@ content#:#cont_notification_comment_subject#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment#:#the following Learning Module Page has been commented content#:#cont_commented_by#:#Commented by +exercise#:#exc_enable_versioning#:#Enable versioning +exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission From 887d3a2e46519aa3d1366f36fc9f04262b7d5675 Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 6 Dec 2018 11:31:55 +0100 Subject: [PATCH 19/69] Versioning table column to exc assignments type text if enabled --- .../class.ilExerciseSubmissionTableGUI.php | 35 ++++++++++++++----- .../default/tpl.exc_members_row.html | 6 ++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 967c811a39a2..d9422163024c 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -32,7 +32,7 @@ abstract class ilExerciseSubmissionTableGUI extends ilTable2GUI // needs PH P5.6 for array support protected $cols_mandatory = array("name", "status"); protected $cols_default = array("login", "submission_date", "idl", "calc_deadline"); - protected $cols_order = array("image", "name", "login", "team_members", + protected $cols_order = array("image", "name", "login", "team_members", "version", "sent_time", "submission", "calc_deadline", "idl", "status", "mark", "status_time", "feedback_time", "comment", "notice"); @@ -53,8 +53,6 @@ function __construct($a_parent_obj, $a_parent_cmd, ilObjExercise $a_exc, $a_item $this->access = $DIC->access(); $this->tpl = $DIC["tpl"]; $this->lng = $DIC->language(); - - $ilCtrl = $DIC->ctrl(); $this->exc = $a_exc; @@ -208,8 +206,7 @@ protected function parseColumns() { $cols = $this->parseModeColumns(); - $cols["submission"] = array($this->lng->txt("exc_tbl_submission_date"), "submission"); - + $cols["submission"] = array($this->lng->txt("exc_tbl_submission_date"), "submission"); $cols["status"] = array($this->lng->txt("exc_tbl_status"), "status"); $cols["mark"] = array($this->lng->txt("exc_tbl_mark"), "mark"); $cols["status_time"] = array($this->lng->txt("exc_tbl_status_time"), "status_time"); @@ -228,7 +225,13 @@ protected function parseColumns() $cols["comment"] = array($this->lng->txt("exc_tbl_comment"), "comment"); } - $cols["notice"] = array($this->lng->txt("exc_tbl_notice"), "note"); + $cols["notice"] = array($this->lng->txt("exc_tbl_notice"), "note"); + + if($this->hasVersioningMode()) + { + $cols["version"] = array($this->lng->txt("version"), "version"); + $this->cols_mandatory[] = "version"; + } return $cols; } @@ -362,7 +365,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) // selectable columns - + foreach($this->getSelectedColumns() as $col) { switch($col) @@ -475,7 +478,11 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) break; } } - + + if($this->hasVersioningMode()) + { + $this->tpl->setVariable("VAL_VERSION", "dummy value for now"); + } // actions @@ -632,4 +639,16 @@ public function render() return parent::render(). implode("\n", $this->comment_modals); } + + protected function hasVersioningMode() + { + if($this->ass->getType() == ilExAssignment::TYPE_TEXT) + { + $exc_settings = new ilSetting("excs"); + if($exc_settings->get("enable_versioning")) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/Modules/Exercise/templates/default/tpl.exc_members_row.html b/Modules/Exercise/templates/default/tpl.exc_members_row.html index c6413c8fb4e9..b7cb9585362a 100755 --- a/Modules/Exercise/templates/default/tpl.exc_members_row.html +++ b/Modules/Exercise/templates/default/tpl.exc_members_row.html @@ -90,6 +90,12 @@ + + + {VAL_VERSION} + + + {VAL_CALC_DEADLINE} From dcca5e2785d45d69eff1c29de52aea987478fbd5 Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 6 Dec 2018 15:57:12 +0100 Subject: [PATCH 20/69] submission versionables. GUI table + db + lang --- .../Exercise/classes/class.ilExAssignment.php | 12 +++++ .../Exercise/classes/class.ilExSubmission.php | 44 ++++++++++++++++++- .../classes/class.ilExerciseManagementGUI.php | 15 +++++++ .../class.ilExerciseSubmissionTableGUI.php | 39 +++++++++------- lang/ilias_de.lang | 4 +- lang/ilias_en.lang | 2 + 6 files changed, 98 insertions(+), 18 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExAssignment.php b/Modules/Exercise/classes/class.ilExAssignment.php index 094444094f53..9639a8a03f86 100644 --- a/Modules/Exercise/classes/class.ilExAssignment.php +++ b/Modules/Exercise/classes/class.ilExAssignment.php @@ -2566,6 +2566,18 @@ public function getCalculatedDeadlines() } return $calculated_deadlines; } + + public function isVersionable() + { + if($this->getType() == ilExAssignment::TYPE_TEXT) + { + $exc_settings = new ilSetting("excs"); + if($exc_settings->get("enable_versioning")) { + return true; + } + } + return false; + } } ?> \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index b7f26034f302..6bf870bf9486 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -14,8 +14,6 @@ class ilExSubmission const TYPE_TEXT = "Text"; const TYPE_REPO_OBJECT = "RepoObject"; // Wikis - - /** * @var ilObjUser */ @@ -1666,5 +1664,47 @@ static function getDirectoryNameFromUserData($a_user_id) return $targetdir; } + + /** + * Update the submission with the next version number and set it as versioned. + * The user will be allowed to submit again. + * @return int + */ + public function setVersion() + { + $next_version = $this->getLastVersionNumber() + 1; + + $this->db->manipulate("UPDATE exc_returned". + " SET version = ".$this->db->quote($next_version, "integer"). + ", versioned = ".$this->db->quote(1, "integer"). + " WHERE ass_id = ". + $this->db->quote($this->assignment->getId(), "integer"). + " AND user_id = ". + $this->db->quote($this->user_id, "ingeger"). + " AND version = ". + $this->db->quote($this->getLastVersionNumber(), "integer")); + + return $next_version; + } + + /** + * @return integer + */ + public function getLastVersionNumber() : int + { + $sql = "SELECT max(version) version". + " FROM exc_returned". + " WHERE ass_id = ". + $this->db->quote($this->assignment->getId(), "integer"). + " AND user_id = ". + $this->db->quote($this->user_id, "ingeger"); + + $res = $this->db->query($sql); + + $row = $this->db->fetchAssoc($res); + + return (int)$row['version']; + + } } diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 47bbb9aa3d61..7a825fc04bf6 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2217,4 +2217,19 @@ public function collectFeedbackDataFromPeer(array $a_data): array return $data; } + + public function freezeVersionObject() + { + $user_id = (int)$_GET['usr_id']; + + $submission = new ilExSubmission($this->assignment, $user_id); + $submission->setVersion(); + //TODO create info message + $this->ctrl->redirect($this, "members"); + } + + public function showVersions() + { + //TODO + } } \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index d9422163024c..b69538d03ac0 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -227,7 +227,7 @@ protected function parseColumns() $cols["notice"] = array($this->lng->txt("exc_tbl_notice"), "note"); - if($this->hasVersioningMode()) + if($this->ass->isVersionable()) { $cols["version"] = array($this->lng->txt("version"), "version"); $this->cols_mandatory[] = "version"; @@ -479,9 +479,9 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) } } - if($this->hasVersioningMode()) + if($this->ass->isVersionable()) { - $this->tpl->setVariable("VAL_VERSION", "dummy value for now"); + $this->tpl->setVariable("VAL_VERSION", $a_row["submission_obj"]->getLastVersionNumber()); } // actions @@ -620,7 +620,27 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) "", $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "showTeamLog") ); - } + } + + if($this->ass->isVersionable()) + { + //TODO -> check this behavior with teams! + $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "usr_id", $a_user_id); + + //TODO -> If freezed do not show this action + $actions->addItem( + $this->lng->txt("exc_tbl_freeze_version"), + "", + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "freezeVersion") + ); + + //TODO -> Do not show this action ¡f no frozen versions + $actions->addItem( + $this->lng->txt("exc_tbl_show_frozen_versions"), + "", + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "showVersions") + ); + } $this->tpl->setVariable("ACTIONS", $actions->getHTML()); } @@ -640,15 +660,4 @@ public function render() implode("\n", $this->comment_modals); } - protected function hasVersioningMode() - { - if($this->ass->getType() == ilExAssignment::TYPE_TEXT) - { - $exc_settings = new ilSetting("excs"); - if($exc_settings->get("enable_versioning")) { - return true; - } - } - return false; - } } \ No newline at end of file diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index c483d36fc51a..9ba95a404b1f 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14974,4 +14974,6 @@ content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment#:#the following Learning Module Page has been commented content#:#cont_commented_by#:#Commented by exercise#:#exc_enable_versioning#:#Enable versioning -exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission \ No newline at end of file +exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission +exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission +exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index e1c124e30dd3..429b1aeb86dd 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14975,3 +14975,5 @@ content#:#cont_notification_comment#:#the following Learning Module Page has bee content#:#cont_commented_by#:#Commented by exercise#:#exc_enable_versioning#:#Enable versioning exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission +exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission +exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions \ No newline at end of file From 1398582eb2d04601bb39aeca6f696c5e9efc50ee Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 6 Dec 2018 16:11:51 +0100 Subject: [PATCH 21/69] submission isVersioned + show action buttons depending if submit version --- .../Exercise/classes/class.ilExSubmission.php | 18 +++++++++++- .../class.ilExerciseSubmissionTableGUI.php | 28 +++++++++++-------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index 6bf870bf9486..856426bf71ad 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -1700,11 +1700,27 @@ public function getLastVersionNumber() : int $this->db->quote($this->user_id, "ingeger"); $res = $this->db->query($sql); - $row = $this->db->fetchAssoc($res); return (int)$row['version']; } + + public function isVersioned() : bool + { + $sql = "SELECT versioned". + " FROM exc_returned". + " WHERE ass_id = ". + $this->db->quote($this->assignment->getId(), "integer"). + " AND user_id = ". + $this->db->quote($this->user_id, "ingeger"). + " AND version = ". + $this->db->quote($this->getLastVersionNumber(), "integer"); + + $res = $this->db->query($sql); + $row = $this->db->fetchAssoc($res); + + return (bool)$row['versioned']; + } } diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index b69538d03ac0..f03a3c3c1dc5 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -627,19 +627,23 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) //TODO -> check this behavior with teams! $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "usr_id", $a_user_id); - //TODO -> If freezed do not show this action - $actions->addItem( - $this->lng->txt("exc_tbl_freeze_version"), - "", - $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "freezeVersion") - ); + if( ! $a_row["submission_obj"]->isVersioned()) + { + $actions->addItem( + $this->lng->txt("exc_tbl_freeze_version"), + "", + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "freezeVersion") + ); + } - //TODO -> Do not show this action ¡f no frozen versions - $actions->addItem( - $this->lng->txt("exc_tbl_show_frozen_versions"), - "", - $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "showVersions") - ); + if($a_row["submission_obj"]->getLastVersionNumber()) + { + $actions->addItem( + $this->lng->txt("exc_tbl_show_frozen_versions"), + "", + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "showVersions") + ); + } } $this->tpl->setVariable("ACTIONS", $actions->getHTML()); From 8cdc921feab92f551756b2d2fca6ed038d40cb8c Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 6 Dec 2018 16:19:33 +0100 Subject: [PATCH 22/69] do not show version 0 in the gui table --- .../Exercise/classes/class.ilExerciseSubmissionTableGUI.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index f03a3c3c1dc5..30fb579af435 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -481,7 +481,11 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($this->ass->isVersionable()) { - $this->tpl->setVariable("VAL_VERSION", $a_row["submission_obj"]->getLastVersionNumber()); + if($a_row["submission_obj"]->getLastVersionNumber() > 0) { + $this->tpl->setVariable("VAL_VERSION", $a_row["submission_obj"]->getLastVersionNumber()); + } else { + $this->tpl->setVariable("VAL_VERSION", ""); + } } // actions From 0bc1cf1cd0e587c1616d66556eefd5975e72746b Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 7 Dec 2018 09:54:12 +0100 Subject: [PATCH 23/69] ilSubmission canSubmit returns true also when the submission has been versioned --- Modules/Exercise/classes/class.ilExSubmission.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index 856426bf71ad..f1d881142d39 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -199,7 +199,8 @@ public function getSelectedObject() public function canSubmit() { return ($this->isOwner() && - $this->state->isSubmissionAllowed()); + $this->state->isSubmissionAllowed() || + $this->isVersioned()); } public function canView() From cba445a757941ed22578eb5e90b8bd5b43302472 Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 7 Dec 2018 11:31:44 +0100 Subject: [PATCH 24/69] btns+lang User can send more than one submission --- .../classes/class.ilExSubmissionTextGUI.php | 31 +++++++++++++++---- lang/ilias_de.lang | 4 ++- lang/ilias_en.lang | 4 ++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php index 9ee5a9a3e13e..d016fd5fcf77 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php @@ -62,8 +62,21 @@ public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmissio $lng = $DIC->language(); $ilCtrl = $DIC->ctrl(); - - if($a_submission->canSubmit()) + + if($a_submission->isVersioned()) + { + //TODO provide link to submissions history + $btn_show = ilLinkButton::getInstance(); + $btn_show->setCaption("exc_btn_show_submissions"); + //$btn_show->setUrl($ilCtrl->getLinkTargetByClass("ilExSubmissionsHistoryGUI", "showSubmissionsHistory")); + + $btn_revise = ilLinkButton::getInstance(); + $btn_revise->setPrimary(true); + $btn_revise->setCaption("exc_btn_revise_submission"); + $btn_revise->setUrl($ilCtrl->getLinkTargetByClass(array("ilExSubmissionGUI", "ilExSubmissionTextGUI"), "editAssignmentText")); + $files_str = $btn_show->render()." ".$btn_revise->render(); + } + elseif($a_submission->canSubmit()) { $button = ilLinkButton::getInstance(); $button->setPrimary(true); @@ -199,6 +212,7 @@ function editAssignmentTextObject(ilPropertyFormGUI $a_form = null) { $a_form = $this->initAssignmentTextForm(); + //TODO get last revision/submission files. $files = $this->submission->getFiles(); if($files) { @@ -243,11 +257,16 @@ function updateAssignmentTextObject($a_return = false) $text = trim($form->getInput("atxt")); $existing = $this->submission->getFiles(); - - $returned_id = $this->submission->updateTextSubmission( + + //If versioned, new DB entry + if($this->submission->isVersioned()){ + $returned_id = $this->submission->addResourceObject("TEXT", $text); + } else { + $returned_id = $this->submission->updateTextSubmission( // mob src to mob id - ilRTE::_replaceMediaObjectImageSrc($text, 0)); - + ilRTE::_replaceMediaObjectImageSrc($text, 0)); + } + // no empty text if($returned_id) { diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 9ba95a404b1f..1c864e828813 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14976,4 +14976,6 @@ content#:#cont_commented_by#:#Commented by exercise#:#exc_enable_versioning#:#Enable versioning exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission -exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions \ No newline at end of file +exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions +exercise#:#exc_btn_show_submissions#:#Show Submission History +exercise#:#exc_btn_revise_submission#:#Revise Submission \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 429b1aeb86dd..37db11cbce17 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14976,4 +14976,6 @@ content#:#cont_commented_by#:#Commented by exercise#:#exc_enable_versioning#:#Enable versioning exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission -exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions \ No newline at end of file +exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions +exercise#:#exc_btn_show_submissions#:#Show Submission History +exercise#:#exc_btn_revise_submission#:#Revise Submission \ No newline at end of file From 8ffb9c5515431408cbe39f49acacfac85cb85b6d Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 7 Dec 2018 13:30:44 +0100 Subject: [PATCH 25/69] Edit the last revision --- Modules/Exercise/classes/class.ilExSubmission.php | 9 +++++++-- Modules/Exercise/classes/class.ilExSubmissionTextGUI.php | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index f1d881142d39..0e10881e999d 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -522,8 +522,13 @@ function getFiles(array $a_file_ids = null, $a_only_valid = false, $a_min_timest if($a_min_timestamp) { $sql .= " AND ts > ".$ilDB->quote($a_min_timestamp, "timestamp"); - } - + } + + if($this->isVersioned()) + { + $sql .= " ORDER BY returned_id DESC LIMIT 1"; + } + $result = $ilDB->query($sql); $delivered_files = array(); diff --git a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php index d016fd5fcf77..2a6dca431fa5 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php @@ -259,9 +259,12 @@ function updateAssignmentTextObject($a_return = false) $existing = $this->submission->getFiles(); //If versioned, new DB entry - if($this->submission->isVersioned()){ + if($this->submission->isVersioned() && $existing[0]['versioned']) + { $returned_id = $this->submission->addResourceObject("TEXT", $text); - } else { + } + else + { $returned_id = $this->submission->updateTextSubmission( // mob src to mob id ilRTE::_replaceMediaObjectImageSrc($text, 0)); From b9867ed1664262cef8e277ffaddadf9fa5a6189f Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 7 Dec 2018 14:13:13 +0100 Subject: [PATCH 26/69] isVersionable if no versioned before or last version is 0 --- .../Exercise/classes/class.ilExSubmission.php | 57 ++++++++++++++++--- .../class.ilExerciseSubmissionTableGUI.php | 2 +- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index 0e10881e999d..8f0d96c675b2 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -1676,21 +1676,64 @@ static function getDirectoryNameFromUserData($a_user_id) * The user will be allowed to submit again. * @return int */ - public function setVersion() + public function setVersion() : int { - $next_version = $this->getLastVersionNumber() + 1; + if($this->isVersionable()) + { + $next_version = $this->getLastVersionNumber() + 1; + + $sql = "UPDATE exc_returned". + " SET version = ".$this->db->quote($next_version, "integer"). + ", versioned = ".$this->db->quote(1, "integer"). + " WHERE ass_id = ". + $this->db->quote($this->assignment->getId(), "integer"). + " AND user_id = ". + $this->db->quote($this->user_id, "ingeger"); + + if($this->isVersioned()) + { + $sql .= " AND version = ". + $this->db->quote(0, "integer"); + } + else + { + $sql .= " AND version = ". + $this->db->quote($this->getLastVersionNumber(), "integer"); + } + + $this->db->manipulate($sql); + + return $next_version; + } + + return 0; + } - $this->db->manipulate("UPDATE exc_returned". - " SET version = ".$this->db->quote($next_version, "integer"). - ", versioned = ".$this->db->quote(1, "integer"). + //Todo find better method name + public function isVersionable() : bool + { + if( ! $this->isVersioned()) + { + return true; + } + + $sql = "SELECT count(version) total". + " FROM exc_returned". " WHERE ass_id = ". $this->db->quote($this->assignment->getId(), "integer"). " AND user_id = ". $this->db->quote($this->user_id, "ingeger"). " AND version = ". - $this->db->quote($this->getLastVersionNumber(), "integer")); + $this->db->quote(0, "ingeger"); - return $next_version; + $res = $this->db->query($sql); + $row = $this->db->fetchAssoc($res); + if($row['total'] > 0) + { + return true; + } + + return false; } /** diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 30fb579af435..137083a8c87e 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -631,7 +631,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) //TODO -> check this behavior with teams! $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "usr_id", $a_user_id); - if( ! $a_row["submission_obj"]->isVersioned()) + if($a_row["submission_obj"]->isVersionable()) { $actions->addItem( $this->lng->txt("exc_tbl_freeze_version"), From 6c2520a2f032ed7776474fb7aca581dd13ef3967 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 10 Dec 2018 09:26:22 +0100 Subject: [PATCH 27/69] DB update + reload structure --- setup/sql/dbupdate_04.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/setup/sql/dbupdate_04.php b/setup/sql/dbupdate_04.php index da68174cfb9e..a7ac9537b5a1 100644 --- a/setup/sql/dbupdate_04.php +++ b/setup/sql/dbupdate_04.php @@ -25276,4 +25276,25 @@ function writeCtrlClassEntry(ilPluginSlot $slot, array $plugin_data) { ), array( "1" => array("integer", 1) )); +?> +<#5431> +tableColumnExists("exc_returned", 'versioned')) { + $ilDB->addTableColumn("exc_returned", 'versioned', [ + "type" => "integer", + "length" => 1, + "default" => 0, + ]); +} +if (!$ilDB->tableColumnExists("exc_returned", 'version')) { + $ilDB->addTableColumn("exc_returned", 'version', [ + "type" => "integer", + "length" => 4, + "default" => 0, + ]); +} +?> +<#5432> +getStructure(); ?> \ No newline at end of file From 5a6a28e2b579ecbd96f38fdc0bbf0207412531c7 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 14:02:16 +0100 Subject: [PATCH 28/69] remove DB update --- setup/sql/dbupdate_04.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/setup/sql/dbupdate_04.php b/setup/sql/dbupdate_04.php index a7ac9537b5a1..da68174cfb9e 100644 --- a/setup/sql/dbupdate_04.php +++ b/setup/sql/dbupdate_04.php @@ -25276,25 +25276,4 @@ function writeCtrlClassEntry(ilPluginSlot $slot, array $plugin_data) { ), array( "1" => array("integer", 1) )); -?> -<#5431> -tableColumnExists("exc_returned", 'versioned')) { - $ilDB->addTableColumn("exc_returned", 'versioned', [ - "type" => "integer", - "length" => 1, - "default" => 0, - ]); -} -if (!$ilDB->tableColumnExists("exc_returned", 'version')) { - $ilDB->addTableColumn("exc_returned", 'version', [ - "type" => "integer", - "length" => 4, - "default" => 0, - ]); -} -?> -<#5432> -getStructure(); ?> \ No newline at end of file From d2e217e93ecf2bb8d62305f5cae3d31c29a7e4a8 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 14:21:38 +0100 Subject: [PATCH 29/69] Refactor to get versions in one DB table. --- .../Exercise/classes/class.ilExSubmission.php | 123 ++++---------- .../classes/class.ilExSubmissionRevision.php | 156 ++++++++++++++++++ .../classes/class.ilExerciseManagementGUI.php | 49 +++++- .../class.ilExerciseSubmissionTableGUI.php | 19 ++- .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + setup/sql/dbupdate_04.php | 92 +++++++++++ 7 files changed, 337 insertions(+), 104 deletions(-) create mode 100644 Modules/Exercise/classes/class.ilExSubmissionRevision.php diff --git a/Modules/Exercise/classes/class.ilExSubmission.php b/Modules/Exercise/classes/class.ilExSubmission.php index 8f0d96c675b2..d91269350698 100644 --- a/Modules/Exercise/classes/class.ilExSubmission.php +++ b/Modules/Exercise/classes/class.ilExSubmission.php @@ -658,6 +658,30 @@ public static function findUserFiles($a_user_id, $a_filetitle) } return $res; } + + /** + * Return the submission ids related to the specific user and assignment + * @param $a_user_id + * @param $a_filetitle + * @return array + */ + public function getSubmissionsByUser() : array + { + $sql = "SELECT *". + " FROM exc_returned". + " WHERE user_id = ".$this->db->quote($this->user_id, "integer"). + " AND ass_id = ".$this->db->quote($this->assignment->getId(), "integer"); + + $set = $this->db->query($sql); + + $res = array(); + while($row = $this->db->fetchAssoc($set)) + { + $res[] = $row; + } + + return $res; + } function deleteAllFiles() { @@ -1672,104 +1696,13 @@ static function getDirectoryNameFromUserData($a_user_id) } /** - * Update the submission with the next version number and set it as versioned. - * The user will be allowed to submit again. - * @return int - */ - public function setVersion() : int - { - if($this->isVersionable()) - { - $next_version = $this->getLastVersionNumber() + 1; - - $sql = "UPDATE exc_returned". - " SET version = ".$this->db->quote($next_version, "integer"). - ", versioned = ".$this->db->quote(1, "integer"). - " WHERE ass_id = ". - $this->db->quote($this->assignment->getId(), "integer"). - " AND user_id = ". - $this->db->quote($this->user_id, "ingeger"); - - if($this->isVersioned()) - { - $sql .= " AND version = ". - $this->db->quote(0, "integer"); - } - else - { - $sql .= " AND version = ". - $this->db->quote($this->getLastVersionNumber(), "integer"); - } - - $this->db->manipulate($sql); - - return $next_version; - } - - return 0; - } - - //Todo find better method name - public function isVersionable() : bool - { - if( ! $this->isVersioned()) - { - return true; - } - - $sql = "SELECT count(version) total". - " FROM exc_returned". - " WHERE ass_id = ". - $this->db->quote($this->assignment->getId(), "integer"). - " AND user_id = ". - $this->db->quote($this->user_id, "ingeger"). - " AND version = ". - $this->db->quote(0, "ingeger"); - - $res = $this->db->query($sql); - $row = $this->db->fetchAssoc($res); - if($row['total'] > 0) - { - return true; - } - - return false; - } - - /** - * @return integer + * Check if the submission has been versioned by tutor/admin + * @return bool */ - public function getLastVersionNumber() : int - { - $sql = "SELECT max(version) version". - " FROM exc_returned". - " WHERE ass_id = ". - $this->db->quote($this->assignment->getId(), "integer"). - " AND user_id = ". - $this->db->quote($this->user_id, "ingeger"); - - $res = $this->db->query($sql); - $row = $this->db->fetchAssoc($res); - - return (int)$row['version']; - - } - public function isVersioned() : bool { - $sql = "SELECT versioned". - " FROM exc_returned". - " WHERE ass_id = ". - $this->db->quote($this->assignment->getId(), "integer"). - " AND user_id = ". - $this->db->quote($this->user_id, "ingeger"). - " AND version = ". - $this->db->quote($this->getLastVersionNumber(), "integer"); - - $res = $this->db->query($sql); - $row = $this->db->fetchAssoc($res); - - return (bool)$row['versioned']; + $revision = new ilExSubmissionRevision($this); + return $revision->isVersioned(); } } diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php new file mode 100644 index 000000000000..e98aa7d6037d --- /dev/null +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -0,0 +1,156 @@ + + * @ingroup ModulesExercise + */ + +class ilExSubmissionRevision +{ + /** + * @var ilExSubmission + */ + protected $submission; + + /** + * @var int + */ + protected $ass_id; + + /** + * @var int + */ + protected $usr_id; + + /** + * @var ilDBInterface + */ + protected $db; + + + /** + * ilExSubmissionRevision constructor. + * @param ilExSubmission $a_submission + */ + public function __construct(ilExSubmission $a_submission) + { + global $DIC; + + $this->db = $DIC->database(); + $this->submission = $a_submission; + $this->ass_id = $this->submission->getAssignment()->getId(); + $this->usr_id = $this->submission->getUserId(); + } + + + /** + * Store the submission version in the DB. + * The user will be allowed to submit again. + * @return int + */ + public function setVersion() : int + { + $next_version = $this->getLastVersionNumber() + 1; + + $submissions = $this->submission->getSubmissionsByUser(); + + foreach($submissions as $submission) + { + $ass_mem_status = new ilExAssignmentMemberStatus($this->ass_id, $this->submission->getUserId()); + + $next_id = $this->db->nextId('exc_submission_version'); + + $affectedRows = $this->db->manipulateF( + "INSERT INTO exc_submission_version (id, returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, atext, late, team_id, status, mark, u_comment, version, versioned)". + " VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'timestamp', 'integer', 'text', 'integer', 'integer', 'text', 'text', 'text',' integer', 'timestamp'), + array( + $next_id, + $submission['returned_id'], + $submission['obj_id'], + $submission['user_id'], + $submission['filename'], + $submission['filetitle'], + $submission['mimetype'], + $submission['ts'], + $submission['ass_id'], + $submission['atext'], + $submission['late'], + $submission['team_id'], + $ass_mem_status->getStatus(), + $ass_mem_status->getMark(), + $ass_mem_status->getComment(), + $next_version, + ilUtil::now() + ) + ); + } + return $next_version; + } + + + /** + * Get Last submission version number + * @return integer + */ + public function getLastVersionNumber() : int + { + $sql = "SELECT max(version) version". + " FROM exc_submission_version". + " WHERE ass_id = ". + $this->db->quote($this->ass_id, "integer"). + " AND user_id = ". + $this->db->quote($this->usr_id, "integer"); + + $res = $this->db->query($sql); + $row = $this->db->fetchAssoc($res); + + return (int)$row['version']; + } + + + /** + * Compare the submission with the last revision to determine if it was versioned or not. + * @return bool + */ + public function isVersioned() : bool + { + $sql = "SELECT count(r.returned_id) count". + " FROM exc_returned r, exc_submission_version v". + " WHERE r.obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND r.ass_id = ".$this->ass_id. + " AND r.user_id = ".$this->usr_id. + " AND r.obj_id = v.obj_id". + " AND r.ass_id = v.ass_id". + " AND r.user_id = v.user_id". + " AND r.ts = v.ts"; + + $res = $this->db->query($sql); + $row = $this->db->fetchAssoc($res); + + return (bool)$row['count']; + } + + /** + * Get all versions for the submission. + * @return array + */ + public function getRevisions() : array + { + $sql = "SELECT * FROM exc_submission_version". + " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND ass_id = ".$this->ass_id. + " AND user_id = ".$this->usr_id. + " ORDER BY version ASC"; + + $res = $this->db->query($sql); + while($row = $this->db->fetchAssoc($res)) + { + $versions[] = $row; + } + return $versions ? $versions : array(); + } +} \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 7a825fc04bf6..b83d1938d4c9 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2177,6 +2177,10 @@ function initFilter() $this->toolbar->addButtonInstance($submit); } + /** + * Versioning + */ + /** * Add the Back link to the tabs. (used in submission list and submission compare) */ @@ -2218,18 +2222,57 @@ public function collectFeedbackDataFromPeer(array $a_data): array return $data; } + /** + * Freeze one submission, update and assign version number. + * Example in: Exercise Submissions table. (Submissions and Grades -> Assignment View tab) + */ public function freezeVersionObject() { $user_id = (int)$_GET['usr_id']; $submission = new ilExSubmission($this->assignment, $user_id); - $submission->setVersion(); + $revision = new ilExSubmissionRevision($submission); + $revision->setVersion(); //TODO create info message $this->ctrl->redirect($this, "members"); } - public function showVersions() + /** + * Display a list of panels with all versioned submissions. + */ + public function showVersionsObject() + { + $user_id = (int)$_GET['usr_id']; + $submission = new ilExSubmission($this->assignment, $user_id); + $revision_obj = new ilExSubmissionRevision($submission); + $submissions = $revision_obj->getRevisions(); + + $this->showVersionsPanel($submissions); + } + + //Todo DTO? + // This is going to be a lot for this class + //interface + class + //Similar to listTextAssignmentObject / compareTextAssignmentsObject + //TODO refactor lists of panels to avoid duplicate code. + public function showVersionsPanel(array $a_submissions) { - //TODO + $this->setBackToMembers(); + + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_submission_versions")); + + $report_html = ""; + + foreach($a_submissions as $submission) + { + $feedback_data = $this->collectFeedbackDataFromPeer($submission); + $data = array_merge($feedback_data, $submission); + $report_html .= $this->getReportPanel($data); + $total_reports++; + } + + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); } } \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 137083a8c87e..79c04d1d5eea 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -243,8 +243,15 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $has_no_team_yet = ($a_ass->hasTeam() && !ilExAssignmentTeam::getTeamId($a_ass->getId(), $a_user_id)); - - + + //revisions data + if($this->ass->isVersionable()) + { + $revision = new ilExSubmissionRevision($a_row['submission_obj']); + $number_of_revisions = $revision->getLastVersionNumber(); + $is_submission_versioned = $revision->isVersioned(); + } + // static columns if($this->mode == self::MODE_BY_ASSIGNMENT) @@ -481,8 +488,8 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($this->ass->isVersionable()) { - if($a_row["submission_obj"]->getLastVersionNumber() > 0) { - $this->tpl->setVariable("VAL_VERSION", $a_row["submission_obj"]->getLastVersionNumber()); + if($number_of_revisions) { + $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); } else { $this->tpl->setVariable("VAL_VERSION", ""); } @@ -631,7 +638,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) //TODO -> check this behavior with teams! $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "usr_id", $a_user_id); - if($a_row["submission_obj"]->isVersionable()) + if(!$is_submission_versioned) { $actions->addItem( $this->lng->txt("exc_tbl_freeze_version"), @@ -640,7 +647,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) ); } - if($a_row["submission_obj"]->getLastVersionNumber()) + if($number_of_revisions) { $actions->addItem( $this->lng->txt("exc_tbl_show_frozen_versions"), diff --git a/libs/composer/vendor/composer/autoload_classmap.php b/libs/composer/vendor/composer/autoload_classmap.php index 407ad85dfea4..a0fcd913d1ac 100644 --- a/libs/composer/vendor/composer/autoload_classmap.php +++ b/libs/composer/vendor/composer/autoload_classmap.php @@ -4209,6 +4209,7 @@ 'ilExSubmissionFileGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionFileGUI.php', 'ilExSubmissionGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionGUI.php', 'ilExSubmissionObjectGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php', + 'ilExSubmissionRevision' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionRevision.php', 'ilExSubmissionTeamGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php', 'ilExSubmissionTextGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionTextGUI.php', 'ilExampleCache' => $baseDir . '/../../Services/Cache/classes/class.ilExampleCache.php', diff --git a/libs/composer/vendor/composer/autoload_static.php b/libs/composer/vendor/composer/autoload_static.php index 2fc8c7ae6556..11e6b8d5ed76 100644 --- a/libs/composer/vendor/composer/autoload_static.php +++ b/libs/composer/vendor/composer/autoload_static.php @@ -4517,6 +4517,7 @@ class ComposerStaticInit2fffdf922cf8fdbf1f62eec345993c83 'ilExSubmissionFileGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionFileGUI.php', 'ilExSubmissionGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionGUI.php', 'ilExSubmissionObjectGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php', + 'ilExSubmissionRevision' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionRevision.php', 'ilExSubmissionTeamGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php', 'ilExSubmissionTextGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionTextGUI.php', 'ilExampleCache' => __DIR__ . '/../..' . '/../../Services/Cache/classes/class.ilExampleCache.php', diff --git a/setup/sql/dbupdate_04.php b/setup/sql/dbupdate_04.php index da68174cfb9e..5c9fe4f53023 100644 --- a/setup/sql/dbupdate_04.php +++ b/setup/sql/dbupdate_04.php @@ -25276,4 +25276,96 @@ function writeCtrlClassEntry(ilPluginSlot $slot, array $plugin_data) { ), array( "1" => array("integer", 1) )); +?> +<#5431> +tableExists("exc_submission_version")) +{ + $ilDB->createTable("exc_submission_version", array( + 'id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'returned_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'obj_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'user_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'filename' => array( + 'type' => 'text', + 'length' => 1000, + 'notnull' => false + ), + 'filetitle' => array( + 'type' => 'text', + 'length' => 1000, + 'notnull' => false + ), + 'mimetype' => array( + 'type' => 'text', + 'length' => 150, + 'notnull' => false + ), + 'ts' => array( + 'type' => 'timestamp', + 'notnull' => false + ), + 'ass_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'atext' => array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => true + ), + 'late' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'team_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + ), + 'status' => array( + 'type' => 'text', + 'length' => '9' + ), + 'mark' => array( + 'type' => 'text', + 'length' => '32' + ), + 'u_comment' => array( + 'type' => 'text', + 'length' => '4000' + ), + 'version' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'versioned' => array( + 'type' => 'timestamp', + 'notnull' => true + ) + ) + ); + + $ilDB->addPrimaryKey('exc_submission_version', array('id', 'user_id', 'team_id', 'ass_id')); + $ilDB->createSequence('exc_submission_version'); +} ?> \ No newline at end of file From ce34a777335f7e707e0ce08d865ac6cb678c90b5 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 14:58:29 +0100 Subject: [PATCH 30/69] msg when successfully freeze a submission --- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 2 +- lang/ilias_de.lang | 3 ++- lang/ilias_en.lang | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index b83d1938d4c9..211e9f5dc689 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2233,7 +2233,7 @@ public function freezeVersionObject() $submission = new ilExSubmission($this->assignment, $user_id); $revision = new ilExSubmissionRevision($submission); $revision->setVersion(); - //TODO create info message + ilUtil::sendSuccess($this->lng->txt("exc_submission_versioned_ok"), true); $this->ctrl->redirect($this, "members"); } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 1c864e828813..622bdd50ba75 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14978,4 +14978,5 @@ exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History -exercise#:#exc_btn_revise_submission#:#Revise Submission \ No newline at end of file +exercise#:#exc_btn_revise_submission#:#Revise Submission +exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 37db11cbce17..7461eade9a24 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14978,4 +14978,5 @@ exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History -exercise#:#exc_btn_revise_submission#:#Revise Submission \ No newline at end of file +exercise#:#exc_btn_revise_submission#:#Revise Submission +exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen \ No newline at end of file From fa6115a179eb56b344e1f414f71a048af609f0a8 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 16:27:20 +0100 Subject: [PATCH 31/69] get member assignment data can return an empty array --- Modules/Exercise/classes/class.ilExAssignment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExAssignment.php b/Modules/Exercise/classes/class.ilExAssignment.php index 9639a8a03f86..faaacc92d144 100644 --- a/Modules/Exercise/classes/class.ilExAssignment.php +++ b/Modules/Exercise/classes/class.ilExAssignment.php @@ -1521,7 +1521,7 @@ function getMemberListData() * @param $a_grade * @return array */ - public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") + public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") : array { global $DIC; $ilDB = $DIC->database(); @@ -1554,7 +1554,7 @@ public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") $data["comment"] = $rec["u_comment"]; } - return $data; + return $data? $data : array(); } From 06dc8772912cdc7951bda68908b4eed0c7c6ed15 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 16:34:24 +0100 Subject: [PATCH 32/69] showSubmissionPanel to display all panel lists --- .../classes/class.ilExerciseManagementGUI.php | 81 ++++++------------- 1 file changed, 24 insertions(+), 57 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 211e9f5dc689..f93d159670cb 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -515,8 +515,6 @@ function listTextAssignmentObject() { $this->initFilter(); - $this->setBackToMembers(); - $button_print = $this->ui_factory->button()->standard($this->lng->txt('print'), "#") ->withOnLoadCode(function($id) { return "$('#{$id}').click(function() { window.print(); return false; });"; @@ -524,80 +522,50 @@ function listTextAssignmentObject() $this->toolbar->addSeparator(); $this->toolbar->addComponent($button_print); - include_once "Services/User/classes/class.ilUserUtil.php"; - include_once "Services/RTE/classes/class.ilRTE.php"; - - $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); - $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle()); + $title = $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle(); - $report_html = ""; - $total_reports = 0; foreach(ilExSubmission::getAllAssignmentFiles($this->assignment->getExerciseId(), $this->assignment->getId()) as $file) { if(trim($file["atext"])) { - $feedback_data = $this->collectFeedbackDataFromPeer($file); - $submission_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); - - if(is_array($submission_data)) - { - $data = array_merge($feedback_data, $submission_data); - $report_html .= $this->getReportPanel($data); - $total_reports++; - - } + $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); + $submission_data[] = array_merge($file, $assignment_data); } } - if($total_reports == 0) + if(count($submission_data) == 0) { + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $title); $mtpl = new ilTemplate("tpl.message.html", true, true, "Services/Utilities"); $mtpl->setCurrentBlock("info_message"); $mtpl->setVariable("TEXT", $this->lng->txt("fiter_no_results")); $mtpl->parseCurrentBlock(); $report_html .= $mtpl->get(); + + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); } - $group_panels_tpl->setVariable('CONTENT', $report_html); - $this->tpl->setContent($group_panels_tpl->get()); + $this->showSubmissionPanels($title, $submission_data); } /** * TODO -> Deal with the redirection after update the grade via action button. - * - * Extract the data collection to another method. List and compare use this. DRY */ public function compareTextAssignmentsObject() { - $this->setBackToMembers(); - - $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); - $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_compare_selected_submissions")); - - $report_html = ""; //participant ids selected via checkboxes $participants = array_keys($this->getMultiActionUserIds()); foreach($participants as $participant_id) { $submission = new ilExSubmission($this->assignment,$participant_id); - - //submission data array $file = reset($submission->getFiles()); - - $feedback_data = $this->collectFeedbackDataFromPeer($file); - - $submission_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); - - if(is_array($submission_data)) - { - $data = array_merge($feedback_data, $submission_data); - $report_html .= $this->getReportPanel($data); - $total_reports++; - } + $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); + $submission_data[] = array_merge($file,$assignment_data); } - $group_panels_tpl->setVariable('CONTENT', $report_html); - $this->tpl->setContent($group_panels_tpl->get()); + $this->showSubmissionPanels($this->lng->txt("exc_compare_selected_submissions"), $submission_data); } public function getReportPanel($a_data) @@ -2246,28 +2214,27 @@ public function showVersionsObject() $submission = new ilExSubmission($this->assignment, $user_id); $revision_obj = new ilExSubmissionRevision($submission); $submissions = $revision_obj->getRevisions(); - - $this->showVersionsPanel($submissions); + $this->showSubmissionPanels($this->lng->txt("exc_submission_versions"), $submissions); } - //Todo DTO? - // This is going to be a lot for this class - //interface + class - //Similar to listTextAssignmentObject / compareTextAssignmentsObject - //TODO refactor lists of panels to avoid duplicate code. - public function showVersionsPanel(array $a_submissions) + /** + * Display the HTML with a bunch of sub panels. + * @param string $a_title + * @param array $a_submissions_data + */ + public function showSubmissionPanels(string $a_title, array $a_submissions_data) { $this->setBackToMembers(); $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); - $group_panels_tpl->setVariable('TITLE', $this->lng->txt("exc_submission_versions")); + $group_panels_tpl->setVariable('TITLE', $a_title); $report_html = ""; - foreach($a_submissions as $submission) + foreach($a_submissions_data as $submission_data) { - $feedback_data = $this->collectFeedbackDataFromPeer($submission); - $data = array_merge($feedback_data, $submission); + $feedback_data = $this->collectFeedbackDataFromPeer($submission_data); + $data = array_merge($feedback_data, $submission_data); $report_html .= $this->getReportPanel($data); $total_reports++; } From 4ec4783e4a155699366641c54eb0194acc8c9280 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 11 Dec 2018 17:02:16 +0100 Subject: [PATCH 33/69] small fix for filter in panels list --- Modules/Exercise/classes/class.ilExAssignment.php | 4 ++-- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExAssignment.php b/Modules/Exercise/classes/class.ilExAssignment.php index faaacc92d144..9639a8a03f86 100644 --- a/Modules/Exercise/classes/class.ilExAssignment.php +++ b/Modules/Exercise/classes/class.ilExAssignment.php @@ -1521,7 +1521,7 @@ function getMemberListData() * @param $a_grade * @return array */ - public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") : array + public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") { global $DIC; $ilDB = $DIC->database(); @@ -1554,7 +1554,7 @@ public function getExerciseMemberAssignmentData($a_user_id, $a_grade = "") : arr $data["comment"] = $rec["u_comment"]; } - return $data? $data : array(); + return $data; } diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index f93d159670cb..853b13fcb23e 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -524,12 +524,15 @@ function listTextAssignmentObject() $title = $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle(); + $submission_data = array(); foreach(ilExSubmission::getAllAssignmentFiles($this->assignment->getExerciseId(), $this->assignment->getId()) as $file) { if(trim($file["atext"])) { $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); - $submission_data[] = array_merge($file, $assignment_data); + if($assignment_data != '') { + $submission_data[] = array_merge($file, $assignment_data); + } } } if(count($submission_data) == 0) From 21fd01e1c002981b5348970ef96ce7503af752bf Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 09:45:31 +0100 Subject: [PATCH 34/69] Add Status time info for the versioned cards + lang vars --- Modules/Exercise/classes/class.ilExSubmissionRevision.php | 7 ++++--- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 2 +- lang/ilias_de.lang | 3 ++- lang/ilias_en.lang | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index e98aa7d6037d..de1948f79562 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -64,9 +64,9 @@ public function setVersion() : int $next_id = $this->db->nextId('exc_submission_version'); $affectedRows = $this->db->manipulateF( - "INSERT INTO exc_submission_version (id, returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, atext, late, team_id, status, mark, u_comment, version, versioned)". - " VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", - array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'timestamp', 'integer', 'text', 'integer', 'integer', 'text', 'text', 'text',' integer', 'timestamp'), + "INSERT INTO exc_submission_version (id, returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id, atext, late, team_id, status, status_time, mark, u_comment, version, versioned)". + " VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'timestamp', 'integer', 'text', 'integer', 'integer', 'text', 'timestamp', 'text', 'text',' integer', 'timestamp'), array( $next_id, $submission['returned_id'], @@ -81,6 +81,7 @@ public function setVersion() : int $submission['late'], $submission['team_id'], $ass_mem_status->getStatus(), + $ass_mem_status->getStatusTime(), $ass_mem_status->getMark(), $ass_mem_status->getComment(), $next_version, diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 853b13fcb23e..4c002cf29fce 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2217,7 +2217,7 @@ public function showVersionsObject() $submission = new ilExSubmission($this->assignment, $user_id); $revision_obj = new ilExSubmissionRevision($submission); $submissions = $revision_obj->getRevisions(); - $this->showSubmissionPanels($this->lng->txt("exc_submission_versions"), $submissions); + $this->showSubmissionPanels($this->lng->txt("exc_submission_list_versions"), $submissions); } /** diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 622bdd50ba75..812a20b181ce 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14979,4 +14979,5 @@ exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission -exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen \ No newline at end of file +exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen +exercise#:#exc_submission_list_versions#:#List of Versions \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 7461eade9a24..2bf9a7eadc53 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14979,4 +14979,5 @@ exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission -exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen \ No newline at end of file +exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen +exercise#:#exc_submission_list_versions#:#List of Versions \ No newline at end of file From 1b9605ffbd42e63e0e8738d24fda7ff9a26f7a9c Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 11:00:43 +0100 Subject: [PATCH 35/69] Customize panels to get revision or submission information --- .../classes/class.ilExerciseManagementGUI.php | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 4c002cf29fce..a1dd8acc3656 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -73,6 +73,9 @@ class ilExerciseManagementGUI const GRADE_PASSED = "passed"; const GRADE_FAILED = "failed"; + const PANEL_TYPE_SUBMISSION = 1; + const PANEL_TYPE_REVISION = 2; + /** * Constructor * @@ -549,7 +552,7 @@ function listTextAssignmentObject() $this->tpl->setContent($group_panels_tpl->get()); } - $this->showSubmissionPanels($title, $submission_data); + $this->showSubmissionPanels($title, self::PANEL_TYPE_SUBMISSION, $submission_data); } /** @@ -568,16 +571,25 @@ public function compareTextAssignmentsObject() $submission_data[] = array_merge($file,$assignment_data); } - $this->showSubmissionPanels($this->lng->txt("exc_compare_selected_submissions"), $submission_data); + $this->showSubmissionPanels($this->lng->txt("exc_compare_selected_submissions"), self::PANEL_TYPE_SUBMISSION, $submission_data); } - public function getReportPanel($a_data) + /** + * @param $a_type + * @param $a_data + * @return string + * @throws ilDateTimeException + */ + public function getReportPanel(int $a_type, array $a_data) { - $modal = $this->getEvaluationModal($a_data); + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $modal = $this->getEvaluationModal($a_data); - $actions = $this->ui_factory->dropdown()->standard(array( - $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), - )); + $actions = $this->ui_factory->dropdown()->standard(array( + $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), + )); + } if($a_data['status'] == self::GRADE_NOT_GRADED) { $str_status_key = $this->lng->txt('exc_tbl_status'); @@ -598,10 +610,13 @@ public function getReportPanel($a_data) $card_content = array( $this->lng->txt("exc_tbl_submission_date") => ilDatePresentation::formatDate(new ilDateTime($a_data["udate"], IL_CAL_DATETIME)), $str_status_key => $str_status_value, - $str_evaluation_key => $str_evaluation_value, - $this->lng->txt('feedback_given') => $a_data['fb_given'], - $this->lng->txt('feedback_received') => $a_data['fb_received'] + $str_evaluation_key => $str_evaluation_value ); + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $card_content[$this->lng->txt('feedback_given')] = $a_data['fb_given']; + $card_content[$this->lng->txt('feedback_received')] = $a_data['fb_received']; + } $card_tpl = new ilTemplate("tpl.exc_report_details_card.html", true, true, "Modules/Exercise"); foreach($card_content as $key => $value) { @@ -612,7 +627,12 @@ public function getReportPanel($a_data) } $main_panel = $this->ui_factory->panel()->sub($a_data['uname'], $this->ui_factory->legacy($a_data['utext'])) - ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get()))))->withActions($actions); + ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get())))); + + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $main_panel = $main_panel->withActions($actions); + } $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); //if no feedback filter the feedback is displayed. Can be list submissions or compare submissions. @@ -655,7 +675,12 @@ public function getReportPanel($a_data) $report = $this->ui_factory->panel()->report("", array($main_panel, $feedback_panel)); - return $this->ui_renderer->render([$modal,$report]); + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + return $this->ui_renderer->render([$modal,$report]); + } + + return $this->ui_renderer->render($report); } public function getEvaluationModal($a_data) @@ -2217,7 +2242,7 @@ public function showVersionsObject() $submission = new ilExSubmission($this->assignment, $user_id); $revision_obj = new ilExSubmissionRevision($submission); $submissions = $revision_obj->getRevisions(); - $this->showSubmissionPanels($this->lng->txt("exc_submission_list_versions"), $submissions); + $this->showSubmissionPanels($this->lng->txt("exc_submission_list_versions"), self::PANEL_TYPE_REVISION, $submissions); } /** @@ -2225,7 +2250,7 @@ public function showVersionsObject() * @param string $a_title * @param array $a_submissions_data */ - public function showSubmissionPanels(string $a_title, array $a_submissions_data) + public function showSubmissionPanels(string $a_title, int $a_type, array $a_submissions_data) { $this->setBackToMembers(); @@ -2238,7 +2263,7 @@ public function showSubmissionPanels(string $a_title, array $a_submissions_data) { $feedback_data = $this->collectFeedbackDataFromPeer($submission_data); $data = array_merge($feedback_data, $submission_data); - $report_html .= $this->getReportPanel($data); + $report_html .= $this->getReportPanel($a_type, $data); $total_reports++; } From 8c268ad2cf2d9d9cdf57782ecda927b5a30a5cec Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 11:02:40 +0100 Subject: [PATCH 36/69] List versions DESC --- Modules/Exercise/classes/class.ilExSubmissionRevision.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index de1948f79562..f77ee92b1e53 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -145,7 +145,7 @@ public function getRevisions() : array " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). " AND ass_id = ".$this->ass_id. " AND user_id = ".$this->usr_id. - " ORDER BY version ASC"; + " ORDER BY version DESC"; $res = $this->db->query($sql); while($row = $this->db->fetchAssoc($res)) From b7ee49ad47a86ceaaa94d252deaee2f3832a453e Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 11:41:37 +0100 Subject: [PATCH 37/69] Confirmation form before freeze submission --- .../classes/class.ilExerciseManagementGUI.php | 21 ++++++++++++++++++- .../class.ilExerciseSubmissionTableGUI.php | 2 +- lang/ilias_de.lang | 3 ++- lang/ilias_en.lang | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index a1dd8acc3656..81799c82919e 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2224,7 +2224,7 @@ public function collectFeedbackDataFromPeer(array $a_data): array */ public function freezeVersionObject() { - $user_id = (int)$_GET['usr_id']; + $user_id = (int)$_POST['usr_id']; $submission = new ilExSubmission($this->assignment, $user_id); $revision = new ilExSubmissionRevision($submission); @@ -2270,4 +2270,23 @@ public function showSubmissionPanels(string $a_title, int $a_type, array $a_subm $group_panels_tpl->setVariable('CONTENT', $report_html); $this->tpl->setContent($group_panels_tpl->get()); } + + /** + * Confirm create a new version of the submission. + */ + function confirmFreezeSubmissionObject() + { + $user_id = (int)$_GET['usr_id']; + + $cgui = new ilConfirmationGUI(); + $cgui->setFormAction($this->ctrl->getFormAction($this)); + $cgui->setHeaderText($this->lng->txt("exc_msg_sure_to_freeze_submission")); + $cgui->setCancel($this->lng->txt("cancel"), "members"); + $cgui->setConfirm($this->lng->txt("confirm"), "freezeVersion"); + + $cgui->addItem("usr_id", $user_id, + ilUserUtil::getNamePresentation((int) $user_id, false, false, "", true)); + + $this->tpl->setContent($cgui->getHTML()); + } } \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 79c04d1d5eea..2cc26ce2961d 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -643,7 +643,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $actions->addItem( $this->lng->txt("exc_tbl_freeze_version"), "", - $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "freezeVersion") + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "confirmFreezeSubmission") ); } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 812a20b181ce..2aa0ef6938dd 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14980,4 +14980,5 @@ exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen -exercise#:#exc_submission_list_versions#:#List of Versions \ No newline at end of file +exercise#:#exc_submission_list_versions#:#List of Versions +exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 2bf9a7eadc53..2281b422a00e 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14980,4 +14980,4 @@ exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen -exercise#:#exc_submission_list_versions#:#List of Versions \ No newline at end of file +exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? \ No newline at end of file From d405fd08080cc9a5050706d970626d23dfe7ec06 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 12:31:18 +0100 Subject: [PATCH 38/69] Notification when submission has been frozen --- .../classes/class.ilExSubmissionRevision.php | 16 +++++++++ .../class.ilExerciseMailNotification.php | 33 +++++++++++++++++++ .../classes/class.ilExerciseManagementGUI.php | 1 + lang/ilias_de.lang | 4 ++- lang/ilias_en.lang | 4 ++- 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index f77ee92b1e53..a37b01f4f71c 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -154,4 +154,20 @@ public function getRevisions() : array } return $versions ? $versions : array(); } + + public function sendNotification() + { + $get_ref = (int)$_GET['ref_id']; + $exc_id = $this->submission->getAssignment()->getExerciseId(); + + if(in_array($get_ref, ilObjExercise::_getAllReferences($exc_id))) + { + $not = new ilExerciseMailNotification(); + $not->setType(ilExerciseMailNotification::TYPE_SUBMISSION_VERSIONED); + $not->setAssignmentId($this->ass_id); + $not->setRefId($get_ref); + $not->setRecipients(array($this->submission->getUserId())); + $not->send(); + } + } } \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExerciseMailNotification.php b/Modules/Exercise/classes/class.ilExerciseMailNotification.php index e9aaf443c15c..64c711be247f 100644 --- a/Modules/Exercise/classes/class.ilExerciseMailNotification.php +++ b/Modules/Exercise/classes/class.ilExerciseMailNotification.php @@ -19,6 +19,7 @@ class ilExerciseMailNotification extends ilMailNotification const TYPE_FEEDBACK_FILE_ADDED = 20; const TYPE_SUBMISSION_UPLOAD = 30; const TYPE_FEEDBACK_TEXT_ADDED = 40; + const TYPE_SUBMISSION_VERSIONED = 50; /** * @@ -184,6 +185,38 @@ public function send() $this->sendMail(array($rcp),array('system')); } break; + + case self::TYPE_SUBMISSION_VERSIONED: + + foreach($this->getRecipients() as $rcp) + { + $this->initLanguage($rcp); + $this->initMail(); + $this->setSubject( + sprintf($this->getLanguageText('exc_notification_submission_versioned'), + $this->getObjectTitle(true)) + ); + $this->setBody(ilMail::getSalutation($rcp,$this->getLanguage())); + $this->appendBody("\n\n"); + $this->appendBody( + $this->getLanguageText('exc_notification_submission_can_resend')); + $this->appendBody("\n"); + $this->appendBody( + $this->getLanguageText('obj_exc').": ".$this->getObjectTitle(true)); + $this->appendBody("\n"); + $this->appendBody( + $this->getLanguageText('exc_assignment').": ". + ilExAssignment::lookupTitle($this->getAssignmentId())); + $this->appendBody("\n\n"); + $this->appendBody($this->getLanguageText('exc_mail_permanent_link')); + $this->appendBody("\n"); + $this->appendBody($this->createPermanentLink(array(), '_'.$this->getAssignmentId()). + '#fb'.$this->getAssignmentId()); + $this->getMail()->appendInstallationSignature(true); + + $this->sendMail(array($rcp),array('system')); + } + break; } return true; } diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 81799c82919e..b37a76c44383 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -2229,6 +2229,7 @@ public function freezeVersionObject() $submission = new ilExSubmission($this->assignment, $user_id); $revision = new ilExSubmissionRevision($submission); $revision->setVersion(); + $revision->sendNotification(); ilUtil::sendSuccess($this->lng->txt("exc_submission_versioned_ok"), true); $this->ctrl->redirect($this, "members"); } diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 2aa0ef6938dd..29973a190de5 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14981,4 +14981,6 @@ exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen exercise#:#exc_submission_list_versions#:#List of Versions -exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? \ No newline at end of file +exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? +exc#:#exc_notification_submission_versioned#:#Submission versioned +exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 2281b422a00e..214909bf76b8 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14980,4 +14980,6 @@ exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen -exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? \ No newline at end of file +exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? +exc#:#exc_notification_submission_versioned#:#Submission versioned +exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. \ No newline at end of file From b6ef8f266b7e5ba05b2641068acc1974fe87176f Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 12 Dec 2018 13:57:43 +0100 Subject: [PATCH 39/69] missing english lang var --- lang/ilias_en.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 214909bf76b8..c25b78ae63ec 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14980,6 +14980,7 @@ exercise#:#exc_tbl_show_frozen_versions#:#Show Frozen versions exercise#:#exc_btn_show_submissions#:#Show Submission History exercise#:#exc_btn_revise_submission#:#Revise Submission exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen +exercise#:#exc_submission_list_versions#:#List of Versions exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? exc#:#exc_notification_submission_versioned#:#Submission versioned exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. \ No newline at end of file From e09edffca883ad451450556a9878ff4c3e569969 Mon Sep 17 00:00:00 2001 From: xus Date: Fri, 14 Dec 2018 17:01:10 +0100 Subject: [PATCH 40/69] Refactoring: Everything related with the panels list moved to a handler class. --- .../class.ilExSubmissionPanelsHandlerGUI.php | 526 ++++++++++++++++++ .../classes/class.ilExSubmissionTextGUI.php | 7 +- .../classes/class.ilExerciseManagementGUI.php | 393 +------------ .../class.ilExerciseSubmissionTableGUI.php | 11 +- .../classes/class.ilObjExerciseGUI.php | 24 +- libs/composer/vendor/composer/ClassLoader.php | 2 +- .../vendor/composer/autoload_classmap.php | 1 + .../vendor/composer/autoload_static.php | 1 + 8 files changed, 582 insertions(+), 383 deletions(-) create mode 100644 Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php new file mode 100644 index 000000000000..18472e16c636 --- /dev/null +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -0,0 +1,526 @@ + + * @ingroup ModulesExercise + */ +class ilExSubmissionPanelsHandlerGUI +{ + const PANEL_TYPE_SUBMISSION = 1; + const PANEL_TYPE_REVISION = 2; + + const FEEDBACK_ONLY_SUBMISSION = "submission_only"; + const FEEDBACK_FULL_SUBMISSION = "submission_feedback"; + + const GRADE_NOT_GRADED = "notgraded"; + const GRADE_PASSED = "passed"; + const GRADE_FAILED = "failed"; + + /** + * @var ilExSubmission + */ + protected $submission; + + /** + * @var ilLanguage + */ + protected $lng; + + /** + * @var ilTemplate + */ + protected $tpl; + + /** + * @var ilCtrl + */ + protected $ctrl; + + /** + * @var ilTabsGUI + */ + protected $tabs; + + /** + * @var ilExAssignment + */ + protected $assignment; + + /** + * @var \ILIAS\UI\Factory + */ + protected $ui_factory; + + /** + * @var \ILIAS\UI\Renderer + */ + protected $ui_renderer; + + /** + * @var array + */ + protected $filter; + + /** + * @var ilToolbarGUI + */ + protected $toolbar; + + /** + * @var array + */ + protected $submissions_data; + + /** + * Constructor + * @param ilExAssignment $a_assignment + * @param integer $a_user_id + */ + public function __construct(ilExAssignment $a_assignment, int $a_user_id = null) + { + global $DIC; + + $this->lng = $DIC->language(); + $this->tpl = $DIC->ui()->mainTemplate(); + $this->ctrl = $DIC->ctrl(); + $this->tabs = $DIC->tabs(); + $this->ui_factory = $DIC->ui()->factory(); + $this->ui_renderer = $DIC->ui()->renderer(); + $this->toolbar = $DIC->toolbar(); + $this->assignment = $a_assignment; + + $this->submission = null; + if($a_user_id) + { + $this->submission = new ilExSubmission($a_assignment, $a_user_id); + } + + } + + public function executeCommand() + { + $cmd = $this->ctrl->getCmd(); + $this->{$cmd."Object"}(); + } + + + //TODO structure this data. + public function setSubmissionsData($a_data) + { + $this->submissions_data = $a_data; + } + + //I do not need this + /*public function getSubmissionsData() + { + return $this->submissions_data; + }*/ + + /** + * Display a list of panels with all versioned submissions. + */ + public function showVersionsObject() + { + $revision_obj = new ilExSubmissionRevision($this->submission); + + $submissions = $revision_obj->getRevisions(); + + $this->showSubmissionPanels($this->lng->txt("exc_submission_list_versions"), self::PANEL_TYPE_REVISION, $submissions); + } + + + /** + * Display the HTML with a all submission panels + * @param string $a_title + * @param int $a_type + * @param array $a_submissions_data + */ + public function showSubmissionPanels(string $a_title, int $a_type, array $a_submissions_data) + { + $this->setBackLink(); + + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $a_title); + + $report_html = ""; + + foreach($a_submissions_data as $submission_data) + { + $feedback_data = $this->collectFeedbackDataFromPeer($submission_data); + $data = array_merge($feedback_data, $submission_data); + $report_html .= $this->getReportPanel($a_type, $data); + } + + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); + } + + + /** + * Add the Back link to the tabs. (used in submission list and submission compare) + */ + protected function setBackLink() + { + $this->tabs->clearTargets(); + $this->tabs->setBackTarget($this->lng->txt("back"), + $this->ctrl->getParentReturn($this)); + } + + + /** + * Filter initialization + * Filter by grade + * Display Feedback or not. + */ + function initFilter() + { + if($_POST["filter_status"]) { + $this->filter["status"] = trim(ilUtil::stripSlashes($_POST["filter_status"])); + } + + if($_POST["filter_feedback"]) { + $this->filter["feedback"] = trim(ilUtil::stripSlashes($_POST["filter_feedback"])); + } + + $this->lng->loadLanguageModule("search"); + + $this->toolbar->setFormAction($this->ctrl->getFormAction($this, "listTextAssignment")); + + $si_status = new ilSelectInputGUI($this->lng->txt("exc_tbl_status"), "filter_status"); + $options = array( + "" => $this->lng->txt("search_any"), + self::GRADE_NOT_GRADED => $this->lng->txt("exc_notgraded"), + self::GRADE_PASSED => $this->lng->txt("exc_passed"), + self::GRADE_FAILED => $this->lng->txt("exc_failed") + ); + $si_status->setOptions($options); + $si_status->setValue($this->filter["status"]); + + $si_feedback = new ilSelectInputGUI($this->lng->txt("feedback"), "filter_feedback"); + $options = array( + self::FEEDBACK_FULL_SUBMISSION => $this->lng->txt("submissions_feedback"), + self::FEEDBACK_ONLY_SUBMISSION => $this->lng->txt("submissions_only") + ); + $si_feedback->setOptions($options); + $si_feedback->setValue($this->filter["feedback"]); + + $this->toolbar->addInputItem($si_status, true); + $this->toolbar->addInputItem($si_feedback, true); + + //todo: old school here. + include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php"; + $submit = ilSubmitButton::getInstance(); + $submit->setCaption("filter"); + $submit->setCommand("listTextAssignment"); + $this->toolbar->addButtonInstance($submit); + } + + + /** + * Display list of panels with ALL submissions from this assignment. + */ + function listTextAssignmentObject() + { + $this->initFilter(); + + $button_print = $this->ui_factory->button()->standard($this->lng->txt('print'), "#") + ->withOnLoadCode(function($id) { + return "$('#{$id}').click(function() { window.print(); return false; });"; + }); + $this->toolbar->addSeparator(); + $this->toolbar->addComponent($button_print); + + $title = $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle(); + + $submission_data = array(); + foreach(ilExSubmission::getAllAssignmentFiles($this->assignment->getExerciseId(), $this->assignment->getId()) as $file) + { + if(trim($file["atext"])) + { + $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); + if($assignment_data != '') { + $submission_data[] = array_merge($file, $assignment_data); + } + } + } + if(count($submission_data) == 0) + { + $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); + $group_panels_tpl->setVariable('TITLE', $title); + $mtpl = new ilTemplate("tpl.message.html", true, true, "Services/Utilities"); + $mtpl->setCurrentBlock("info_message"); + $mtpl->setVariable("TEXT", $this->lng->txt("fiter_no_results")); + $mtpl->parseCurrentBlock(); + $report_html .= $mtpl->get(); + + $group_panels_tpl->setVariable('CONTENT', $report_html); + $this->tpl->setContent($group_panels_tpl->get()); + } + + $this->showSubmissionPanels($title, self::PANEL_TYPE_SUBMISSION, $submission_data); + } + + + /** + * Display list of panels with submissions from different users. + */ + public function compareTextAssignmentsObject() + { + $this->showSubmissionPanels($this->lng->txt("exc_compare_selected_submissions"), self::PANEL_TYPE_SUBMISSION, $this->submissions_data); + } + + + /** + * Render a panel with the submission report. + * @param $a_type + * @param $a_data + * @return string + * @throws ilDateTimeException + */ + public function getReportPanel(int $a_type, array $a_data) + { + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $modal = $this->getEvaluationModal($a_data); + + $actions = $this->ui_factory->dropdown()->standard(array( + $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), + )); + } + + if($a_data['status'] == self::GRADE_NOT_GRADED) { + $str_status_key = $this->lng->txt('exc_tbl_status'); + $str_status_value = $this->lng->txt('not_yet'); + } else { + $str_status_key = $this->lng->txt('exc_tbl_status_time'); + $str_status_value = ilDatePresentation::formatDate(new ilDateTime($a_data["status_time"], IL_CAL_DATETIME)); + } + + if($a_data['feedback_time']) { + $str_evaluation_key = $this->lng->txt('exc_tbl_feedback_time'); + $str_evaluation_value = ilDatePresentation::formatDate(new ilDateTime($a_data["feedback_time"], IL_CAL_DATETIME)); + } else { + $str_evaluation_key = $this->lng->txt('exc_settings_feedback'); + $str_evaluation_value = $this->lng->txt('not_yet'); + } + + $card_content = array( + $this->lng->txt("exc_tbl_submission_date") => ilDatePresentation::formatDate(new ilDateTime($a_data["udate"], IL_CAL_DATETIME)), + $str_status_key => $str_status_value, + $str_evaluation_key => $str_evaluation_value + ); + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $card_content[$this->lng->txt('feedback_given')] = $a_data['fb_given']; + $card_content[$this->lng->txt('feedback_received')] = $a_data['fb_received']; + } + $card_tpl = new ilTemplate("tpl.exc_report_details_card.html", true, true, "Modules/Exercise"); + foreach($card_content as $key => $value) + { + $card_tpl->setCurrentBlock("assingment_card"); + $card_tpl->setVariable("ROW_KEY", $key); + $card_tpl->setVariable("ROW_VALUE", $value); + $card_tpl->parseCurrentBlock(); + } + + $main_panel = $this->ui_factory->panel()->sub($a_data['uname'], $this->ui_factory->legacy($a_data['utext'])) + ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get())))); + + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + $main_panel = $main_panel->withActions($actions); + } + + $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); + //if no feedback filter the feedback is displayed. Can be list submissions or compare submissions. + if(array_key_exists("peer", $a_data) && ($this->filter["feedback"] == self::FEEDBACK_FULL_SUBMISSION) || $this->filter["feedback"] == "") + { + $feedback_tpl->setCurrentBlock("feedback"); + foreach($a_data["peer"] as $peer_id) + { + $user = new ilObjUser($peer_id); + $peer_name = $user->getFirstname()." ".$user->getLastname(); + + $feedback_tpl->setCurrentBlock("peer_feedback"); + $feedback_tpl->setVariable("PEER_NAME", $peer_name); + + $submission = new ilExSubmission($this->assignment, $a_data["uid"]); + $values = $submission->getPeerReview()->getPeerReviewValues($peer_id, $a_data["uid"]); + + $review_html = ""; + foreach($this->assignment->getPeerReviewCriteriaCatalogueItems() as $crit) + { + $crit_id = $crit->getId() + ? $crit->getId() + : $crit->getType(); + $crit->setPeerReviewContext($this->assignment, $peer_id, $a_data["uid"]); + + $review_html .= + '
'.$crit->getTitle().'
'. + '
'.$crit->getHTML($values[$crit_id]).'
'; + + } + $feedback_tpl->setVariable("PEER_FEEDBACK", $review_html); + $feedback_tpl->parseCurrentBlock(); + } + $feedback_tpl->parseCurrentBlock(); + } + $feedback_tpl->setVariable("GRADE", $this->lng->txt('grade').": ".$this->lng->txt('exc_'.$a_data['status'])); + $feedback_tpl->setVariable("COMMENT", $this->lng->txt('exc_comment')."
".$a_data['comment']); + + $feedback_panel = $this->ui_factory->panel()->sub("",$this->ui_factory->legacy($feedback_tpl->get())); + + $report = $this->ui_factory->panel()->report("", array($main_panel, $feedback_panel)); + + if($a_type == self::PANEL_TYPE_SUBMISSION) + { + return $this->ui_renderer->render([$modal,$report]); + } + + return $this->ui_renderer->render($report); + } + + + /** + * Save assignment submission grade(status) and comment from the roundtrip modal. + */ + public function saveEvaluationFromModalObject() + { + $comment = trim($_POST['comment']); + $user_id = (int)$_POST['mem_id']; + $grade = trim($_POST["grade"]); + + if($this->assignment->getId() && $user_id) { + $member_status = $this->assignment->getMemberStatus($user_id); + $member_status->setComment(ilUtil::stripSlashes($comment)); + $member_status->setStatus($grade); + if($comment != "") { + $member_status->setFeedback(true); + } + $member_status->update(); + } + ilUtil::sendSuccess($this->lng->txt("exc_status_saved"), true); + $this->ctrl->redirect($this, "listTextAssignment"); + } + + + /** + * Returns one modal containing a form where the submission can be graded/evaluated. + * @param $a_data + * @return \ILIAS\UI\Component\Modal\RoundTrip + */ + public function getEvaluationModal($a_data) + { + $modal_tpl = new ilTemplate("tpl.exc_report_evaluation_modal.html", true, true, "Modules/Exercise"); + $modal_tpl->setVariable("USER_NAME",$a_data['uname']); + + //TODO: CHECK ilias string utils. ilUtil shortenText with net blank. + $max_chars = 500; + + $u_text = strip_tags($a_data["utext"]); //otherwise will get open P + $text = $u_text; + //show more + if(strlen($u_text) > $max_chars) + { + $text = ""; + $text .= "
"; + $text .= mb_substr($u_text, 0, $max_chars); + $text .= ""; + $text .= mb_substr($u_text, $max_chars); + $text .= "
"; + $text .= ""; + } + $modal_tpl->setVariable("USER_TEXT",$text); + + $form = new ilPropertyFormGUI(); + $form->setFormAction($this->ctrl->getFormAction($this, "saveEvaluationFromModal")); + $form->setId(uniqid('form')); + + //Grade + $options = array( + self::GRADE_NOT_GRADED => $this->lng->txt("exc_notgraded"), + self::GRADE_PASSED => $this->lng->txt("exc_passed"), + self::GRADE_FAILED => $this->lng->txt("exc_failed") + ); + $si = new ilSelectInputGUI($this->lng->txt("exc_tbl_status"), "grade"); + $si->setOptions($options); + $si->setValue($a_data['status']); + $form->addItem($si); + + $item = new ilHiddenInputGUI('mem_id'); + $item->setValue($a_data['uid']); + $form->addItem($item); + + $ta = new ilTextAreaInputGUI($this->lng->txt("exc_comment"), 'comment'); + $ta->setInfo($this->lng->txt("exc_comment_for_learner_info")); + $ta->setValue($a_data['comment']); + $ta->setRows(10); + $form->addItem($ta); + + $modal_tpl->setVariable("FORM",$form->getHTML()); + + $form_id = 'form_' . $form->getId(); + $submit_btn = $this->ui_factory->button()->primary($this->lng->txt("save"), '#') + ->withOnLoadCode(function($id) use ($form_id) { + return "$('#{$id}').click(function() { $('#{$form_id}').submit(); return false; });"; + }); + + return $this->ui_factory->modal()->roundtrip(strtoupper($this->lng->txt("grade_evaluate")), $this->ui_factory->legacy($modal_tpl->get()))->withActionButtons([$submit_btn]); + } + + + /** + * Returns an array with the provided feedback + * @param $a_data array submission data + * @return $data array + */ + public function collectFeedbackDataFromPeer(array $a_data): array + { + $user = new ilObjUser($a_data["user_id"]); + $uname = $user->getFirstname()." ".$user->getLastname(); + + $data = array( + "uid" => $a_data["user_id"], + "uname" => $uname, + "udate" => $a_data["ts"], + "utext" => ilRTE::_replaceMediaObjectImageSrc($a_data["atext"], 1) // mob id to mob src + ); + + //get data peer and assign it + $peer_review = new ilExPeerReview($this->assignment); + $data["peer"] = array(); + foreach($peer_review->getPeerReviewsByPeerId($a_data['user_id']) as $key => $value) + { + $data["peer"][] = $value['giver_id']; + } + + $data["fb_received"] = count($data["peer"]); + $data["fb_given"] = $peer_review->countGivenFeedback(true, $a_data["user_id"]); + + return $data; + } + + + //TODO the confirmation can be moved to ilExerciseManagementGUI + /** + * Confirm create a new version of the submission. + */ + function confirmFreezeSubmissionObject() + { + $user_id = (int)$_GET['usr_id']; + + $cgui = new ilConfirmationGUI(); + $cgui->setFormAction($this->ctrl->getFormAction($this)); + $cgui->setHeaderText($this->lng->txt("exc_msg_sure_to_freeze_submission")); + $cgui->setCancel($this->lng->txt("cancel"), "members"); + $cgui->setConfirm($this->lng->txt("confirm"), "freezeVersion"); + + $cgui->addItem("usr_id", $user_id, + ilUserUtil::getNamePresentation((int) $user_id, false, false, "", true)); + + $this->tpl->setContent($cgui->getHTML()); + } +} \ No newline at end of file diff --git a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php index 2a6dca431fa5..b539b37a2cb9 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php @@ -6,7 +6,7 @@ * * @author Jörg Lützenkirchen * - * @ilCtrl_Calls ilExSubmissionTextGUI: + * @ilCtrl_Calls ilExSubmissionTextGUI: ilExerciseManagementGUI * @ingroup ModulesExercise */ class ilExSubmissionTextGUI extends ilExSubmissionBaseGUI @@ -65,10 +65,11 @@ public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmissio if($a_submission->isVersioned()) { - //TODO provide link to submissions history $btn_show = ilLinkButton::getInstance(); $btn_show->setCaption("exc_btn_show_submissions"); - //$btn_show->setUrl($ilCtrl->getLinkTargetByClass("ilExSubmissionsHistoryGUI", "showSubmissionsHistory")); + $ilCtrl->setParameterByClass("ilObjExerciseGUI", 'ass_id', $a_submission->getAssignment()->getId()); + $btn_show->setUrl($ilCtrl->getLinkTargetByClass(array("ilObjExerciseGUI","ilExSubmissionPanelsHandlerGUI"), "showVersions")); + $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "ass_id", ""); $btn_revise = ilLinkButton::getInstance(); $btn_revise->setPrimary(true); diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index b37a76c44383..e22b24694d84 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -11,7 +11,7 @@ * * @ilCtrl_Calls ilExerciseManagementGUI: ilFileSystemGUI, ilRepositorySearchGUI * @ilCtrl_Calls ilExerciseManagementGUI: ilExSubmissionTeamGUI, ilExSubmissionFileGUI -* @ilCtrl_Calls ilExerciseManagementGUI: ilExSubmissionTextGUI, ilExPeerReviewGUI +* @ilCtrl_Calls ilExerciseManagementGUI: ilExSubmissionTextGUI, ilExPeerReviewGUI, ilExSubmissionPanelsHandlerGUI * * @ingroup ModulesExercise */ @@ -47,11 +47,6 @@ class ilExerciseManagementGUI */ protected $ui_renderer; - /** - * @var array - */ - protected $filter; - /** * @var ilToolbarGUI */ @@ -66,15 +61,6 @@ class ilExerciseManagementGUI const VIEW_PARTICIPANT = 2; const VIEW_GRADES = 3; - const FEEDBACK_ONLY_SUBMISSION = "submission_only"; - const FEEDBACK_FULL_SUBMISSION = "submission_feedback"; - - const GRADE_NOT_GRADED = "notgraded"; - const GRADE_PASSED = "passed"; - const GRADE_FAILED = "failed"; - - const PANEL_TYPE_SUBMISSION = 1; - const PANEL_TYPE_REVISION = 2; /** * Constructor @@ -214,7 +200,11 @@ public function executeCommand() $gui = new ilExPeerReviewGUI($this->assignment, $this->initSubmission()); $ilCtrl->forwardCommand($gui); break; - + case "ilexsubmissionpanelshandlergui": + $this->ctrl->setReturn($this, "members"); + $gui = new ilExSubmissionPanelsHandlerGUI($this->assignment); + $ilCtrl->forwardCommand($gui); + break; default: $cmd = $ilCtrl->getCmd(); switch($cmd) @@ -422,6 +412,7 @@ function membersObject() $ass_type = $this->assignment->getType(); //todo change addFormButton for addButtonInstance if($ass_type == ilExAssignment::TYPE_TEXT) { + $ilToolbar->setFormAction($ilCtrl->getFormActionByClass(ilExSubmissionPanelsHandlerGUI::CLASS, "listTextAssignment")); $ilToolbar->addFormButton($lng->txt("exc_list_text_assignment"), "listTextAssignment"); } $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadSubmissions"); @@ -511,58 +502,15 @@ function saveGradesObject() // TEXT ASSIGNMENT ?! - /** - * todo: Pagination. - */ - function listTextAssignmentObject() + /*function listTextAssignmentObject() { - $this->initFilter(); - - $button_print = $this->ui_factory->button()->standard($this->lng->txt('print'), "#") - ->withOnLoadCode(function($id) { - return "$('#{$id}').click(function() { window.print(); return false; });"; - }); - $this->toolbar->addSeparator(); - $this->toolbar->addComponent($button_print); - - $title = $this->lng->txt("exc_list_text_assignment").": ".$this->assignment->getTitle(); - - $submission_data = array(); - foreach(ilExSubmission::getAllAssignmentFiles($this->assignment->getExerciseId(), $this->assignment->getId()) as $file) - { - if(trim($file["atext"])) - { - $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); - if($assignment_data != '') { - $submission_data[] = array_merge($file, $assignment_data); - } - } - } - if(count($submission_data) == 0) - { - $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); - $group_panels_tpl->setVariable('TITLE', $title); - $mtpl = new ilTemplate("tpl.message.html", true, true, "Services/Utilities"); - $mtpl->setCurrentBlock("info_message"); - $mtpl->setVariable("TEXT", $this->lng->txt("fiter_no_results")); - $mtpl->parseCurrentBlock(); - $report_html .= $mtpl->get(); - - $group_panels_tpl->setVariable('CONTENT', $report_html); - $this->tpl->setContent($group_panels_tpl->get()); - } - - $this->showSubmissionPanels($title, self::PANEL_TYPE_SUBMISSION, $submission_data); - } + $panels_gui = new ilExSubmissionPanelsHandlerGUI($this->assignment); + $this->ctrl->redirect($panels_gui, "listTextAssignment"); + }*/ - /** - * TODO -> Deal with the redirection after update the grade via action button. - */ public function compareTextAssignmentsObject() { - //participant ids selected via checkboxes $participants = array_keys($this->getMultiActionUserIds()); - foreach($participants as $participant_id) { $submission = new ilExSubmission($this->assignment,$participant_id); @@ -570,199 +518,13 @@ public function compareTextAssignmentsObject() $assignment_data = $this->assignment->getExerciseMemberAssignmentData($file["user_id"], $this->filter["status"]); $submission_data[] = array_merge($file,$assignment_data); } + $panel_handler = new ilExSubmissionPanelsHandlerGUI($this->assignment); + $panel_handler->setSubmissionsData($submission_data); - $this->showSubmissionPanels($this->lng->txt("exc_compare_selected_submissions"), self::PANEL_TYPE_SUBMISSION, $submission_data); + $this->ctrl->setCmdClass("ilExSubmissionPanelsHandlerGUI"); + $this->ctrl->forwardCommand($panel_handler); } - /** - * @param $a_type - * @param $a_data - * @return string - * @throws ilDateTimeException - */ - public function getReportPanel(int $a_type, array $a_data) - { - if($a_type == self::PANEL_TYPE_SUBMISSION) - { - $modal = $this->getEvaluationModal($a_data); - - $actions = $this->ui_factory->dropdown()->standard(array( - $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), - )); - } - - if($a_data['status'] == self::GRADE_NOT_GRADED) { - $str_status_key = $this->lng->txt('exc_tbl_status'); - $str_status_value = $this->lng->txt('not_yet'); - } else { - $str_status_key = $this->lng->txt('exc_tbl_status_time'); - $str_status_value = ilDatePresentation::formatDate(new ilDateTime($a_data["status_time"], IL_CAL_DATETIME)); - } - - if($a_data['feedback_time']) { - $str_evaluation_key = $this->lng->txt('exc_tbl_feedback_time'); - $str_evaluation_value = ilDatePresentation::formatDate(new ilDateTime($a_data["feedback_time"], IL_CAL_DATETIME)); - } else { - $str_evaluation_key = $this->lng->txt('exc_settings_feedback'); - $str_evaluation_value = $this->lng->txt('not_yet'); - } - - $card_content = array( - $this->lng->txt("exc_tbl_submission_date") => ilDatePresentation::formatDate(new ilDateTime($a_data["udate"], IL_CAL_DATETIME)), - $str_status_key => $str_status_value, - $str_evaluation_key => $str_evaluation_value - ); - if($a_type == self::PANEL_TYPE_SUBMISSION) - { - $card_content[$this->lng->txt('feedback_given')] = $a_data['fb_given']; - $card_content[$this->lng->txt('feedback_received')] = $a_data['fb_received']; - } - $card_tpl = new ilTemplate("tpl.exc_report_details_card.html", true, true, "Modules/Exercise"); - foreach($card_content as $key => $value) - { - $card_tpl->setCurrentBlock("assingment_card"); - $card_tpl->setVariable("ROW_KEY", $key); - $card_tpl->setVariable("ROW_VALUE", $value); - $card_tpl->parseCurrentBlock(); - } - - $main_panel = $this->ui_factory->panel()->sub($a_data['uname'], $this->ui_factory->legacy($a_data['utext'])) - ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get())))); - - if($a_type == self::PANEL_TYPE_SUBMISSION) - { - $main_panel = $main_panel->withActions($actions); - } - - $feedback_tpl = new ilTemplate("tpl.exc_report_feedback.html", true, true, "Modules/Exercise"); - //if no feedback filter the feedback is displayed. Can be list submissions or compare submissions. - if(array_key_exists("peer", $a_data) && ($this->filter["feedback"] == self::FEEDBACK_FULL_SUBMISSION) || $this->filter["feedback"] == "") - { - $feedback_tpl->setCurrentBlock("feedback"); - foreach($a_data["peer"] as $peer_id) - { - $user = new ilObjUser($peer_id); - $peer_name = $user->getFirstname()." ".$user->getLastname(); - - $feedback_tpl->setCurrentBlock("peer_feedback"); - $feedback_tpl->setVariable("PEER_NAME", $peer_name); - - $submission = new ilExSubmission($this->assignment, $a_data["uid"]); - $values = $submission->getPeerReview()->getPeerReviewValues($peer_id, $a_data["uid"]); - - $review_html = ""; - foreach($this->assignment->getPeerReviewCriteriaCatalogueItems() as $crit) - { - $crit_id = $crit->getId() - ? $crit->getId() - : $crit->getType(); - $crit->setPeerReviewContext($this->assignment, $peer_id, $a_data["uid"]); - - $review_html .= - '
'.$crit->getTitle().'
'. - '
'.$crit->getHTML($values[$crit_id]).'
'; - - } - $feedback_tpl->setVariable("PEER_FEEDBACK", $review_html); - $feedback_tpl->parseCurrentBlock(); - } - $feedback_tpl->parseCurrentBlock(); - } - $feedback_tpl->setVariable("GRADE", $this->lng->txt('grade').": ".$this->lng->txt('exc_'.$a_data['status'])); - $feedback_tpl->setVariable("COMMENT", $this->lng->txt('exc_comment')."
".$a_data['comment']); - - $feedback_panel = $this->ui_factory->panel()->sub("",$this->ui_factory->legacy($feedback_tpl->get())); - - $report = $this->ui_factory->panel()->report("", array($main_panel, $feedback_panel)); - - if($a_type == self::PANEL_TYPE_SUBMISSION) - { - return $this->ui_renderer->render([$modal,$report]); - } - - return $this->ui_renderer->render($report); - } - - public function getEvaluationModal($a_data) - { - $modal_tpl = new ilTemplate("tpl.exc_report_evaluation_modal.html", true, true, "Modules/Exercise"); - $modal_tpl->setVariable("USER_NAME",$a_data['uname']); - - //TODO: CHECK ilias string utils. ilUtil shortenText with net blank. - $max_chars = 500; - - $u_text = strip_tags($a_data["utext"]); //otherwise will get open P - $text = $u_text; - //show more - if(strlen($u_text) > $max_chars) - { - $text = ""; - $text .= "
"; - $text .= mb_substr($u_text, 0, $max_chars); - $text .= ""; - $text .= mb_substr($u_text, $max_chars); - $text .= "
"; - $text .= ""; - } - $modal_tpl->setVariable("USER_TEXT",$text); - - $form = new ilPropertyFormGUI(); - $form->setFormAction($this->ctrl->getFormAction($this, "saveEvaluationFromModal")); - $form->setId(uniqid('form')); - - //Grade - $options = array( - self::GRADE_NOT_GRADED => $this->lng->txt("exc_notgraded"), - self::GRADE_PASSED => $this->lng->txt("exc_passed"), - self::GRADE_FAILED => $this->lng->txt("exc_failed") - ); - $si = new ilSelectInputGUI($this->lng->txt("exc_tbl_status"), "grade"); - $si->setOptions($options); - $si->setValue($a_data['status']); - $form->addItem($si); - - $item = new ilHiddenInputGUI('mem_id'); - $item->setValue($a_data['uid']); - $form->addItem($item); - - $ta = new ilTextAreaInputGUI($this->lng->txt("exc_comment"), 'comment'); - $ta->setInfo($this->lng->txt("exc_comment_for_learner_info")); - $ta->setValue($a_data['comment']); - $ta->setRows(10); - $form->addItem($ta); - - $modal_tpl->setVariable("FORM",$form->getHTML()); - - $form_id = 'form_' . $form->getId(); - $submit_btn = $this->ui_factory->button()->primary($this->lng->txt("save"), '#') - ->withOnLoadCode(function($id) use ($form_id) { - return "$('#{$id}').click(function() { $('#{$form_id}').submit(); return false; });"; - }); - - return $this->ui_factory->modal()->roundtrip(strtoupper($this->lng->txt("grade_evaluate")), $this->ui_factory->legacy($modal_tpl->get()))->withActionButtons([$submit_btn]); - } - - /** - * Save assignment submission grade(status) and comment from the roundtrip modal. - */ - public function saveEvaluationFromModalObject() - { - $comment = trim($_POST['comment']); - $user_id = (int)$_POST['mem_id']; - $grade = trim($_POST["grade"]); - - if($this->assignment->getId() && $user_id) { - $member_status = $this->assignment->getMemberStatus($user_id); - $member_status->setComment(ilUtil::stripSlashes($comment)); - $member_status->setStatus($grade); - if($comment != "") { - $member_status->setFeedback(true); - } - $member_status->update(); - } - ilUtil::sendSuccess($this->lng->txt("exc_status_saved"), true); - $this->ctrl->redirect($this, "listTextAssignment"); - } /** * Add user as member @@ -2130,94 +1892,10 @@ protected function setIndividualDeadlineObject() } } - function initFilter() - { - if($_POST["filter_status"]) { - $this->filter["status"] = trim(ilUtil::stripSlashes($_POST["filter_status"])); - } - - if($_POST["filter_feedback"]) { - $this->filter["feedback"] = trim(ilUtil::stripSlashes($_POST["filter_feedback"])); - } - - $this->lng->loadLanguageModule("search"); - - $this->toolbar->setFormAction($this->ctrl->getFormAction($this, "listTextAssignment")); - - $si_status = new ilSelectInputGUI($this->lng->txt("exc_tbl_status"), "filter_status"); - $options = array( - "" => $this->lng->txt("search_any"), - self::GRADE_NOT_GRADED => $this->lng->txt("exc_notgraded"), - self::GRADE_PASSED => $this->lng->txt("exc_passed"), - self::GRADE_FAILED => $this->lng->txt("exc_failed") - ); - $si_status->setOptions($options); - $si_status->setValue($this->filter["status"]); - - $si_feedback = new ilSelectInputGUI($this->lng->txt("feedback"), "filter_feedback"); - $options = array( - self::FEEDBACK_FULL_SUBMISSION => $this->lng->txt("submissions_feedback"), - self::FEEDBACK_ONLY_SUBMISSION => $this->lng->txt("submissions_only") - ); - $si_feedback->setOptions($options); - $si_feedback->setValue($this->filter["feedback"]); - - $this->toolbar->addInputItem($si_status, true); - $this->toolbar->addInputItem($si_feedback, true); - - //todo: old school here. - include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php"; - $submit = ilSubmitButton::getInstance(); - $submit->setCaption("filter"); - $submit->setCommand("listTextAssignment"); - $this->toolbar->addButtonInstance($submit); - } - /** * Versioning */ - /** - * Add the Back link to the tabs. (used in submission list and submission compare) - */ - protected function setBackToMembers() - { - //tabs - $this->tabs_gui->clearTargets(); - $this->tabs_gui->setBackTarget($this->lng->txt("back"), - $this->ctrl->getLinkTarget($this, "members")); - } - - /** - * @param $a_data array submission data - * @return $data array - */ - public function collectFeedbackDataFromPeer(array $a_data): array - { - $user = new ilObjUser($a_data["user_id"]); - $uname = $user->getFirstname()." ".$user->getLastname(); - - $data = array( - "uid" => $a_data["user_id"], - "uname" => $uname, - "udate" => $a_data["ts"], - "utext" => ilRTE::_replaceMediaObjectImageSrc($a_data["atext"], 1) // mob id to mob src - ); - - //get data peer and assign it - $peer_review = new ilExPeerReview($this->assignment); - $data["peer"] = array(); - foreach($peer_review->getPeerReviewsByPeerId($a_data['user_id']) as $key => $value) - { - $data["peer"][] = $value['giver_id']; - } - - $data["fb_received"] = count($data["peer"]); - $data["fb_given"] = $peer_review->countGivenFeedback(true, $a_data["user_id"]); - - return $data; - } - /** * Freeze one submission, update and assign version number. * Example in: Exercise Submissions table. (Submissions and Grades -> Assignment View tab) @@ -2234,50 +1912,13 @@ public function freezeVersionObject() $this->ctrl->redirect($this, "members"); } - /** - * Display a list of panels with all versioned submissions. - */ - public function showVersionsObject() - { - $user_id = (int)$_GET['usr_id']; - $submission = new ilExSubmission($this->assignment, $user_id); - $revision_obj = new ilExSubmissionRevision($submission); - $submissions = $revision_obj->getRevisions(); - $this->showSubmissionPanels($this->lng->txt("exc_submission_list_versions"), self::PANEL_TYPE_REVISION, $submissions); - } - - /** - * Display the HTML with a bunch of sub panels. - * @param string $a_title - * @param array $a_submissions_data - */ - public function showSubmissionPanels(string $a_title, int $a_type, array $a_submissions_data) - { - $this->setBackToMembers(); - - $group_panels_tpl = new ilTemplate("tpl.exc_group_report_panels.html", TRUE, TRUE, "Modules/Exercise"); - $group_panels_tpl->setVariable('TITLE', $a_title); - - $report_html = ""; - - foreach($a_submissions_data as $submission_data) - { - $feedback_data = $this->collectFeedbackDataFromPeer($submission_data); - $data = array_merge($feedback_data, $submission_data); - $report_html .= $this->getReportPanel($a_type, $data); - $total_reports++; - } - - $group_panels_tpl->setVariable('CONTENT', $report_html); - $this->tpl->setContent($group_panels_tpl->get()); - } - +//TODO the confirmation can be moved to ilExerciseManagementGUI /** * Confirm create a new version of the submission. */ function confirmFreezeSubmissionObject() { - $user_id = (int)$_GET['usr_id']; + $user_id = (int)$_GET['member_id']; $cgui = new ilConfirmationGUI(); $cgui->setFormAction($this->ctrl->getFormAction($this)); diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 2cc26ce2961d..083d874bf701 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -636,7 +636,8 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($this->ass->isVersionable()) { //TODO -> check this behavior with teams! - $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "usr_id", $a_user_id); + $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "usr_id", $a_user_id); + $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $this->ass->getId()); if(!$is_submission_versioned) { @@ -649,10 +650,16 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($number_of_revisions) { + $panel_handler = new ilExSubmissionPanelsHandlerGUI($this->assignment); + $panel_handler->setSubmissionsData($submission_data); + + $this->ctrl->setCmdClass("ilExSubmissionPanelsHandlerGUI"); + $this->ctrl->forwardCommand($panel_handler); + $actions->addItem( $this->lng->txt("exc_tbl_show_frozen_versions"), "", - $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "showVersions") + $ilCtrl->getLinkTargetByClass("ilExSubmissionPanelsHandlerGUI", "showVersions") ); } } diff --git a/Modules/Exercise/classes/class.ilObjExerciseGUI.php b/Modules/Exercise/classes/class.ilObjExerciseGUI.php index a2f77e15928c..7ceb0fc62144 100755 --- a/Modules/Exercise/classes/class.ilObjExerciseGUI.php +++ b/Modules/Exercise/classes/class.ilObjExerciseGUI.php @@ -16,7 +16,7 @@ * @ilCtrl_Calls ilObjExerciseGUI: ilObjectCopyGUI, ilExportGUI * @ilCtrl_Calls ilObjExerciseGUI: ilCommonActionDispatcherGUI, ilCertificateGUI * @ilCtrl_Calls ilObjExerciseGUI: ilExAssignmentEditorGUI, ilExSubmissionGUI -* @ilCtrl_Calls ilObjExerciseGUI: ilExerciseManagementGUI, ilExcCriteriaCatalogueGUI +* @ilCtrl_Calls ilObjExerciseGUI: ilExerciseManagementGUI, ilExcCriteriaCatalogueGUI, ilExSubmissionPanelsHandlerGUI * * @ingroup ModulesExercise */ @@ -185,6 +185,28 @@ function executeCommand() $crit_gui = new ilExcCriteriaCatalogueGUI($this->object); $this->ctrl->forwardCommand($crit_gui); break; + + case "ilexsubmissionpanelshandlergui": + //TODO check if this checkRbackOrPositionPermissionAccess is needed or not. + /* + $GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess( + 'edit_submissions_grades', + 'edit_submissions_grades', + $this->object->getRefId() + ); + */ + $ass = new ilExAssignment((int)$_REQUEST["ass_id"]); + /*if(ilObjUser::_exists((int)$_REQUEST["usr_id"])) + { + $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass,(int)$_REQUEST["usr_id"]); + $this->ctrl->forwardCommand($sub_gui); + } + $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass); + */ + $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass,$ilUser->getId()); + $this->ctrl->setReturn($this, "showOverview"); + $this->ctrl->forwardCommand($sub_gui); + break; default: if(!$cmd) diff --git a/libs/composer/vendor/composer/ClassLoader.php b/libs/composer/vendor/composer/ClassLoader.php index dc02dfb114fb..95f7e0978bad 100644 --- a/libs/composer/vendor/composer/ClassLoader.php +++ b/libs/composer/vendor/composer/ClassLoader.php @@ -377,7 +377,7 @@ private function findFileWithExtension($class, $ext) $subPath = $class; while (false !== $lastPos = strrpos($subPath, '\\')) { $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; + $search = $subPath . '\\'; if (isset($this->prefixDirsPsr4[$search])) { $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) { diff --git a/libs/composer/vendor/composer/autoload_classmap.php b/libs/composer/vendor/composer/autoload_classmap.php index a0fcd913d1ac..e8e41cbe7ae1 100644 --- a/libs/composer/vendor/composer/autoload_classmap.php +++ b/libs/composer/vendor/composer/autoload_classmap.php @@ -4209,6 +4209,7 @@ 'ilExSubmissionFileGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionFileGUI.php', 'ilExSubmissionGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionGUI.php', 'ilExSubmissionObjectGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php', + 'ilExSubmissionPanelsHandlerGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php', 'ilExSubmissionRevision' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionRevision.php', 'ilExSubmissionTeamGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php', 'ilExSubmissionTextGUI' => $baseDir . '/../../Modules/Exercise/classes/class.ilExSubmissionTextGUI.php', diff --git a/libs/composer/vendor/composer/autoload_static.php b/libs/composer/vendor/composer/autoload_static.php index 11e6b8d5ed76..5464048970a8 100644 --- a/libs/composer/vendor/composer/autoload_static.php +++ b/libs/composer/vendor/composer/autoload_static.php @@ -4517,6 +4517,7 @@ class ComposerStaticInit2fffdf922cf8fdbf1f62eec345993c83 'ilExSubmissionFileGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionFileGUI.php', 'ilExSubmissionGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionGUI.php', 'ilExSubmissionObjectGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionObjectGUI.php', + 'ilExSubmissionPanelsHandlerGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php', 'ilExSubmissionRevision' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionRevision.php', 'ilExSubmissionTeamGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionTeamGUI.php', 'ilExSubmissionTextGUI' => __DIR__ . '/../..' . '/../../Modules/Exercise/classes/class.ilExSubmissionTextGUI.php', From 304c13fac7c0c6373adbc381ddbe487d632dc089 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 15 Jan 2019 12:21:03 +0100 Subject: [PATCH 41/69] executeCommand new panelshandler with user id + set return + remove useless code --- .../classes/class.ilExerciseManagementGUI.php | 2 +- .../class.ilExerciseSubmissionTableGUI.php | 7 ------ .../classes/class.ilObjExerciseGUI.php | 22 ------------------- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index e22b24694d84..291c741bf52d 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -202,7 +202,7 @@ public function executeCommand() break; case "ilexsubmissionpanelshandlergui": $this->ctrl->setReturn($this, "members"); - $gui = new ilExSubmissionPanelsHandlerGUI($this->assignment); + $gui = new ilExSubmissionPanelsHandlerGUI($this->assignment, (int)$_GET["member_id"]); $ilCtrl->forwardCommand($gui); break; default: diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 083d874bf701..8342028a20fb 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -636,7 +636,6 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($this->ass->isVersionable()) { //TODO -> check this behavior with teams! - $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "usr_id", $a_user_id); $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $this->ass->getId()); if(!$is_submission_versioned) @@ -650,12 +649,6 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) if($number_of_revisions) { - $panel_handler = new ilExSubmissionPanelsHandlerGUI($this->assignment); - $panel_handler->setSubmissionsData($submission_data); - - $this->ctrl->setCmdClass("ilExSubmissionPanelsHandlerGUI"); - $this->ctrl->forwardCommand($panel_handler); - $actions->addItem( $this->lng->txt("exc_tbl_show_frozen_versions"), "", diff --git a/Modules/Exercise/classes/class.ilObjExerciseGUI.php b/Modules/Exercise/classes/class.ilObjExerciseGUI.php index 7ceb0fc62144..f928d9cd007e 100755 --- a/Modules/Exercise/classes/class.ilObjExerciseGUI.php +++ b/Modules/Exercise/classes/class.ilObjExerciseGUI.php @@ -186,28 +186,6 @@ function executeCommand() $this->ctrl->forwardCommand($crit_gui); break; - case "ilexsubmissionpanelshandlergui": - //TODO check if this checkRbackOrPositionPermissionAccess is needed or not. - /* - $GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess( - 'edit_submissions_grades', - 'edit_submissions_grades', - $this->object->getRefId() - ); - */ - $ass = new ilExAssignment((int)$_REQUEST["ass_id"]); - /*if(ilObjUser::_exists((int)$_REQUEST["usr_id"])) - { - $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass,(int)$_REQUEST["usr_id"]); - $this->ctrl->forwardCommand($sub_gui); - } - $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass); - */ - $sub_gui = new ilExSubmissionPanelsHandlerGUI($ass,$ilUser->getId()); - $this->ctrl->setReturn($this, "showOverview"); - $this->ctrl->forwardCommand($sub_gui); - break; - default: if(!$cmd) { From 53fc7592a7710eeb3389ed684d4f7cf0f28a0166 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 30 Jan 2019 09:58:37 +0100 Subject: [PATCH 42/69] Fix ilctrl navigation and set current user if in assignment view. --- .../class.ilExSubmissionPanelsHandlerGUI.php | 16 ++++++---------- .../classes/class.ilExSubmissionTextGUI.php | 6 +++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index 18472e16c636..e84df05da6c6 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -92,14 +92,14 @@ public function __construct(ilExAssignment $a_assignment, int $a_user_id = null) $this->toolbar = $DIC->toolbar(); $this->assignment = $a_assignment; - $this->submission = null; - if($a_user_id) - { + if($a_user_id) { $this->submission = new ilExSubmission($a_assignment, $a_user_id); + } else { + $this->submission = new ilExSubmission($a_assignment, $DIC->user()->getId()); } - } + public function executeCommand() { $cmd = $this->ctrl->getCmd(); @@ -113,11 +113,6 @@ public function setSubmissionsData($a_data) $this->submissions_data = $a_data; } - //I do not need this - /*public function getSubmissionsData() - { - return $this->submissions_data; - }*/ /** * Display a list of panels with all versioned submissions. @@ -161,6 +156,7 @@ public function showSubmissionPanels(string $a_title, int $a_type, array $a_subm /** * Add the Back link to the tabs. (used in submission list and submission compare) + * TODO -> Can we move this to ilExerciseManagementGUI? it will be better */ protected function setBackLink() { @@ -254,7 +250,7 @@ function listTextAssignmentObject() $mtpl->setCurrentBlock("info_message"); $mtpl->setVariable("TEXT", $this->lng->txt("fiter_no_results")); $mtpl->parseCurrentBlock(); - $report_html .= $mtpl->get(); + $report_html = $mtpl->get(); $group_panels_tpl->setVariable('CONTENT', $report_html); $this->tpl->setContent($group_panels_tpl->get()); diff --git a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php index b539b37a2cb9..0d1011864495 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php @@ -6,7 +6,7 @@ * * @author Jörg Lützenkirchen * - * @ilCtrl_Calls ilExSubmissionTextGUI: ilExerciseManagementGUI + * @ilCtrl_Calls ilExSubmissionTextGUI: ilExerciseManagementGUI, ilExSubmissionPanelsHandlerGUI * @ingroup ModulesExercise */ class ilExSubmissionTextGUI extends ilExSubmissionBaseGUI @@ -68,8 +68,8 @@ public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmissio $btn_show = ilLinkButton::getInstance(); $btn_show->setCaption("exc_btn_show_submissions"); $ilCtrl->setParameterByClass("ilObjExerciseGUI", 'ass_id', $a_submission->getAssignment()->getId()); - $btn_show->setUrl($ilCtrl->getLinkTargetByClass(array("ilObjExerciseGUI","ilExSubmissionPanelsHandlerGUI"), "showVersions")); - $ilCtrl->setParameterByClass("ilExerciseManagementGUI", "ass_id", ""); + $btn_show->setUrl($ilCtrl->getLinkTargetByClass(array("ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionPanelsHandlerGUI"), "showVersions")); + $ilCtrl->setParameterByClass("ilObjExerciseGUI", 'ass_id', ""); $btn_revise = ilLinkButton::getInstance(); $btn_revise->setPrimary(true); From 2b99075f636e0bd422a425d88a67bc1a7a56ca98 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 30 Jan 2019 14:07:27 +0100 Subject: [PATCH 43/69] Toolbar on members: remove second formAction --- Modules/Exercise/classes/class.ilExerciseManagementGUI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 291c741bf52d..1f05f56de23a 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -412,8 +412,8 @@ function membersObject() $ass_type = $this->assignment->getType(); //todo change addFormButton for addButtonInstance if($ass_type == ilExAssignment::TYPE_TEXT) { - $ilToolbar->setFormAction($ilCtrl->getFormActionByClass(ilExSubmissionPanelsHandlerGUI::CLASS, "listTextAssignment")); - $ilToolbar->addFormButton($lng->txt("exc_list_text_assignment"), "listTextAssignment"); + $ilToolbar->addButton($this->lng->txt("exc_list_text_assignment"), + $this->ctrl->getLinkTargetByClass("ilExSubmissionPanelsHandlerGUI", "listTextAssignment")); } $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadSubmissions"); } From 3dbe0946edf136ecdcad1981a219124978128ffe Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 30 Jan 2019 15:31:24 +0100 Subject: [PATCH 44/69] Fixing the back to previous view --- .../class.ilExSubmissionPanelsHandlerGUI.php | 23 +++++++++++++++---- .../classes/class.ilExSubmissionTextGUI.php | 3 +++ .../classes/class.ilExerciseManagementGUI.php | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index e84df05da6c6..9c578e481e08 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -74,6 +74,11 @@ class ilExSubmissionPanelsHandlerGUI */ protected $submissions_data; + /** + * @var int + */ + protected $back_link; + /** * Constructor * @param ilExAssignment $a_assignment @@ -92,10 +97,21 @@ public function __construct(ilExAssignment $a_assignment, int $a_user_id = null) $this->toolbar = $DIC->toolbar(); $this->assignment = $a_assignment; - if($a_user_id) { + //going back to submissions and grades tab as default behavior + $this->back_link = $this->ctrl->getParentReturn($this); + + if($a_user_id) + { $this->submission = new ilExSubmission($a_assignment, $a_user_id); - } else { + } + else + { $this->submission = new ilExSubmission($a_assignment, $DIC->user()->getId()); + + //going back to exercise assignments tab + if($_GET['vw'] != ilExerciseManagementGUI::VIEW_GRADES) { + $this->back_link = $this->ctrl->getLinkTargetByClass("ilObjExerciseGUI", "showOverview"); + } } } @@ -161,8 +177,7 @@ public function showSubmissionPanels(string $a_title, int $a_type, array $a_subm protected function setBackLink() { $this->tabs->clearTargets(); - $this->tabs->setBackTarget($this->lng->txt("back"), - $this->ctrl->getParentReturn($this)); + $this->tabs->setBackTarget($this->lng->txt("back"),$this->back_link); } diff --git a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php index 0d1011864495..06864cacfce9 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionTextGUI.php @@ -68,8 +68,11 @@ public static function getOverviewContent(ilInfoScreenGUI $a_info, ilExSubmissio $btn_show = ilLinkButton::getInstance(); $btn_show->setCaption("exc_btn_show_submissions"); $ilCtrl->setParameterByClass("ilObjExerciseGUI", 'ass_id', $a_submission->getAssignment()->getId()); + $ilCtrl->setParameterByClass("ilObjExerciseGUI", "vw", ilExerciseManagementGUI::VIEW_ASSIGNMENT); $btn_show->setUrl($ilCtrl->getLinkTargetByClass(array("ilExerciseHandlerGUI", "ilObjExerciseGUI", "ilExerciseManagementGUI", "ilExSubmissionPanelsHandlerGUI"), "showVersions")); $ilCtrl->setParameterByClass("ilObjExerciseGUI", 'ass_id', ""); + $ilCtrl->setParameterByClass("ilObjExerciseGUI", "vw", ""); + $btn_revise = ilLinkButton::getInstance(); $btn_revise->setPrimary(true); diff --git a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php index 1f05f56de23a..f34c895578a1 100644 --- a/Modules/Exercise/classes/class.ilExerciseManagementGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseManagementGUI.php @@ -411,10 +411,12 @@ function membersObject() { $ass_type = $this->assignment->getType(); //todo change addFormButton for addButtonInstance + $this->ctrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "vw", self::VIEW_GRADES); if($ass_type == ilExAssignment::TYPE_TEXT) { $ilToolbar->addButton($this->lng->txt("exc_list_text_assignment"), $this->ctrl->getLinkTargetByClass("ilExSubmissionPanelsHandlerGUI", "listTextAssignment")); } + $this->ctrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "vw", ""); $ilToolbar->addFormButton($lng->txt("download_all_returned_files"), "downloadSubmissions"); } $this->ctrl->setParameter($this, "vw", self::VIEW_ASSIGNMENT); From d40f2779f94762099d134bfa8dcaaa8acb2aab47 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 30 Jan 2019 16:14:55 +0100 Subject: [PATCH 45/69] just add the custom db update file --- setup/sql/dbupdate_custom.php | 100 ++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 setup/sql/dbupdate_custom.php diff --git a/setup/sql/dbupdate_custom.php b/setup/sql/dbupdate_custom.php new file mode 100644 index 000000000000..d011be534313 --- /dev/null +++ b/setup/sql/dbupdate_custom.php @@ -0,0 +1,100 @@ +<#1> +tableExists("exc_submission_version")) +{ + $ilDB->createTable("exc_submission_version", array( + 'id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'returned_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'obj_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'user_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'filename' => array( + 'type' => 'text', + 'length' => 1000, + 'notnull' => false + ), + 'filetitle' => array( + 'type' => 'text', + 'length' => 1000, + 'notnull' => false + ), + 'mimetype' => array( + 'type' => 'text', + 'length' => 150, + 'notnull' => false + ), + 'ts' => array( + 'type' => 'timestamp', + 'notnull' => false + ), + 'ass_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'atext' => array( + 'type' => 'text', + 'length' => 4000, + 'notnull' => true + ), + 'late' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'team_id' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => false + ), + 'status' => array( + 'type' => 'text', + 'length' => '9' + ), + 'status_time' => array( + 'type' => 'timestamp', + 'notnull' => false + ), + 'mark' => array( + 'type' => 'text', + 'length' => '32' + ), + 'u_comment' => array( + 'type' => 'text', + 'length' => '4000' + ), + 'version' => array( + 'type' => 'integer', + 'length' => 4, + 'notnull' => true + ), + 'versioned' => array( + 'type' => 'timestamp', + 'notnull' => true + ) + ) + ); + + $ilDB->addPrimaryKey('exc_submission_version', array('id', 'user_id', 'team_id', 'ass_id')); + $ilDB->createSequence('exc_submission_version'); +} +?> +<#2> +getStructure(); +?> From 4ea360d05f48aa780f33125d26b502fbb3e7c8ff Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 30 Jan 2019 16:16:33 +0100 Subject: [PATCH 46/69] remove changes in main db file --- setup/sql/dbupdate_04.php | 92 --------------------------------------- 1 file changed, 92 deletions(-) diff --git a/setup/sql/dbupdate_04.php b/setup/sql/dbupdate_04.php index 5c9fe4f53023..da68174cfb9e 100644 --- a/setup/sql/dbupdate_04.php +++ b/setup/sql/dbupdate_04.php @@ -25276,96 +25276,4 @@ function writeCtrlClassEntry(ilPluginSlot $slot, array $plugin_data) { ), array( "1" => array("integer", 1) )); -?> -<#5431> -tableExists("exc_submission_version")) -{ - $ilDB->createTable("exc_submission_version", array( - 'id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'returned_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'obj_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'user_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'filename' => array( - 'type' => 'text', - 'length' => 1000, - 'notnull' => false - ), - 'filetitle' => array( - 'type' => 'text', - 'length' => 1000, - 'notnull' => false - ), - 'mimetype' => array( - 'type' => 'text', - 'length' => 150, - 'notnull' => false - ), - 'ts' => array( - 'type' => 'timestamp', - 'notnull' => false - ), - 'ass_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'atext' => array( - 'type' => 'text', - 'length' => 4000, - 'notnull' => true - ), - 'late' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'team_id' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => false - ), - 'status' => array( - 'type' => 'text', - 'length' => '9' - ), - 'mark' => array( - 'type' => 'text', - 'length' => '32' - ), - 'u_comment' => array( - 'type' => 'text', - 'length' => '4000' - ), - 'version' => array( - 'type' => 'integer', - 'length' => 4, - 'notnull' => true - ), - 'versioned' => array( - 'type' => 'timestamp', - 'notnull' => true - ) - ) - ); - - $ilDB->addPrimaryKey('exc_submission_version', array('id', 'user_id', 'team_id', 'ass_id')); - $ilDB->createSequence('exc_submission_version'); -} ?> \ No newline at end of file From 91723b54994ea3d8888fee2c26cc18ade005de1e Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 15:39:25 +0100 Subject: [PATCH 47/69] LM notifications when edit --- .../LearningModule/classes/class.ilLMPage.php | 10 ++ .../class.ilLearningModuleNotification.php | 135 +++++++++++++----- lang/ilias_en.lang | 3 +- 3 files changed, 109 insertions(+), 39 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLMPage.php b/Modules/LearningModule/classes/class.ilLMPage.php index e6bb85544870..8395a1857a32 100644 --- a/Modules/LearningModule/classes/class.ilLMPage.php +++ b/Modules/LearningModule/classes/class.ilLMPage.php @@ -55,6 +55,16 @@ function beforePageContentUpdate($a_page_content) } } + /** + * After update content send notifications. + */ + function afterUpdate() + { + $references = ilObject::_getAllReferences($this->getParentId()); + $notification = new ilLearningModuleNotification("update",ilNotification::TYPE_LM_PAGE, new ilObjLearningModule(reset($references)), $this->getId()); + $notification->send(); + } + } ?> diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 99095b1bd63f..1932fcda2907 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -58,10 +58,25 @@ class ilLearningModuleNotification */ protected $comment; + /** + * @var string + */ + protected $link; + + /** + * @var int + */ + protected $lm_ref_id; + + /** + * @var string + */ + protected $pg_title; + /** * ilLearningModuleNotification constructor. * @param string $a_action - * @param int $a_type + * @param int $a_type Notification type e.g. ilNotification::TYPE_LM_PAGE * @param ilObjLearningModule $a_learning_module * @param int $a_page_id * @param string|null $a_comment @@ -80,6 +95,9 @@ public function __construct(string $a_action, int $a_type, ilObjLearningModule $ $this->learning_module = $a_learning_module; $this->page_id = $a_page_id; $this->comment = $a_comment; + $this->lm_ref_id = $this->learning_module->getRefId(); + $this->link = $this->getLink(); + $this->pg_title = $this->getPageTitle(); } /** @@ -87,68 +105,40 @@ public function __construct(string $a_action, int $a_type, ilObjLearningModule $ */ public function send() { - //currently only notifications from new comments are implemented - if($this->action != "comment") - { - return; - } $lm_id = $this->learning_module->getId(); - $lm_ref_id = $this->learning_module->getRefId(); - - $pg_title = ilLMPageObject::_getPresentationTitle($this->page_id, - $this->learning_module->getPageHeader(), $this->learning_module->isActiveNumbering(), - $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lng); // #11138 //only comment implemented so always true. $ignore_threshold = ($this->action == "comment"); - $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, $this->page_id, $ignore_threshold); + $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, "", $ignore_threshold); if ($this->type == ilNotification::TYPE_LM_PAGE) { - $page_users = ilNotification::getNotificationsForObject($this->type, $this->page_id, null, $ignore_threshold); + $page_users = ilNotification::getNotificationsForObject($this->type,$lm_id, $this->page_id, null, $ignore_threshold); $users = array_merge($users, $page_users); } - if(!sizeof($users)) + + if(!sizeof($users)) { return; } + //TODO --> Should update notification for TYPE_LM_PAGE? ilNotification::updateNotificationTime(ilNotification::TYPE_LM, $lm_id, $users, $this->page_id); - // #15192 - should always be present - if($this->page_id) - { - // #18804 - see ilWikiPageGUI::preview() - $link = ilLink::_getLink("", "pg", null, $this->page_id."_".$lm_ref_id); - } - else - { - $link = ilLink::_getLink($lm_ref_id); - } foreach(array_unique($users) as $idx => $user_id) { - if($user_id != $this->ilUser->getId() && - $this->ilAccess->checkAccessOfUser($user_id, 'read', '', $lm_ref_id)) + if($user_id != $this->ilUser->getId() && + $this->ilAccess->checkAccessOfUser($user_id, 'read', '', $this->lm_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('content'); - $subject = sprintf($ulng->txt('cont_notification_comment_subject'), $this->learning_module->getTitle(), $pg_title); - $message = sprintf($ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n"; - - $message .= $ulng->txt('cont_notification_'.$this->action).":\n\n"; - $message .= $ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; - $message .= $ulng->txt('page').": ".$pg_title."\n"; - $message .= $ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; - - // include comment/note text - $message .= "\n".$ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; - - $message .= "\n".$ulng->txt('url').": ".$link; + $subject = $this->getMailSubject($ulng); + $message = $this->getMailBody($ulng,$user_id); $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); @@ -157,4 +147,73 @@ public function send() } } } + + /** + * Get Link to the LM page + * @return string + */ + protected function getLink() : string + { + // #15192 - should always be present + if($this->page_id) + { + // #18804 - see ilWikiPageGUI::preview() + return ilLink::_getLink("", "pg", null, $this->page_id."_".$this->lm_ref_id); + } + + return ilLink::_getLink($this->lm_ref_id); + + } + + /** + * Get formatted title page + * @return string + */ + protected function getPageTitle() : string + { + return ilLMPageObject::_getPresentationTitle( + $this->page_id, + $this->learning_module->getPageHeader(), $this->learning_module->isActiveNumbering(), + $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lng + ); + } + + /** + * get Subject of mail/notification + * @param ilLanguage $ulng + * @return string + */ + protected function getMailSubject(ilLanguage $ulng): string + { + if ($this->action == "comment") + { + return sprintf($ulng->txt('cont_notification_comment_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); + } + + return sprintf($ulng->txt('cont_change_notification_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); + } + + /** + * get email/notification body + * @param ilLanguage $a_ulng + * @param int $a_user_id + * @return string + */ + protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string + { + $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id))."\n\n"; + $message .= $a_ulng->txt('cont_notification_'.$this->action).":\n\n"; + $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; + $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; + if($this->type == 'comment') + { + // include comment/note text + $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; + $message .= "\n".$a_ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; + } + + $message .= "\n".$a_ulng->txt('url').": ".$this->link; + + return $message; + } } \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index c25b78ae63ec..270a8f661f1c 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14971,8 +14971,9 @@ content#:#cont_notification_activate_page#:#Activate Notification for Page content#:#cont_notification_deactivated#:#Notification Deactivated content#:#cont_notification_comment_subject#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, -content#:#cont_notification_comment#:#the following Learning Module Page has been commented +content#:#cont_notification_comment_lm#:#the following Learning Module Page has been commented content#:#cont_commented_by#:#Commented by +content#:#cont_change_notification_subject_lm#:#Learning Module "%1$s" has been changed: %2$s exercise#:#exc_enable_versioning#:#Enable versioning exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission From 7b92bdf0469d3972915e1afd668d7bd8a5b2dc65 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 15:40:20 +0100 Subject: [PATCH 48/69] [Fix 24825] Wiki notification- No content when comment --- Modules/Wiki/classes/class.ilWikiUtil.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Modules/Wiki/classes/class.ilWikiUtil.php b/Modules/Wiki/classes/class.ilWikiUtil.php index 6fa6dd8c8ab3..11ebc1e7412f 100755 --- a/Modules/Wiki/classes/class.ilWikiUtil.php +++ b/Modules/Wiki/classes/class.ilWikiUtil.php @@ -728,14 +728,6 @@ static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $message .= $ulng->txt('page').": ".$page->getTitle()."\n"; $message .= $ulng->txt('wiki_commented_by').": ".ilUserUtil::getNamePresentation($ilUser->getId())."\n"; - if($snippet) - { - $message .= "\n".$ulng->txt('content')."\n". - "----------------------------------------\n". - $snippet."\n". - "----------------------------------------\n"; - } - // include comment/note text if($a_comment) { From 6e84a14738551e15824c41d8357fae340d2853e2 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 15:56:25 +0100 Subject: [PATCH 49/69] Fix indentation --- .../class.ilLearningModuleNotification.php | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 1932fcda2907..1e08a2460142 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -58,19 +58,19 @@ class ilLearningModuleNotification */ protected $comment; - /** - * @var string - */ + /** + * @var string + */ protected $link; - /** - * @var int - */ + /** + * @var int + */ protected $lm_ref_id; - /** - * @var string - */ + /** + * @var string + */ protected $pg_title; /** @@ -95,9 +95,9 @@ public function __construct(string $a_action, int $a_type, ilObjLearningModule $ $this->learning_module = $a_learning_module; $this->page_id = $a_page_id; $this->comment = $a_comment; - $this->lm_ref_id = $this->learning_module->getRefId(); - $this->link = $this->getLink(); - $this->pg_title = $this->getPageTitle(); + $this->lm_ref_id = $this->learning_module->getRefId(); + $this->link = $this->getLink(); + $this->pg_title = $this->getPageTitle(); } /** @@ -111,11 +111,11 @@ public function send() // #11138 //only comment implemented so always true. $ignore_threshold = ($this->action == "comment"); - $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, "", $ignore_threshold); + $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, "", $ignore_threshold); if ($this->type == ilNotification::TYPE_LM_PAGE) { - $page_users = ilNotification::getNotificationsForObject($this->type,$lm_id, $this->page_id, null, $ignore_threshold); + $page_users = ilNotification::getNotificationsForObject($this->type,$lm_id, $this->page_id, null, $ignore_threshold); $users = array_merge($users, $page_users); } @@ -130,7 +130,7 @@ public function send() foreach(array_unique($users) as $idx => $user_id) { - if($user_id != $this->ilUser->getId() && + if($user_id != $this->ilUser->getId() && $this->ilAccess->checkAccessOfUser($user_id, 'read', '', $this->lm_ref_id)) { // use language of recipient to compose message @@ -148,72 +148,72 @@ public function send() } } - /** - * Get Link to the LM page - * @return string - */ + /** + * Get Link to the LM page + * @return string + */ protected function getLink() : string - { - // #15192 - should always be present - if($this->page_id) - { - // #18804 - see ilWikiPageGUI::preview() - return ilLink::_getLink("", "pg", null, $this->page_id."_".$this->lm_ref_id); - } - - return ilLink::_getLink($this->lm_ref_id); - - } - - /** - * Get formatted title page - * @return string - */ + { + // #15192 - should always be present + if($this->page_id) + { + // #18804 - see ilWikiPageGUI::preview() + return ilLink::_getLink("", "pg", null, $this->page_id."_".$this->lm_ref_id); + } + + return ilLink::_getLink($this->lm_ref_id); + + } + + /** + * Get formatted title page + * @return string + */ protected function getPageTitle() : string - { - return ilLMPageObject::_getPresentationTitle( - $this->page_id, - $this->learning_module->getPageHeader(), $this->learning_module->isActiveNumbering(), - $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lng - ); - } - - /** - * get Subject of mail/notification - * @param ilLanguage $ulng - * @return string - */ + { + return ilLMPageObject::_getPresentationTitle( + $this->page_id, + $this->learning_module->getPageHeader(), $this->learning_module->isActiveNumbering(), + $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lng + ); + } + + /** + * get Subject of mail/notification + * @param ilLanguage $ulng + * @return string + */ protected function getMailSubject(ilLanguage $ulng): string - { - if ($this->action == "comment") - { - return sprintf($ulng->txt('cont_notification_comment_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); - } - - return sprintf($ulng->txt('cont_change_notification_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); - } - - /** - * get email/notification body - * @param ilLanguage $a_ulng - * @param int $a_user_id - * @return string - */ - protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string - { - $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id))."\n\n"; - $message .= $a_ulng->txt('cont_notification_'.$this->action).":\n\n"; - $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; - $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; - if($this->type == 'comment') - { - // include comment/note text - $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; - $message .= "\n".$a_ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; - } - - $message .= "\n".$a_ulng->txt('url').": ".$this->link; - - return $message; - } + { + if ($this->action == "comment") + { + return sprintf($ulng->txt('cont_notification_comment_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); + } + + return sprintf($ulng->txt('cont_change_notification_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); + } + + /** + * get email/notification body + * @param ilLanguage $a_ulng + * @param int $a_user_id + * @return string + */ + protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string + { + $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id))."\n\n"; + $message .= $a_ulng->txt('cont_notification_'.$this->action).":\n\n"; + $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; + $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; + if($this->type == 'comment') + { + // include comment/note text + $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; + $message .= "\n".$a_ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; + } + + $message .= "\n".$a_ulng->txt('url').": ".$this->link; + + return $message; + } } \ No newline at end of file From 09a6cccd13e0a6cc858ef0bc1748858f832242bc Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 16:41:50 +0100 Subject: [PATCH 50/69] Fix notification for lm page --- .../classes/class.ilLearningModuleNotification.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 1e08a2460142..69afccb9915e 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -115,11 +115,12 @@ public function send() if ($this->type == ilNotification::TYPE_LM_PAGE) { - $page_users = ilNotification::getNotificationsForObject($this->type,$lm_id, $this->page_id, null, $ignore_threshold); + $page_users = ilNotification::getNotificationsForObject($this->type, $this->page_id, null, $ignore_threshold); $users = array_merge($users, $page_users); + ilNotification::updateNotificationTime(ilNotification::TYPE_LM_PAGE, $this->page_id, $users); } - if(!sizeof($users)) + if(!sizeof($users)) { return; } From 28c41508d0d8bfd239de4c2f7fbc32a0b0e2f832 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 16:42:49 +0100 Subject: [PATCH 51/69] remove todo --- .../classes/class.ilLearningModuleNotification.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 69afccb9915e..9de6e4e922b5 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -125,7 +125,6 @@ public function send() return; } - //TODO --> Should update notification for TYPE_LM_PAGE? ilNotification::updateNotificationTime(ilNotification::TYPE_LM, $lm_id, $users, $this->page_id); From bbf8b32877d69cc240f04e575587e10b0f168d1c Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 5 Feb 2019 17:13:56 +0100 Subject: [PATCH 52/69] LM notification with content when edit. --- .../class.ilLearningModuleNotification.php | 37 ++++++++++++++++++- lang/ilias_en.lang | 1 + 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 9de6e4e922b5..17defed713e7 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -202,7 +202,7 @@ protected function getMailSubject(ilLanguage $ulng): string protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string { $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id))."\n\n"; - $message .= $a_ulng->txt('cont_notification_'.$this->action).":\n\n"; + $message .= $a_ulng->txt('cont_notification_'.$this->action."_lm").":\n\n"; $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; if($this->type == 'comment') @@ -211,9 +211,44 @@ protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; $message .= "\n".$a_ulng->txt('comment').":\n\"".trim($this->comment)."\"\n"; } + else { + $message .= $this->getPreviewText($a_ulng); + } $message .= "\n".$a_ulng->txt('url').": ".$this->link; return $message; } + + /** + * Get first 500 characters of the recently added content + * behavior copied from ilWikiUtil->sendNotification + * @param ilLanguage $a_ulng + * @return string + */ + protected function getPreviewText(ilLanguage $a_ulng) : string + { + $page = new ilLMPageGUI($this->page_id); + $page->setRawPageContent(true); + $page->setAbstractOnly(true); + $page->setFileDownloadLink("."); + $page->setFullscreenLink("."); + $page->setSourcecodeDownloadScript("."); + $str = $page->showPage(); + $str = ilPageObject::truncateHTML($str, 500, "..."); + // making things more readable + $str = str_replace('
', "\n", $str); + $str = str_replace('
', "\n", $str); + $str = str_replace('

', "\n", $str); + $str = str_replace('', "\n", $str); + $str = trim(strip_tags($str)); + + $content = "\n".$a_ulng->txt('content')."\n". + "----------------------------------------\n". + $str."\n". + "----------------------------------------\n"; + + return $content; + + } } \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 270a8f661f1c..9be57b57e615 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14972,6 +14972,7 @@ content#:#cont_notification_deactivated#:#Notification Deactivated content#:#cont_notification_comment_subject#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment_lm#:#the following Learning Module Page has been commented +content#:#cont_notification_update_lm#:#the following Learning Module has been updated content#:#cont_commented_by#:#Commented by content#:#cont_change_notification_subject_lm#:#Learning Module "%1$s" has been changed: %2$s exercise#:#exc_enable_versioning#:#Enable versioning From 11736d70dba02c260d11d693cc6d6dfa1a949ff7 Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 6 Feb 2019 09:55:03 +0100 Subject: [PATCH 53/69] add changes to german lang file --- lang/ilias_de.lang | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 29973a190de5..d69a67c6c45a 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14971,8 +14971,10 @@ content#:#cont_notification_activate_page#:#Activate Notification for Page content#:#cont_notification_deactivated#:#Notification Deactivated content#:#cont_notification_comment_subject#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, -content#:#cont_notification_comment#:#the following Learning Module Page has been commented +content#:#cont_notification_comment_lm#:#the following Learning Module Page has been commented +content#:#cont_notification_update_lm#:#the following Learning Module has been updated content#:#cont_commented_by#:#Commented by +content#:#cont_change_notification_subject_lm#:#Learning Module "%1$s" has been changed: %2$s exercise#:#exc_enable_versioning#:#Enable versioning exercise#:#exc_enable_versioning_info#:#Allow tutors and participants to create different versions of a submission exercise#:#exc_tbl_freeze_version#:#Freeze version of Submission From 7dac9d35ccf08673656e42f14106d372eb374e1f Mon Sep 17 00:00:00 2001 From: xus Date: Wed, 6 Feb 2019 10:15:35 +0100 Subject: [PATCH 54/69] Fix comment action + lang files --- .../classes/class.ilLearningModuleNotification.php | 3 ++- lang/ilias_de.lang | 2 +- lang/ilias_en.lang | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index 17defed713e7..bef1dacc7464 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -201,11 +201,12 @@ protected function getMailSubject(ilLanguage $ulng): string */ protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string { + $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id))."\n\n"; $message .= $a_ulng->txt('cont_notification_'.$this->action."_lm").":\n\n"; $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; - if($this->type == 'comment') + if($this->action == 'comment') { // include comment/note text $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index d69a67c6c45a..4f1c150ae8ff 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14969,7 +14969,7 @@ content#:#cont_notification_deactivate_page#:#Deactivate Notification for Page content#:#cont_notification_activate_lm#:#Activate Notification for Learning Module content#:#cont_notification_activate_page#:#Activate Notification for Page content#:#cont_notification_deactivated#:#Notification Deactivated -content#:#cont_notification_comment_subject#:#A comment was added to %s: %s +content#:#cont_notification_comment_subject_lm#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment_lm#:#the following Learning Module Page has been commented content#:#cont_notification_update_lm#:#the following Learning Module has been updated diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 9be57b57e615..1944c5c923ca 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14969,7 +14969,7 @@ content#:#cont_notification_deactivate_page#:#Deactivate Notification for Page content#:#cont_notification_activate_lm#:#Activate Notification for Learning Module content#:#cont_notification_activate_page#:#Activate Notification for Page content#:#cont_notification_deactivated#:#Notification Deactivated -content#:#cont_notification_comment_subject#:#A comment was added to %s: %s +content#:#cont_notification_comment_subject_lm#:#A comment was added to %s: %s content#:#cont_change_notification_salutation#:#Hello %s, content#:#cont_notification_comment_lm#:#the following Learning Module Page has been commented content#:#cont_notification_update_lm#:#the following Learning Module has been updated From 8dcc54dbbb2ba7c81433e8e389642e4418cb7fae Mon Sep 17 00:00:00 2001 From: xus Date: Thu, 7 Feb 2019 15:59:53 +0100 Subject: [PATCH 55/69] lm constants to define the actions --- Modules/LearningModule/classes/class.ilLMPage.php | 7 ++++++- .../LearningModule/classes/class.ilLMPresentationGUI.php | 6 +++++- .../classes/class.ilLearningModuleNotification.php | 9 ++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Modules/LearningModule/classes/class.ilLMPage.php b/Modules/LearningModule/classes/class.ilLMPage.php index 8395a1857a32..daaaaf6ada2c 100644 --- a/Modules/LearningModule/classes/class.ilLMPage.php +++ b/Modules/LearningModule/classes/class.ilLMPage.php @@ -61,7 +61,12 @@ function beforePageContentUpdate($a_page_content) function afterUpdate() { $references = ilObject::_getAllReferences($this->getParentId()); - $notification = new ilLearningModuleNotification("update",ilNotification::TYPE_LM_PAGE, new ilObjLearningModule(reset($references)), $this->getId()); + $notification = new ilLearningModuleNotification( + ilLearningModuleNotification::ACTION_UPDATE, + ilNotification::TYPE_LM_PAGE, + new ilObjLearningModule(reset($references)), + $this->getId()); + $notification->send(); } diff --git a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php index 79364305bb53..82f90f6e75b6 100755 --- a/Modules/LearningModule/classes/class.ilLMPresentationGUI.php +++ b/Modules/LearningModule/classes/class.ilLMPresentationGUI.php @@ -4483,7 +4483,11 @@ function observeNoteAction($a_lm_id, $a_page_id, $a_type, $a_action, $a_note_id) $note = new ilNote($a_note_id); $note = $note->getText(); - $notification = new ilLearningModuleNotification("comment", ilNotification::TYPE_LM_PAGE, $this->lm, $a_page_id,$note); + $notification = new ilLearningModuleNotification( + ilLearningModuleNotification::ACTION_COMMENT, + ilNotification::TYPE_LM_PAGE, + $this->lm, $a_page_id,$note); + $notification->send(); } diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php index bef1dacc7464..dd3fe62d9977 100644 --- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php +++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php @@ -13,6 +13,8 @@ */ class ilLearningModuleNotification { + const ACTION_COMMENT = "comment"; + const ACTION_UPDATE = "update"; /** * @var ilObjUser */ @@ -34,6 +36,7 @@ class ilLearningModuleNotification protected $lm_set; /** + * store constant value * @var string */ protected $action; @@ -109,7 +112,7 @@ public function send() $lm_id = $this->learning_module->getId(); // #11138 //only comment implemented so always true. - $ignore_threshold = ($this->action == "comment"); + $ignore_threshold = ($this->action == self::ACTION_COMMENT); $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, "", $ignore_threshold); @@ -185,7 +188,7 @@ protected function getPageTitle() : string */ protected function getMailSubject(ilLanguage $ulng): string { - if ($this->action == "comment") + if ($this->action == self::ACTION_COMMENT) { return sprintf($ulng->txt('cont_notification_comment_subject_lm'), $this->learning_module->getTitle(), $this->pg_title); } @@ -206,7 +209,7 @@ protected function getMailBody(ilLanguage $a_ulng, int $a_user_id) : string $message .= $a_ulng->txt('cont_notification_'.$this->action."_lm").":\n\n"; $message .= $a_ulng->txt('learning module').": ".$this->learning_module->getTitle()."\n"; $message .= $a_ulng->txt('page').": ".$this->pg_title."\n"; - if($this->action == 'comment') + if($this->action == self::ACTION_COMMENT) { // include comment/note text $message .= $a_ulng->txt('cont_commented_by').": ".ilUserUtil::getNamePresentation($this->ilUser->getId())."\n"; From 55d6c4a73ffd990f255390a0b3116eb9ab80e8e8 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 18 Feb 2019 15:14:10 +0100 Subject: [PATCH 56/69] Fix participant view tab Participants view doesn't need actions and columns about the versioning. --- .../class.ilExerciseMemberTableGUI.php | 6 ++ .../class.ilExerciseSubmissionTableGUI.php | 56 +++++++++---------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php b/Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php index 8e042feafeb4..8f2faad5b99b 100644 --- a/Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseMemberTableGUI.php @@ -267,6 +267,12 @@ protected function parseModeColumns() $cols["calc_deadline"] = array($this->lng->txt("exc_tbl_calculated_deadline"), "calc_deadline"); } + if($this->ass->isVersionable()) + { + $cols["version"] = array($this->lng->txt("version"), "version"); + $this->cols_mandatory[] = "version"; + } + return $cols; } diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 8342028a20fb..6cb0996e79ae 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -226,12 +226,6 @@ protected function parseColumns() } $cols["notice"] = array($this->lng->txt("exc_tbl_notice"), "note"); - - if($this->ass->isVersionable()) - { - $cols["version"] = array($this->lng->txt("version"), "version"); - $this->cols_mandatory[] = "version"; - } return $cols; } @@ -244,18 +238,10 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $has_no_team_yet = ($a_ass->hasTeam() && !ilExAssignmentTeam::getTeamId($a_ass->getId(), $a_user_id)); - //revisions data - if($this->ass->isVersionable()) - { - $revision = new ilExSubmissionRevision($a_row['submission_obj']); - $number_of_revisions = $revision->getLastVersionNumber(); - $is_submission_versioned = $revision->isVersioned(); - } - // static columns if($this->mode == self::MODE_BY_ASSIGNMENT) - { + { if(!$a_ass->hasTeam()) { $this->tpl->setVariable("VAL_NAME", $a_row["name"]); @@ -267,6 +253,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $this->tpl->setCurrentBlock('access_warning'); $this->tpl->setVariable('PARENT_ACCESS', $info[0]["text"]); $this->tpl->parseCurrentBlock(); + } } else @@ -315,6 +302,19 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $this->tpl->setVariable("TXT_TEAM_INFO", "(".$a_row["submission_obj"]->getTeam()->getId().")"); } } + //revisions data + if($a_ass->isVersionable()) + { + $revision = new ilExSubmissionRevision($a_row['submission_obj']); + $number_of_revisions = $revision->getLastVersionNumber(); + $is_submission_versioned = $revision->isVersioned(); + + if($number_of_revisions) { + $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); + } else { + $this->tpl->setVariable("VAL_VERSION", ""); + } + } } else { @@ -485,18 +485,8 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) break; } } - - if($this->ass->isVersionable()) - { - if($number_of_revisions) { - $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); - } else { - $this->tpl->setVariable("VAL_VERSION", ""); - } - } // actions - include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; $actions = new ilAdvancedSelectionListGUI(); $actions->setId($a_ass->getId()."_".$a_user_id); @@ -633,10 +623,20 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) ); } - if($this->ass->isVersionable()) + //TODO Extract this from here. + if($a_ass->isVersionable() && $this->mode == self::MODE_BY_ASSIGNMENT) { - //TODO -> check this behavior with teams! - $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $this->ass->getId()); + $revision = new ilExSubmissionRevision($a_row['submission_obj']); + $number_of_revisions = $revision->getLastVersionNumber(); + $is_submission_versioned = $revision->isVersioned(); + + if($number_of_revisions) { + $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); + } else { + $this->tpl->setVariable("VAL_VERSION", ""); + } + + $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $a_ass->getId()); if(!$is_submission_versioned) { From aa97d60af4f0ccaa6082fa1e05979811d8295acd Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 09:24:15 +0100 Subject: [PATCH 57/69] [Fix 24850 part 1] Implement grade/evaluate revisions --- .../class.ilExSubmissionPanelsHandlerGUI.php | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index 9c578e481e08..9642ddd437cd 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -160,6 +160,7 @@ public function showSubmissionPanels(string $a_title, int $a_type, array $a_subm foreach($a_submissions_data as $submission_data) { + //TODO : feedback data in the list of versions?? should I filter here? Feedback is not showed for versions $feedback_data = $this->collectFeedbackDataFromPeer($submission_data); $data = array_merge($feedback_data, $submission_data); $report_html .= $this->getReportPanel($a_type, $data); @@ -293,15 +294,6 @@ public function compareTextAssignmentsObject() */ public function getReportPanel(int $a_type, array $a_data) { - if($a_type == self::PANEL_TYPE_SUBMISSION) - { - $modal = $this->getEvaluationModal($a_data); - - $actions = $this->ui_factory->dropdown()->standard(array( - $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), - )); - } - if($a_data['status'] == self::GRADE_NOT_GRADED) { $str_status_key = $this->lng->txt('exc_tbl_status'); $str_status_value = $this->lng->txt('not_yet'); @@ -323,7 +315,7 @@ public function getReportPanel(int $a_type, array $a_data) $str_status_key => $str_status_value, $str_evaluation_key => $str_evaluation_value ); - if($a_type == self::PANEL_TYPE_SUBMISSION) + if($this->displayFeedback($a_type)) { $card_content[$this->lng->txt('feedback_given')] = $a_data['fb_given']; $card_content[$this->lng->txt('feedback_received')] = $a_data['fb_received']; @@ -340,8 +332,14 @@ public function getReportPanel(int $a_type, array $a_data) $main_panel = $this->ui_factory->panel()->sub($a_data['uname'], $this->ui_factory->legacy($a_data['utext'])) ->withCard($this->ui_factory->card()->standard($this->lng->txt('text_assignment'))->withSections(array($this->ui_factory->legacy($card_tpl->get())))); - if($a_type == self::PANEL_TYPE_SUBMISSION) + if($this->displayCardActions($a_type)) { + $modal = $this->getEvaluationModal($a_data); + + $actions = $this->ui_factory->dropdown()->standard(array( + $this->ui_factory->button()->shy($this->lng->txt("grade_evaluate"), "#")->withOnClick($modal->getShowSignal()), + )); + $main_panel = $main_panel->withActions($actions); } @@ -386,7 +384,7 @@ public function getReportPanel(int $a_type, array $a_data) $report = $this->ui_factory->panel()->report("", array($main_panel, $feedback_panel)); - if($a_type == self::PANEL_TYPE_SUBMISSION) + if($this->displayCardActions($a_type)) { return $this->ui_renderer->render([$modal,$report]); } @@ -465,6 +463,10 @@ public function getEvaluationModal($a_data) $item->setValue($a_data['uid']); $form->addItem($item); + $version = new ilHiddenInputGUI('version_id'); + $version->setValue($a_data['version']); + $form->addItem($version); + $ta = new ilTextAreaInputGUI($this->lng->txt("exc_comment"), 'comment'); $ta->setInfo($this->lng->txt("exc_comment_for_learner_info")); $ta->setValue($a_data['comment']); @@ -534,4 +536,32 @@ function confirmFreezeSubmissionObject() $this->tpl->setContent($cgui->getHTML()); } + + /** + * @param $type + * @return bool + */ + function displayCardActions(int $type): bool + { + if($type == self::PANEL_TYPE_SUBMISSION || $type == self::PANEL_TYPE_REVISION) + { + return true; + } + + return false; + } + + /** + * @param int $type + * @return bool + */ + function displayFeedback(int $type): bool + { + if($type == self::PANEL_TYPE_SUBMISSION) + { + return true; + } + + return false; + } } \ No newline at end of file From 30ef0a0b611c06d63b2961cb5a3064b12da72177 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 11:50:43 +0100 Subject: [PATCH 58/69] [Fix 24850 Part2] Grade and evaluate revisions --- .../class.ilExSubmissionPanelsHandlerGUI.php | 38 ++++++-- .../classes/class.ilExSubmissionRevision.php | 95 ++++++++++++++++++- 2 files changed, 122 insertions(+), 11 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index 9642ddd437cd..08df49f08328 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -401,18 +401,35 @@ public function saveEvaluationFromModalObject() $comment = trim($_POST['comment']); $user_id = (int)$_POST['mem_id']; $grade = trim($_POST["grade"]); + $version_id = (int)$_POST['version_id']; - if($this->assignment->getId() && $user_id) { - $member_status = $this->assignment->getMemberStatus($user_id); - $member_status->setComment(ilUtil::stripSlashes($comment)); - $member_status->setStatus($grade); - if($comment != "") { - $member_status->setFeedback(true); + // versioned/frozen submissions + if ($version_id) + { + //update version + $revision = new ilExSubmissionRevision($this->submission); + $revision->updateRevisionStatus($version_id, $grade); + $revision->updateRevisionComment($version_id, $comment); + + ilUtil::sendSuccess($this->lng->txt("exc_revision_updated"), true); + $this->ctrl->redirect($this, "showVersions"); + } + // last/current submission + else + { + if ($this->assignment->getId() && $user_id) + { + $member_status = $this->assignment->getMemberStatus($user_id); + $member_status->setComment(ilUtil::stripSlashes($comment)); + $member_status->setStatus($grade); + if ($comment != "") { + $member_status->setFeedback(true); + } + $member_status->update(); } - $member_status->update(); + ilUtil::sendSuccess($this->lng->txt("exc_status_saved"), true); + $this->ctrl->redirect($this, "listTextAssignment"); } - ilUtil::sendSuccess($this->lng->txt("exc_status_saved"), true); - $this->ctrl->redirect($this, "listTextAssignment"); } @@ -429,6 +446,9 @@ public function getEvaluationModal($a_data) //TODO: CHECK ilias string utils. ilUtil shortenText with net blank. $max_chars = 500; + //TODO the following show more text does not work properly + + $u_text = strip_tags($a_data["utext"]); //otherwise will get open P $text = $u_text; //show more diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index a37b01f4f71c..ce18bdec1852 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -148,9 +148,21 @@ public function getRevisions() : array " ORDER BY version DESC"; $res = $this->db->query($sql); + $data = array(); while($row = $this->db->fetchAssoc($res)) { - $versions[] = $row; + $data['id'] = $row['id']; + $data['obj_id'] = $row['obj_id']; + $data['user_id'] = $row['user_id']; + $data['udate'] = $row['ts']; + $data['status_time'] = $row['status_time']; + $data['utext'] = $row['atext']; + $data['ass_id'] = $row['ass_id']; + $data['status'] = $row['status']; + $data['comment'] = $row['u_comment']; + $data['version'] = $row['version']; + $data['versioned'] = $row['versioned']; + $versions[] = $data; } return $versions ? $versions : array(); } @@ -170,4 +182,83 @@ public function sendNotification() $not->send(); } } -} \ No newline at end of file + + /** + * Get data from specific revision + * @param integer $id + * @return string|null + */ + public function getRevisionStatus(int $id) : string + { + $status = null; + + $sql = "SELECT status FROM exc_submission_version". + " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND ass_id = ".$this->ass_id. + " AND user_id = ".$this->usr_id. + " AND revision = ".$id; + + $res = $this->db->query($sql); + while($row = $this->db->fetchAssoc($res)) + { + $status = $row['status']; + } + return $status; + } + + /** + * @param int $id + * @return string|null + */ + public function getRevisionComment(int $id): string + { + $comment = null; + + $sql = "SELECT ucomment FROM exc_submission_version". + " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND ass_id = ".$this->ass_id. + " AND user_id = ".$this->usr_id. + " AND revision = ".$id; + + $res = $this->db->query($sql); + while($row = $this->db->fetchAssoc($res)) + { + $comment = $row['u_comment']; + } + return $comment; + } + + /** + * @param int $id + * @param string $comment + */ + public function updateRevisionComment(int $id, string $comment): void + { + $query = "UPDATE exc_submission_version". + " SET u_comment = ".$this->db->quote($comment, 'text'). + //"feedback_time = ".$this->db->quote(ilUtil::now(), 'timestamp'). + " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND ass_id = ".$this->ass_id. + " AND user_id = ".$this->usr_id. + " AND version = ".$id; + + $res = $this->db->manipulate($query); + } + + /** + * @param int $id + * @param string $status + */ + public function updateRevisionStatus(int $id, string $status): void + { + $query = "UPDATE exc_submission_version". + " SET status = ".$this->db->quote($status, 'text').", ". + "status_time = ".$this->db->quote(ilUtil::now(), 'timestamp'). + " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). + " AND ass_id = ".$this->ass_id. + " AND user_id = ".$this->usr_id. + " AND version = ".$id; + + $res = $this->db->manipulate($query); + } +} From a77223c83d2dd1a932d75fae9ea68741ad473f2b Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 12:28:57 +0100 Subject: [PATCH 59/69] [Fix 24850 end] new db field for feedback date + db fixes --- .../class.ilExSubmissionPanelsHandlerGUI.php | 11 +++++++++-- .../classes/class.ilExSubmissionRevision.php | 13 +++++++------ setup/sql/dbupdate_custom.php | 11 +++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index 08df49f08328..3e0cfde1a828 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -408,8 +408,15 @@ public function saveEvaluationFromModalObject() { //update version $revision = new ilExSubmissionRevision($this->submission); - $revision->updateRevisionStatus($version_id, $grade); - $revision->updateRevisionComment($version_id, $comment); + $db_grade = $revision->getRevisionStatus($version_id); + $db_comment = $revision->getRevisionComment($version_id); + + if($db_grade !== $grade) { + $revision->updateRevisionStatus($version_id, $grade); + } + if($db_comment !== $comment) { + $revision->updateRevisionComment($version_id, $comment); + } ilUtil::sendSuccess($this->lng->txt("exc_revision_updated"), true); $this->ctrl->redirect($this, "showVersions"); diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index ce18bdec1852..18d2cd92ab06 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -156,6 +156,7 @@ public function getRevisions() : array $data['user_id'] = $row['user_id']; $data['udate'] = $row['ts']; $data['status_time'] = $row['status_time']; + $data['feedback_time'] = $row['feedback_time']; $data['utext'] = $row['atext']; $data['ass_id'] = $row['ass_id']; $data['status'] = $row['status']; @@ -196,7 +197,7 @@ public function getRevisionStatus(int $id) : string " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). " AND ass_id = ".$this->ass_id. " AND user_id = ".$this->usr_id. - " AND revision = ".$id; + " AND version = ".$id; $res = $this->db->query($sql); while($row = $this->db->fetchAssoc($res)) @@ -214,11 +215,11 @@ public function getRevisionComment(int $id): string { $comment = null; - $sql = "SELECT ucomment FROM exc_submission_version". + $sql = "SELECT u_comment FROM exc_submission_version". " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). " AND ass_id = ".$this->ass_id. " AND user_id = ".$this->usr_id. - " AND revision = ".$id; + " AND version = ".$id; $res = $this->db->query($sql); while($row = $this->db->fetchAssoc($res)) @@ -235,13 +236,13 @@ public function getRevisionComment(int $id): string public function updateRevisionComment(int $id, string $comment): void { $query = "UPDATE exc_submission_version". - " SET u_comment = ".$this->db->quote($comment, 'text'). - //"feedback_time = ".$this->db->quote(ilUtil::now(), 'timestamp'). + " SET u_comment = ".$this->db->quote($comment, 'text').", ". + "feedback_time = ".$this->db->quote(ilUtil::now(), 'timestamp'). " WHERE obj_id = ".$this->submission->getAssignment()->getExerciseId(). " AND ass_id = ".$this->ass_id. " AND user_id = ".$this->usr_id. " AND version = ".$id; - + $res = $this->db->manipulate($query); } diff --git a/setup/sql/dbupdate_custom.php b/setup/sql/dbupdate_custom.php index d011be534313..8d3cdf36611d 100644 --- a/setup/sql/dbupdate_custom.php +++ b/setup/sql/dbupdate_custom.php @@ -98,3 +98,14 @@ getStructure(); ?> +<#3> +tableColumnExists("exc_submission_version","feedback_time")) +{ + $atts = array( + 'type' => 'timestamp', + 'notnull' => false, + ); + $ilDB->addTableColumn("exc_submission_version","feedback_time",$atts); +} +?> \ No newline at end of file From c5b157c421e07791ee54623f4f01222ac44a5026 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 14:00:49 +0100 Subject: [PATCH 60/69] Missing lang var --- .../Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php | 2 +- lang/ilias_de.lang | 3 ++- lang/ilias_en.lang | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php index 3e0cfde1a828..f218bc2f5a9d 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php +++ b/Modules/Exercise/classes/class.ilExSubmissionPanelsHandlerGUI.php @@ -418,7 +418,7 @@ public function saveEvaluationFromModalObject() $revision->updateRevisionComment($version_id, $comment); } - ilUtil::sendSuccess($this->lng->txt("exc_revision_updated"), true); + ilUtil::sendSuccess($this->lng->txt("exc_version_updated"), true); $this->ctrl->redirect($this, "showVersions"); } // last/current submission diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 4f1c150ae8ff..66558b1f219b 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -14985,4 +14985,5 @@ exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen exercise#:#exc_submission_list_versions#:#List of Versions exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? exc#:#exc_notification_submission_versioned#:#Submission versioned -exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. \ No newline at end of file +exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. +exc#:#exc_version_updated#:#Version updated. \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 1944c5c923ca..995fc4baa708 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -14985,4 +14985,5 @@ exercise#:#exc_submission_versioned_ok#:#Submission successfully frozen exercise#:#exc_submission_list_versions#:#List of Versions exercise#:#exc_msg_sure_to_freeze_submission#:#Are you sure you want to freeze the submission for this user? exc#:#exc_notification_submission_versioned#:#Submission versioned -exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. \ No newline at end of file +exc#:#exc_notification_submission_can_resend#:#The following submission has been versioned. You are allowed to revise your submission. +exc#:#exc_version_updated#:#Version updated. \ No newline at end of file From 42b5a7db375a33aefdc2647db367a2d2adf0d178 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 14:12:25 +0100 Subject: [PATCH 61/69] Remove return types when null allowed. --- Modules/Exercise/classes/class.ilExSubmissionRevision.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index 18d2cd92ab06..54b8cc1cf958 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -189,7 +189,7 @@ public function sendNotification() * @param integer $id * @return string|null */ - public function getRevisionStatus(int $id) : string + public function getRevisionStatus(int $id) { $status = null; @@ -211,7 +211,7 @@ public function getRevisionStatus(int $id) : string * @param int $id * @return string|null */ - public function getRevisionComment(int $id): string + public function getRevisionComment(int $id) { $comment = null; From e2503e2c5fc73f0dfaa85bfbc38533123b025b07 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 19 Feb 2019 14:15:25 +0100 Subject: [PATCH 62/69] Remove more Return type declarations --- Modules/Exercise/classes/class.ilExSubmissionRevision.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExSubmissionRevision.php b/Modules/Exercise/classes/class.ilExSubmissionRevision.php index 54b8cc1cf958..de7382415988 100644 --- a/Modules/Exercise/classes/class.ilExSubmissionRevision.php +++ b/Modules/Exercise/classes/class.ilExSubmissionRevision.php @@ -233,7 +233,7 @@ public function getRevisionComment(int $id) * @param int $id * @param string $comment */ - public function updateRevisionComment(int $id, string $comment): void + public function updateRevisionComment(int $id, string $comment) { $query = "UPDATE exc_submission_version". " SET u_comment = ".$this->db->quote($comment, 'text').", ". @@ -250,7 +250,7 @@ public function updateRevisionComment(int $id, string $comment): void * @param int $id * @param string $status */ - public function updateRevisionStatus(int $id, string $status): void + public function updateRevisionStatus(int $id, string $status) { $query = "UPDATE exc_submission_version". " SET status = ".$this->db->quote($status, 'text').", ". From daa64dd09ceb49352647a68131cba6ae365f07be Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 26 Feb 2019 11:50:09 +0100 Subject: [PATCH 63/69] lm and wiki comments via modalbox send notification Send notifications from coments in LM and Wikis using Modalboxes to users who activated this option previously. --- Services/Notes/classes/class.ilNoteGUI.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Services/Notes/classes/class.ilNoteGUI.php b/Services/Notes/classes/class.ilNoteGUI.php index ee37e2415ba6..530daa4045de 100644 --- a/Services/Notes/classes/class.ilNoteGUI.php +++ b/Services/Notes/classes/class.ilNoteGUI.php @@ -1811,6 +1811,26 @@ protected function notifyObserver($a_action, $a_note) call_user_func_array($item, $param); } } + + //ajax calls don't have callbacks in the observer. (modals) + if($this->ajax) + { + $ref = (int)$_GET['ref_id']; + if(in_array($ref,ilObject::_getAllReferences($this->rep_obj_id))) + { + if($this->obj_type == "pg") + { + $gui = new ilLMPresentationGUI(); + $gui->observeNoteAction($this->rep_obj_id,$this->obj_id,$this->obj_type,$a_action,$a_note->getId()); + } + + if($this->obj_type == "wpg") + { + $gui = new ilWikiPageGUI($this->obj_id, 0, $ref); + $gui->observeNoteAction($this->obj_id,$this->obj_id,$this->obj_type,$a_action,$a_note->getId()); + } + } + } } protected function listSortAsc() From fd6866362f88bd328d2f7ff014abda77fd15c120 Mon Sep 17 00:00:00 2001 From: xus Date: Tue, 26 Feb 2019 12:03:32 +0100 Subject: [PATCH 64/69] Refactoring - versionable: Use of ilExAssignmentTypes --- Modules/Exercise/classes/class.ilExAssignment.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExAssignment.php b/Modules/Exercise/classes/class.ilExAssignment.php index 9639a8a03f86..2f4bbcd4f963 100644 --- a/Modules/Exercise/classes/class.ilExAssignment.php +++ b/Modules/Exercise/classes/class.ilExAssignment.php @@ -2567,9 +2567,14 @@ public function getCalculatedDeadlines() return $calculated_deadlines; } + /** + * Returns if the submissions can be versioned. + * + * @return bool + */ public function isVersionable() { - if($this->getType() == ilExAssignment::TYPE_TEXT) + if($this->types->getSubmissionType($this->id)) { $exc_settings = new ilSetting("excs"); if($exc_settings->get("enable_versioning")) { From 44395f813ee2b753858d6239b71c5bc32dd3a2d2 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 11 Mar 2019 12:03:00 +0100 Subject: [PATCH 65/69] Revert "Refactoring - versionable: Use of ilExAssignmentTypes" This reverts commit fd6866362f88bd328d2f7ff014abda77fd15c120. --- Modules/Exercise/classes/class.ilExAssignment.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExAssignment.php b/Modules/Exercise/classes/class.ilExAssignment.php index 2f4bbcd4f963..9639a8a03f86 100644 --- a/Modules/Exercise/classes/class.ilExAssignment.php +++ b/Modules/Exercise/classes/class.ilExAssignment.php @@ -2567,14 +2567,9 @@ public function getCalculatedDeadlines() return $calculated_deadlines; } - /** - * Returns if the submissions can be versioned. - * - * @return bool - */ public function isVersionable() { - if($this->types->getSubmissionType($this->id)) + if($this->getType() == ilExAssignment::TYPE_TEXT) { $exc_settings = new ilSetting("excs"); if($exc_settings->get("enable_versioning")) { From b0f15793aca5cd8182a95c44f028fdc7507d6de2 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 11 Mar 2019 12:58:59 +0100 Subject: [PATCH 66/69] [Fix 25050] No freeze submission option if there is no submission --- Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 6cb0996e79ae..00ea9a1fb841 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -638,7 +638,7 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $a_ass->getId()); - if(!$is_submission_versioned) + if(!$is_submission_versioned && $a_row['submission_obj']->hasSubmitted()) { $actions->addItem( $this->lng->txt("exc_tbl_freeze_version"), From ecf139f8e0830c086b4696b9f3d98daa43ca7164 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 11 Mar 2019 13:32:54 +0100 Subject: [PATCH 67/69] [Fix 25049] column version just before status --- .../Exercise/classes/class.ilExerciseSubmissionTableGUI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index 00ea9a1fb841..bd0b81d4065e 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -32,8 +32,8 @@ abstract class ilExerciseSubmissionTableGUI extends ilTable2GUI // needs PH P5.6 for array support protected $cols_mandatory = array("name", "status"); protected $cols_default = array("login", "submission_date", "idl", "calc_deadline"); - protected $cols_order = array("image", "name", "login", "team_members", "version", - "sent_time", "submission", "calc_deadline", "idl", "status", "mark", "status_time", + protected $cols_order = array("image", "name", "login", "team_members", + "sent_time", "submission", "calc_deadline", "idl", "version", "status", "mark", "status_time", "feedback_time", "comment", "notice"); /** From 9e016c02fe1372008c34f36fadd6e15da0a08750 Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 11 Mar 2019 13:42:33 +0100 Subject: [PATCH 68/69] [Fix 25051] Freeze/d submissions as second position in the dropdown --- .../class.ilExerciseSubmissionTableGUI.php | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php index bd0b81d4065e..f262efc31426 100644 --- a/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php +++ b/Modules/Exercise/classes/class.ilExerciseSubmissionTableGUI.php @@ -515,6 +515,39 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) ); } } + + if($a_ass->isVersionable() && $this->mode == self::MODE_BY_ASSIGNMENT) + { + $revision = new ilExSubmissionRevision($a_row['submission_obj']); + $number_of_revisions = $revision->getLastVersionNumber(); + $is_submission_versioned = $revision->isVersioned(); + + if($number_of_revisions) { + $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); + } else { + $this->tpl->setVariable("VAL_VERSION", ""); + } + + $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $a_ass->getId()); + + if(!$is_submission_versioned && $a_row['submission_obj']->hasSubmitted()) + { + $actions->addItem( + $this->lng->txt("exc_tbl_freeze_version"), + "", + $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "confirmFreezeSubmission") + ); + } + + if($number_of_revisions) + { + $actions->addItem( + $this->lng->txt("exc_tbl_show_frozen_versions"), + "", + $ilCtrl->getLinkTargetByClass("ilExSubmissionPanelsHandlerGUI", "showVersions") + ); + } + } if(!$has_no_team_yet && $a_ass->hasActiveIDl() && @@ -622,40 +655,6 @@ protected function parseRow($a_user_id, ilExAssignment $a_ass, array $a_row) $ilCtrl->getLinkTargetByClass("ilExSubmissionTeamGUI", "showTeamLog") ); } - - //TODO Extract this from here. - if($a_ass->isVersionable() && $this->mode == self::MODE_BY_ASSIGNMENT) - { - $revision = new ilExSubmissionRevision($a_row['submission_obj']); - $number_of_revisions = $revision->getLastVersionNumber(); - $is_submission_versioned = $revision->isVersioned(); - - if($number_of_revisions) { - $this->tpl->setVariable("VAL_VERSION", $number_of_revisions); - } else { - $this->tpl->setVariable("VAL_VERSION", ""); - } - - $ilCtrl->setParameterByClass("ilExSubmissionPanelsHandlerGUI", "ass_id", $a_ass->getId()); - - if(!$is_submission_versioned && $a_row['submission_obj']->hasSubmitted()) - { - $actions->addItem( - $this->lng->txt("exc_tbl_freeze_version"), - "", - $ilCtrl->getLinkTargetByClass("ilExerciseManagementGUI", "confirmFreezeSubmission") - ); - } - - if($number_of_revisions) - { - $actions->addItem( - $this->lng->txt("exc_tbl_show_frozen_versions"), - "", - $ilCtrl->getLinkTargetByClass("ilExSubmissionPanelsHandlerGUI", "showVersions") - ); - } - } $this->tpl->setVariable("ACTIONS", $actions->getHTML()); } From b519d717c486ad87850213ff1579927433c233ed Mon Sep 17 00:00:00 2001 From: xus Date: Mon, 11 Mar 2019 14:13:57 +0100 Subject: [PATCH 69/69] [Fix 25049-2part] move version in members row html --- .../templates/default/tpl.exc_members_row.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/Exercise/templates/default/tpl.exc_members_row.html b/Modules/Exercise/templates/default/tpl.exc_members_row.html index b7cb9585362a..3fa90932322f 100755 --- a/Modules/Exercise/templates/default/tpl.exc_members_row.html +++ b/Modules/Exercise/templates/default/tpl.exc_members_row.html @@ -90,12 +90,6 @@ - - - {VAL_VERSION} - - - {VAL_CALC_DEADLINE} @@ -107,6 +101,12 @@ {VAL_IDL} + + + + {VAL_VERSION} + +