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..bdea0e82e8 100755 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -42,6 +42,8 @@ $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 +54,7 @@ if (empty($exercise_id)) { api_not_allowed(true); } -if (!$is_allowedToEdit) { +if (!$is_allowedToEdit && !$allowCoachFeedbackExercises) { api_not_allowed(true); } @@ -123,7 +125,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 +241,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/exercice/exercise_show.php b/main/exercice/exercise_show.php index 950d042afb..f716eb8b76 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -64,8 +64,12 @@ 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(); +$isCoachAllowedToEdit = api_is_allowed_to_edit(false, true); +$isFeedbackAllowed = 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 +513,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() && + $isCoachAllowedToEdit + ) { + $isFeedbackAllowed = true; + } else if (!$isCoachAllowedToEdit && $allowCoachFeedbackExercises) { + $isFeedbackAllowed = true; + } + + $marksname = ''; + + if ($isFeedbackAllowed) { $name = "fckdiv".$questionId; $marksname = "marksName".$questionId; if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { @@ -573,7 +591,7 @@ foreach ($questionList as $questionId) { } } - if ($is_allowedToEdit) { + if ($is_allowedToEdit && $isFeedbackAllowed) { if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { $marksname = "marksName".$questionId; echo '