Browse Source

Merge pull request #798 from AngelFQC/7448

Allow feedback from coaches on exercise results when allow_coach_to_edit_course_session is false - refs BT#7448
Angel Fernando Quiroz Campos 9 years ago
parent
commit
739c210281

+ 75 - 0
app/Migrations/Schema/V110/Version20150812230500.php

@@ -0,0 +1,75 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Application\Migrations\Schema\V110;
+
+use Application\Migrations\AbstractMigrationChamilo;
+use Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Class Version20150812230500
+ *
+ * @package Application\Migrations\Schema\V11010
+ */
+class Version20150812230500 extends AbstractMigrationChamilo
+{
+
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->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();
+    }
+
+}

+ 12 - 2
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

+ 26 - 6
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 '<div id="'.$marksname.'" style="display:none">';
@@ -708,12 +726,14 @@ echo $total_score_text;
 echo $exercise_content;
 echo $total_score_text;
 
-if (is_array($arrid) && is_array($arrmarks)) {
-	$strids = implode(",",$arrid);
-	$marksid = implode(",",$arrmarks);
+if ($isFeedbackAllowed) {
+    if (is_array($arrid) && is_array($arrmarks)) {
+        $strids = implode(",",$arrid);
+        $marksid = implode(",",$arrmarks);
+    }
 }
 
-if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss()) {
+if ($isFeedbackAllowed) {
 	if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
 		echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
 		echo '<input type = "hidden" name="lp_item_id"       value="'.$learnpath_id.'">';

+ 6 - 3
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
 ('&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;','arabic','ar','arabic',0),
@@ -1797,4 +1800,4 @@ VALUES
 ('gamification_mode', '1', 'Yes'),
 ('gamification_mode', '0', 'No');
 
-UPDATE settings_current SET selected_value = '1.10.0.43' WHERE variable = 'chamilo_database_version';
+UPDATE settings_current SET selected_value = '1.10.0.44' WHERE variable = 'chamilo_database_version';

+ 2 - 0
main/lang/english/trad4all.inc.php

@@ -7489,4 +7489,6 @@ $CronRemindCourseFinishedActivateTitle = "Send course finished notification";
 $FieldTypeAlphanumericSpaces = "Text alphanumeric characters and spaces";
 $CronRemindCourseFinishedActivateComment = "Whether to send an e-mail to students when their course (session) is finished. This requires cron tasks to be configured (see main/cron/ directory).";
 $ThanksForRegisteringToSite = "Thanks for registering to %s.";
+$AllowCoachFeedbackExercisesTitle = "Allow coaches to comment in review of exercises";
+$AllowCoachFeedbackExercisesComment = "Allow coaches to edit feedback during review of exercises";
 ?>

+ 2 - 0
main/lang/spanish/trad4all.inc.php

@@ -7514,4 +7514,6 @@ $CronRemindCourseFinishedActivateTitle = "Enviar notificación de finalización
 $FieldTypeAlphanumericSpaces = "Texto de caracteres alfanuméricos y espacios";
 $CronRemindCourseFinishedActivateComment = "Enviar un correo electrónico a los estudiantes cuando su curso (o sesión) ha finalizado. Esto requiere tareas cron para ser configurado (ver directorio main/cron/).";
 $ThanksForRegisteringToSite = "Gracias por registrarse en %s.";
+$AllowCoachFeedbackExercisesTitle = "Permitir a los tutores comentar la revisión de ejercicios";
+$AllowCoachFeedbackExercisesComment = "Permitir a los tutores editar comentarios durante la revisión de ejercicios";
 ?>