Skip to content
Permalink
Browse files

Add conf setting survey_additional_teacher_modify_actions - refs BT#1…

…5281

Allow add additional actions (as links) in survey list for teachers.
e.g. ['myplugin' => ['MyPlugin', 'urlGeneratorCallback']]
  • Loading branch information...
AngelFQC committed Feb 13, 2019
1 parent 7a4fccc commit ebe2eb117afb7080f48d15271cb8ff8b399d87fa
Showing with 35 additions and 0 deletions.
  1. +3 −0 main/install/configuration.dist.php
  2. +2 −0 main/survey/survey.php
  3. +30 −0 main/survey/surveyUtil.class.php
@@ -522,6 +522,9 @@
//$_configuration['allow_survey_availability_datetime'] = false;
// Mark the "Required" field during question creation process when displaying the form.
//$_configuration['survey_mark_question_as_required'] = false;
// Allow add additional actions (as links) in survey list for teachers.
// e.g. ['myplugin' => ['MyPlugin', 'urlGeneratorCallback']]
//$_configuration['survey_additional_teacher_modify_actions'] = [];
// ------
// Allow career diagram, requires a DB change:
@@ -159,6 +159,8 @@
}
}
$survey_actions .= SurveyUtil::getAdditionalTeacherActions($survey_id, ICON_SIZE_MEDIUM);
echo '<div class="actions">'.$survey_actions.'</div>';
$urlQuestion = api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add';
@@ -2919,6 +2919,8 @@ public static function modify_filter($survey_id, $drh = false)
if (api_is_allowed_to_edit() ||
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
) {
$actions[] = self::getAdditionalTeacherActions($survey_id);
$warning = addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES));
$actions[] = Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
@@ -2933,6 +2935,34 @@ public static function modify_filter($survey_id, $drh = false)
return implode(PHP_EOL, $actions);
}
/**
* Get the additional actions added in survey_additional_teacher_modify_actions configuration
*
* @param int $surveyId
* @param int $iconSize
*
* @return string
*/
public static function getAdditionalTeacherActions($surveyId, $iconSize = ICON_SIZE_SMALL)
{
$additionalActions = api_get_configuration_value('survey_additional_teacher_modify_actions') ?: [];
if (empty($additionalActions)) {
return '';
}
$actions = [];
foreach ($additionalActions as $additionalAction) {
$actions[] = call_user_func(
$additionalAction,
['survey_id' => $surveyId, 'icon_size' => $iconSize]
);
}
return implode(PHP_EOL, $actions);
}
/**
* @param int $survey_id
*

0 comments on commit ebe2eb1

Please sign in to comment.
You can’t perform that action at this time.