Skip to content

Commit 971c73c

Browse files
committed
Add configuration setting to hide edition options for surveys - refs BT#13203
1 parent 79223b6 commit 971c73c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

main/install/configuration.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,9 @@
467467
//$_configuration['allow_required_survey_questions'] = false;
468468
// Hide Survey Reporting button
469469
//$_configuration['hide_survey_reporting_button'] = false;
470+
// Hide survey edition tools for all or some surveys.
471+
//Set an asterisk to hide for all, otherwise set an array with the survey codes in which the options will be blocked
472+
//$_configuration['hide_survey_edition'] = ['codes' => []];
470473
// ------
471474

472475
// Allow career diagram, requires a DB change:

main/survey/surveyUtil.class.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
/* For licensing terms, see /license.txt */
3+
use Chamilo\CourseBundle\Entity\CSurvey;
34

45
/**
56
* This class offers a series of general utility functions for survey querying and display
@@ -2662,7 +2663,21 @@ public static function display_survey_list_for_coach()
26622663
*/
26632664
public static function modify_filter($survey_id, $drh = false)
26642665
{
2665-
$survey_id = Security::remove_XSS($survey_id);
2666+
/** @var CSurvey $survey */
2667+
$survey = Database::getManager()->find('ChamiloCourseBundle:CSurvey', $survey_id);
2668+
$hideSurveyEdition = api_get_configuration_value('hide_survey_edition');
2669+
2670+
if (false !== $hideSurveyEdition) {
2671+
if ('*' === $hideSurveyEdition['codes']) {
2672+
return '';
2673+
}
2674+
2675+
if (in_array($survey->getCode(), $hideSurveyEdition['codes'])) {
2676+
return '';
2677+
}
2678+
}
2679+
2680+
$survey_id = $survey->getSurveyId();
26662681
$return = '';
26672682
$hideReportingButton = api_get_configuration_value('hide_survey_reporting_button');
26682683

0 commit comments

Comments
 (0)