From 9a04803fb157e7b959737cedaf8d9c6c39622396 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 12 Aug 2015 18:34:16 -0500 Subject: [PATCH 1/5] Add setting to allow feedback from coaches on exercise results - refs #7448 --- .../Schema/V110/Version20150812230500.php | 75 +++++++++++++++++++ main/exercice/exercise_report.php | 16 +++- main/install/data.sql | 7 +- 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 app/Migrations/Schema/V110/Version20150812230500.php diff --git a/app/Migrations/Schema/V110/Version20150812230500.php b/app/Migrations/Schema/V110/Version20150812230500.php new file mode 100644 index 0000000000..d9cfd0cbaf --- /dev/null +++ b/app/Migrations/Schema/V110/Version20150812230500.php @@ -0,0 +1,75 @@ +addSettingCurrent( + 'allow_coach_feedback_exercises', + null, + 'radio', + 'Session', + 'false', + 'AllowCoachFeedbackExercisesTitle', + 'AllowCoachFeedbackExercisesComment', + null, + null, + 1, + true, + false, + [ + ['value' => 'true', 'text' => 'Yes'], + ['value' => 'false', 'text' => 'No'] + ] + ); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $entityManage = $this->getEntityManager(); + + $deleteOptions = $entityManage->createQueryBuilder(); + + $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o') + ->andWhere( + $deleteOptions->expr()->in( + 'o.variable', + [ + 'allow_coach_feedback_exercises' + ] + ) + ); + $deleteOptions->getQuery()->execute(); + + $deleteSettings = $entityManage->createQueryBuilder(); + $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's') + ->andWhere( + $deleteSettings->expr()->in( + 's.variable', + [ + 'allow_coach_feedback_exercises' + ] + ) + ); + $deleteSettings->getQuery()->execute(); + } + +} diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index bbc9cd2cb9..c5e2c681d4 100755 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -42,6 +42,10 @@ $TBL_TRACK_ATTEMPT = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT) $TBL_TRACK_ATTEMPT_RECORDING = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); +$allowCoachFeedbackExercises = api_get_setting( + 'allow_coach_feedback_exercises' +) == 'true'; + $course_id = api_get_course_int_id(); $exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null; $filter_user = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_by_user']) : null; @@ -52,7 +56,7 @@ if (empty($exercise_id)) { api_not_allowed(true); } -if (!$is_allowedToEdit) { +if (!$is_allowedToEdit && !$allowCoachFeedbackExercises) { api_not_allowed(true); } @@ -123,7 +127,7 @@ if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') { //Send student email @todo move this code in a class, library if (isset($_REQUEST['comments']) && $_REQUEST['comments'] == 'update' && - ($is_allowedToEdit || $is_tutor) + ($is_allowedToEdit || $is_tutor || $allowCoachFeedbackExercises) ) { //filtered by post-condition $id = intval($_GET['exeid']); @@ -239,6 +243,14 @@ if (isset($_REQUEST['comments']) && $message, api_get_user_id() ); + + if ($allowCoachFeedbackExercises) { + Display::addFlash( + Display::return_message(get_lang('MessageSent')) + ); + header('Location: ' . api_get_path(WEB_PATH)); + exit; + } } //Updating LP score here diff --git a/main/install/data.sql b/main/install/data.sql index b6a58c41fb..b8b5b726a2 100644 --- a/main/install/data.sql +++ b/main/install/data.sql @@ -313,7 +313,8 @@ VALUES ('chamilo_database_version', NULL, 'textfield', NULL, '0', 'DatabaseVersion', '', NULL, NULL, 0), ('cron_remind_course_finished_activate', NULL, 'radio', 'Crons', 'false', 'CronRemindCourseFinishedActivateTitle', 'CronRemindCourseFinishedActivateComment', NULL, NULL, 1), ('cron_remind_course_expiration_frequency', NULL, 'textfield', 'Crons', '2', 'CronRemindCourseExpirationFrequencyTitle', 'CronRemindCourseExpirationFrequencyComment', NULL, NULL, 1), -('cron_remind_course_expiration_activate', NULL, 'radio', 'Crons', 'false', 'CronRemindCourseExpirationActivateTitle', 'CronRemindCourseExpirationActivateComment', NULL, NULL, 1); +('cron_remind_course_expiration_activate', NULL, 'radio', 'Crons', 'false', 'CronRemindCourseExpirationActivateTitle', 'CronRemindCourseExpirationActivateComment', NULL, NULL, 1), +('allow_coach_feedback_exercises',NULL,'radio','Session','true','AllowCoachFeedbackExercisesTitle','AllowCoachFeedbackExercisesComment',NULL,NULL, 0); INSERT INTO settings_options (variable, value, display_text) VALUES @@ -641,7 +642,9 @@ VALUES ('cron_remind_course_finished_activate', 'false', 'No'), ('cron_remind_course_finished_activate', 'true', 'Yes'), ('cron_remind_course_expiration_activate', 'false', 'No'), -('cron_remind_course_expiration_activate', 'true', 'Yes'); +('cron_remind_course_expiration_activate', 'true', 'Yes'), +('allow_coach_feedback_exercises','true','Yes'), +('allow_coach_feedback_exercises','false','No'); INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('العربية','arabic','ar','arabic',0), From cd77a3ef861e2997df983b1233acfd6564ac9010 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 13 Aug 2015 08:47:44 -0500 Subject: [PATCH 2/5] Not allow edit feedback to coach on exercise result - refs #7448 --- main/exercice/exercise_show.php | 34 +++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 950d042afb..4e6636e56c 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -64,8 +64,14 @@ if (api_is_course_session_coach( } } +$allowCoachFeedbackExercises = api_get_setting( + 'allow_coach_feedback_exercises' +) == 'true'; + $maxEditors = intval(api_get_setting('exercise_max_ckeditors_in_page')); $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh() || api_is_student_boss(); +$isAllowedCoachToEdit = api_is_allowed_to_edit(false, true); +$isAllowedFeedback = false; //Getting results from the exe_id. This variable also contain all the information about the exercise $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id); @@ -509,7 +515,21 @@ foreach ($questionList as $questionId) { $comnt = null; if ($show_results) { - if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss()) { + if ( + $is_allowedToEdit && + $locked == false && + !api_is_drh() && + !api_is_student_boss() && + $isAllowedCoachToEdit + ) { + $isAllowedFeedback = true; + } else if (!$isAllowedCoachToEdit && $allowCoachFeedbackExercises) { + $isAllowedFeedback = true; + } + + $marksname = ''; + + if ($isAllowedFeedback) { $name = "fckdiv".$questionId; $marksname = "marksName".$questionId; if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { @@ -573,7 +593,7 @@ foreach ($questionList as $questionId) { } } - if ($is_allowedToEdit) { + if ($is_allowedToEdit && $isAllowedFeedback) { if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { $marksname = "marksName".$questionId; echo '