Merge remote-tracking branch 'origin/master'

pull/5209/head
Angel Fernando Quiroz Campos 9 months ago
commit c00729368d
  1. 73
      public/main/inc/lib/NotificationEvent.php
  2. 16
      public/main/survey/survey.php
  3. 4
      src/CoreBundle/Settings/LearningPathSettingsSchema.php
  4. 23
      translations/messages.en.po

@ -16,7 +16,7 @@ class NotificationEvent extends Model
'event_type',
'event_id',
];
public $extraFieldName;
public string $extraFieldName;
/**
* Constructor.
@ -43,7 +43,14 @@ class NotificationEvent extends Model
];
}
public function getForm(FormValidator $form, $data = [])
/**
* Get a prepared FormValidator form (passed as first param) with the justification fields
* @param FormValidator $form
* @param array $data
* @return FormValidator
* @throws Exception
*/
public function getForm(FormValidator $form, array $data = []): FormValidator
{
$options = $this->getEventsForSelect();
$form->addSelect('event_type', get_lang('EventType'), $options);
@ -72,7 +79,13 @@ class NotificationEvent extends Model
return $form;
}
public function getAddForm(FormValidator $form)
/**
* Get addition form for the justification notification
* @param FormValidator $form
* @return FormValidator
* @throws Exception
*/
public function getAddForm(FormValidator $form): FormValidator
{
$options = $this->getEventsForSelect();
$eventType = $form->getSubmitValue('event_type');
@ -81,7 +94,7 @@ class NotificationEvent extends Model
'event_type',
get_lang('EventType'),
$options,
['placeholder' => get_lang('SelectAnOption'), 'onchange' => 'document.add.submit()']
['placeholder' => get_lang('Please select an option'), 'onchange' => 'document.add.submit()']
);
if (!empty($eventType)) {
@ -90,14 +103,14 @@ class NotificationEvent extends Model
$form->addTextarea('content', get_lang('Content'));
$form->addText('link', get_lang('Link'), false);
$form->addCheckBox('persistent', get_lang('Persistent'));
$form->addNumeric('day_diff', get_lang('DayDiff'), false);
$form->addNumeric('day_diff', get_lang('Time difference'), false);
switch ($eventType) {
case self::JUSTIFICATION_EXPIRATION:
$plugin = Justification::create();
$list = $plugin->getList();
$list = array_column($list, 'name', 'id');
$form->addSelect('event_id', get_lang('JustificationType'), $list);
$form->addSelect('event_id', get_lang('Justification type'), $list);
break;
default:
break;
@ -108,7 +121,12 @@ class NotificationEvent extends Model
return $form;
}
public function getUserExtraData($userId)
/**
* Get notification-related user's extra field value
* @param int $userId
* @return string
*/
public function getUserExtraData(int $userId): string
{
$data = UserManager::get_extra_user_data_by_field($userId, $this->extraFieldName);
@ -182,7 +200,7 @@ class NotificationEvent extends Model
}
$eventText = $plugin->get_lang('Justification').': '.$fieldData['name'].' <br />';
$eventText .= $plugin->get_lang('JustificationDate').': '.$userJustification['date_validity'];
$eventText .= $plugin->get_lang('Justification expiration').': '.$userJustification['date_validity'];
$url = $event['link'];
if (empty($url)) {
@ -208,7 +226,13 @@ class NotificationEvent extends Model
return $notifications;
}
public function isRead($id, $extraData)
/**
* Returns whether a notification has already been read by the user or not
* @param int $id
* @param string $extraData
* @return bool
*/
public function isRead(int $id, string $extraData): bool
{
$userId = api_get_user_id();
@ -230,7 +254,12 @@ class NotificationEvent extends Model
return false;
}
public function markAsRead($id)
/**
* Mark a notification as read by the user
* @param int $id
* @return bool
*/
public function markAsRead(int $id): bool
{
if (empty($id)) {
return false;
@ -250,9 +279,17 @@ class NotificationEvent extends Model
return true;
}
public function showNotification($date, $dayDiff)
/**
* Returns whether to show some notification or not based on dates
* @param string $date
* @param int $dayDiff
* @return bool
* @throws Exception
*/
public function showNotification(string $date, int $dayDiff): bool
{
$today = api_get_utc_datetime();
$dayDiff = (string) $dayDiff;
$expiration = api_get_utc_datetime($date, false, true);
$interval = new DateInterval('P'.$dayDiff.'D');
$diff = $expiration->sub($interval);
@ -263,18 +300,4 @@ class NotificationEvent extends Model
return false;
}
public function install()
{
$sql = "CREATE TABLE IF NOT EXISTS notification_event (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
title VARCHAR(255),
content TEXT,
link TEXT,
persistent INT,
day_diff INT,
event_type VARCHAR(255)
)";
Database::query($sql);
}
}

@ -210,16 +210,16 @@ if (0 == $survey_data['survey_type']) {
$urlQuestion.'&type=comment&survey_id='.$survey_id
);
$questions .= Display::url(
Display::getMdiIcon('format-list-bulleted-type', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('SurveyMultipleAnswerWithOther')),
Display::getMdiIcon('format-list-bulleted-type', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('Multiple choice with *other* option')),
$urlQuestion.'&type=multiplechoiceother&survey_id='.$survey_id
);
if (0 == $survey_data['one_question_per_page']) {
$questions .= Display::url(
Display::getMdiIcon('thumbs-up-down', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('SurveyQuestionSelectiveDisplay')),
Display::getMdiIcon('thumbs-up-down', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('Selective display')),
$urlQuestion.'&type=selectivedisplay&survey_id='.$survey_id
);
$questions .= Display::url(
Display::getMdiIcon('format-page-break', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('Pagebreak')),
Display::getMdiIcon('format-page-break', 'ch-toolbar-icon', null, ICON_SIZE_BIG, get_lang('Page break (distinct questions)')),
$urlQuestion.'&type=pagebreak&survey_id='.$survey_id
);
}
@ -305,13 +305,13 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
}
if ('yesno' === $row['type']) {
$tool_name = get_lang('YesNo');
$tool_name = get_lang('Yes / No');
} elseif ('multiplechoice' === $row['type']) {
$tool_name = get_lang('UniqueSelect');
} elseif ('multipleresponse' === $row['type']) {
$tool_name = get_lang('MultipleChoiceMultipleAnswers');
$tool_name = get_lang('Multiple choice, multiple answers');
} elseif ('selectivedisplay' === $row['type']) {
$tool_name = get_lang('SurveyQuestionSelectiveDisplay');
$tool_name = get_lang('Selective display');
} else {
$tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type'])));
}
@ -335,7 +335,7 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
echo '<a
href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.
api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$questionId.'"
onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?', ENT_QUOTES)).'\')) return false;">'.
onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("Are you sure you want to delete the question?").'?', ENT_QUOTES)).'\')) return false;">'.
Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Delete')).'</a>';
if (3 != $survey_data['survey_type']) {
if ($question_counter > 1) {
@ -434,7 +434,7 @@ if ($is_survey_type_1) {
Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Edit')).'</a> '.
'<a
href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup"
onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('Delete surveyGroup'), $row['title']).'?', ENT_QUOTES)).'\')) return false;">'.
onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('Are you sure you want to delete %s?'), $row['title']).'?', ENT_QUOTES)).'\')) return false;">'.
Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Delete')).'</a>'.
'</td></tr>';
}

@ -113,8 +113,8 @@ class LearningPathSettingsSchema extends AbstractSettingsSchema
'scorm_api_extrafield_to_use_as_student_id',
TextType::class,
[
'label' => 'ScormApiExtrafieldToUseAsStudentIdTitle',
'help' => 'ScormApiExtrafieldToUseAsStudentIdComment',
'label' => 'Extra field to use as student ID for SCORM API',
'help' => 'The name provided will be used as the identifier of the user extra field containing an ID that the remote SCORM API will recognize as a user ID. This is only useful if your remote SCORM provider asked you for something similar.',
]
)
->add('allow_import_scorm_package_in_course_builder', YesNoType::class)

@ -13380,13 +13380,13 @@ msgid "This type does not exist"
msgstr "This type does not exist"
msgid "The survey has been created succesfully"
msgstr "The survey has been created succesfully"
msgstr "The survey has been created successfully"
msgid "You can now add questions to your survey"
msgstr "You can now add questions to your survey"
msgid "The survey has been updated succesfully"
msgstr "The survey has been updated succesfully"
msgstr "The survey has been updated successfully"
msgid "The question has been added."
msgstr "The question has been added."
@ -13584,7 +13584,7 @@ msgid "This survey code soon exists in this language"
msgstr "This survey code soon exists in this language"
msgid "The user's answers to the survey have been succesfully removed."
msgstr "The user's answers to the survey have been succesfully removed."
msgstr "The user's answers to the survey have been successfully removed."
msgid "Delete this user's answers"
msgstr "Delete this user's answers"
@ -22923,10 +22923,10 @@ msgid "Create a new Doodle type survey"
msgstr "Create a new Doodle type survey"
msgid "Remove multiplicated questions"
msgstr "Remove multiplicated questions"
msgstr "Remove multiplied questions"
msgid "Multiplicate questions"
msgstr "Multiplicate questions"
msgstr "Multiply questions"
msgid "You can use the tags {{class_name}} and {{student_full_name}} in the question to be able to multiplicate questions."
msgstr "You can use the tags {{class_name}} and {{student_full_name}} in the question to be able to multiplicate questions."
@ -23469,10 +23469,10 @@ msgid "Hi %s <br/><br/>As group tutor for the group %s you are invited to partic
msgstr "Hi %s <br/><br/>As group tutor for the group %s you are invited to participate at the following survey :"
msgid "Survey %s multiplicated"
msgstr "Survey %s multiplicated"
msgstr "Survey %s multiplied"
msgid "Survey %s not multiplicated"
msgstr "Survey %s not multiplicated"
msgstr "Survey %s not multiplied"
msgid "Export survey results"
msgstr "Export survey results"
@ -24211,3 +24211,12 @@ msgstr "FAQ"
msgid "Created with Chamilo copyright year"
msgstr "Created with Chamilo © %s"
msgid "Multiple choice with *other* option"
msgstr "Multiple choice with *other* option"
msgid "Extra field to use as student ID for SCORM API"
msgstr "Extra field to use as student ID for SCORM API"
msgid "The name provided will be used as the identifier of the user extra field containing an ID that the remote SCORM API will recognize as a user ID. This is only useful if your remote SCORM provider asked you for something similar."
msgstr "The name provided will be used as the identifier of the user extra field containing an ID that the remote SCORM API will recognize as a user ID. This is only useful if your remote SCORM provider asked you for something similar."

Loading…
Cancel
Save