diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index 0257bcb606..a9d9a28a01 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -3015,6 +3015,28 @@ form .formw .freeze { /* **************************************************** CSS SKILL **************************************************** */ +#skillList .header-title{ + padding: 8px; + border-bottom: 2px solid #ddd; + font-weight: bold; + margin-bottom: 15px; +} +.skills-badges{ + display: grid; + grid-gap: 1rem; + grid-row-gap: 16px; + grid-template-columns: repeat(6, 1fr); +} +.skills-badges .item{ + display: inline-block; + width: 100%; + text-align: center; + justify-content: center; + align-items: center; +} +.skills-badges a .caption{ + text-align: center; +} .list-horizontal .list-skills{ display: grid; grid-gap: 1rem; diff --git a/main/exercise/exercise.php b/main/exercise/exercise.php index 277c5463d2..274c7fa20d 100644 --- a/main/exercise/exercise.php +++ b/main/exercise/exercise.php @@ -1250,36 +1250,29 @@ if (!empty($exerciseList)) { $hotpotatoes_exist = false; if ($is_allowedToEdit) { - $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility - FROM $TBL_DOCUMENT d - INNER JOIN $TBL_ITEM_PROPERTY ip - ON (d.id = ip.ref AND d.c_id = ip.c_id) + $sql = "SELECT d.iid, d.path as path, d.comment as comment + FROM $TBL_DOCUMENT d WHERE d.c_id = $courseId AND - ip.c_id = $courseId AND - ip.tool = '".TOOL_DOCUMENT."' AND (d.path LIKE '%htm%') AND d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' LIMIT ".$from.",".$limit; // only .htm or .html files listed } else { - $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility - FROM $TBL_DOCUMENT d - INNER JOIN $TBL_ITEM_PROPERTY ip - ON (d.id = ip.ref AND d.c_id = ip.c_id) + $sql = "SELECT d.iid, d.path as path, d.comment as comment + FROM $TBL_DOCUMENT d WHERE d.c_id = $courseId AND - ip.c_id = $courseId AND - ip.tool = '".TOOL_DOCUMENT."' AND (d.path LIKE '%htm%') AND - d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND - ip.visibility='1' + d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' LIMIT ".$from.",".$limit; } $result = Database::query($sql); +$attribute = []; + while ($row = Database :: fetch_array($result, 'ASSOC')) { + $attribute['id'][] = $row['iid']; $attribute['path'][] = $row['path']; - $attribute['visibility'][] = $row['visibility']; $attribute['comment'][] = $row['comment']; } @@ -1288,8 +1281,6 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { $hotpotatoes_exist = true; foreach ($attribute['path'] as $key => $path) { $item = ''; - $vis = $attribute['visibility'][$key]; - $active = !empty($vis); $title = GetQuizName($path, $documentPath); if ($title == '') { $title = basename($path); @@ -1297,6 +1288,26 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { // prof only if ($is_allowedToEdit) { + $visibility = api_get_item_visibility( + ['real_id' => $courseId], + TOOL_DOCUMENT, + $attribute['id'][$key], + 0 + ); + + if (!empty($sessionId)) { + if (0 == $visibility) { + continue; + } + + $visibility = api_get_item_visibility( + ['real_id' => $courseId], + TOOL_DOCUMENT, + $attribute['id'][$key], + $sessionId + ); + } + $item = Display::tag( 'td', implode(PHP_EOL, [ @@ -1307,7 +1318,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { 'file' => $path, 'uid' => $userId, ]), - ['class' => !$active ? 'text-muted' : null] + ['class' => $visibility == 0 ? 'text-muted' : null] ), ]) ); @@ -1328,7 +1339,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; // if active - if ($active) { + if ($visibility != 0) { $nbrActiveTests = $nbrActiveTests + 1; $actions .= ' '. Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL).''; @@ -1341,55 +1352,64 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { $item .= Display::tag('td', $actions); $tableRows[] = Display::tag('tr', $item); } else { + $visibility = api_get_item_visibility( + ['real_id' => $courseId], + TOOL_DOCUMENT, + $attribute['id'][$key], + $sessionId + ); + + if (0 == $visibility) { + continue; + } + // Student only - if ($active) { - $attempt = ExerciseLib::getLatestHotPotatoResult( - $path, - $userId, - api_get_course_int_id(), - api_get_session_id() - ); + $attempt = ExerciseLib::getLatestHotPotatoResult( + $path, + $userId, + api_get_course_int_id(), + api_get_session_id() + ); - $nbrActiveTests = $nbrActiveTests + 1; - $item .= Display::tag( - 'td', - Display::url( - $title, - 'showinframes.php?'.api_get_cidreq().'&'.http_build_query([ - 'file' => $path, - 'cid' => api_get_course_id(), - 'uid' => $userId, - ]) - ) - ); + $nbrActiveTests = $nbrActiveTests + 1; + $item .= Display::tag( + 'td', + Display::url( + $title, + 'showinframes.php?'.api_get_cidreq().'&'.http_build_query([ + 'file' => $path, + 'cid' => api_get_course_id(), + 'uid' => $userId, + ]) + ) + ); - if (!empty($attempt)) { - $actions = ''.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; - $attemptText = get_lang('LatestAttempt').' : '; - $attemptText .= ExerciseLib::show_score( - $attempt['exe_result'], - $attempt['exe_weighting'] - ).' '; - $attemptText .= $actions; - } else { - // No attempts. - $attemptText = get_lang('NotAttempted').' '; - } + if (!empty($attempt)) { + $actions = ''.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; + $attemptText = get_lang('LatestAttempt').' : '; + $attemptText .= ExerciseLib::show_score( + $attempt['exe_result'], + $attempt['exe_weighting'] + ).' '; + $attemptText .= $actions; + } else { + // No attempts. + $attemptText = get_lang('NotAttempted').' '; + } - $item .= Display::tag('td', $attemptText); + $item .= Display::tag('td', $attemptText); - if ($isDrhOfCourse) { - $actions = ''. - Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; + if ($isDrhOfCourse) { + $actions = ''. + Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; - $item .= Display::tag( - 'td', - $actions, - ['class' => 'td_actions'] - ); - } - $tableRows[] = Display::tag('tr', $item); + $item .= Display::tag( + 'td', + $actions, + ['class' => 'td_actions'] + ); } + $tableRows[] = Display::tag('tr', $item); } } } diff --git a/main/inc/ajax/admin.ajax.php b/main/inc/ajax/admin.ajax.php index 05f3d090e8..90ece49437 100755 --- a/main/inc/ajax/admin.ajax.php +++ b/main/inc/ajax/admin.ajax.php @@ -4,6 +4,7 @@ use Chamilo\CoreBundle\Entity\BranchSync; use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository; use GuzzleHttp\Client; +use GuzzleHttp\Exception\GuzzleException; /** * Responses to AJAX calls. @@ -78,11 +79,15 @@ switch ($action) { break; } - $latestNews = getLatestNews(); - $latestNews = json_decode($latestNews, true); + try { + $latestNews = getLatestNews(); + $latestNews = json_decode($latestNews, true); - echo Security::remove_XSS($latestNews['text'], COURSEMANAGER); - break; + echo Security::remove_XSS($latestNews['text'], COURSEMANAGER); + break; + } catch (Exception $e) { + break; + } } /** @@ -241,6 +246,7 @@ function check_system_version() * Display the latest news from the Chamilo Association for admins. * * @throws \GuzzleHttp\Exception\GuzzleException + * @throws Exception * * @return string|void */ @@ -260,7 +266,7 @@ function getLatestNews() ); if ($response->getStatusCode() !== 200) { - return; + throw new Exception(get_lang('DenyEntry')); } return $response->getBody()->getContents(); diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index cade43f679..7a6a36a2dd 100755 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -834,10 +834,10 @@ class Skill extends Model $item = ''; if ($showBadge) { - $item = $skill[$imageSize]; + $item = '
'.$skill[$imageSize].'
'; } - $name = $skill['name']; + $name = '
'. $skill['name'].'
'; if (!empty($skill['short_code'])) { $name = $skill['short_code']; } @@ -1433,15 +1433,9 @@ class Skill extends Model } if ($addTitle) { - $tableResult .= ' - - - - - - - - - - -
' . get_lang('AchievedSkills') . '
'; + $tableResult .= '
' . get_lang('AchievedSkills') . '
+
+ '; } if (!empty($skillParents)) { @@ -1541,11 +1535,7 @@ class Skill extends Model } if ($addTitle) { - $tableResult .= '
- '; + $tableResult .= ''; } $tableResult .= ''; diff --git a/main/inc/lib/usergroup.lib.php b/main/inc/lib/usergroup.lib.php index 827b1ff29a..db3b36a19a 100755 --- a/main/inc/lib/usergroup.lib.php +++ b/main/inc/lib/usergroup.lib.php @@ -1387,8 +1387,13 @@ class UserGroup extends Model $path = $path_info['dir']; // If this directory does not exist - we create it. - if (!file_exists($path)) { - @mkdir($path, api_get_permissions_for_new_directories(), true); + if (!is_dir($path)) { + $res = @mkdir($path, api_get_permissions_for_new_directories(), true); + if ($res === false) { + // There was an issue creating the directory $path, probably + // permissions-related + return false; + } } // The old photos (if any). diff --git a/main/survey/preview.php b/main/survey/preview.php index e791c9c245..659883f723 100755 --- a/main/survey/preview.php +++ b/main/survey/preview.php @@ -29,6 +29,8 @@ $surveyId = (int) $_GET['survey_id']; $userInvited = 0; $userAnonymous = 0; +$allowRequiredSurveyQuestions = api_get_configuration_value('allow_required_survey_questions'); + //query to ask if logged user is allowed to see the preview (if he is invited of he is a teacher) $sql = "SELECT survey_invitation.user FROM $table_survey_invitation survey_invitation @@ -164,6 +166,7 @@ if (api_is_course_admin() || survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort + ".($allowRequiredSurveyQuestions ? ', survey_question.is_required' : '')." FROM $table_survey_question survey_question LEFT JOIN $table_survey_question_option survey_question_option ON @@ -189,6 +192,7 @@ if (api_is_course_admin() || //$questions[$sort]['options'][intval($row['option_sort'])] = $row['option_text']; $questions[$sort]['options'][$row['question_option_id']] = $row['option_text']; $questions[$sort]['maximum_score'] = $row['max_value']; + $questions[$row['sort']]['is_required'] = $allowRequiredSurveyQuestions && $row['is_required']; } else { // If the type is a pagebreak we are finished loading the questions for this page //break; diff --git a/main/template/default/admin/settings_index.tpl b/main/template/default/admin/settings_index.tpl index ec5db74d57..bcc2fef250 100755 --- a/main/template/default/admin/settings_index.tpl +++ b/main/template/default/admin/settings_index.tpl @@ -42,6 +42,10 @@ $ .ajax('{{ web_admin_ajax_url }}?a=get_latest_news') .then(function (response) { + if (!response.length) { + return; + } + $('#chamilo-news').removeClass('hidden'); $('#chamilo-news-content').html(response); }); diff --git a/plugin/apaexportsurvey/lang/english.php b/plugin/apaexportsurvey/lang/english.php deleted file mode 100644 index fd56d68c7b..0000000000 --- a/plugin/apaexportsurvey/lang/english.php +++ /dev/null @@ -1,7 +0,0 @@ -get_info(); diff --git a/plugin/apaexportsurvey/README.md b/plugin/surveyexporttxt/README.md similarity index 76% rename from plugin/apaexportsurvey/README.md rename to plugin/surveyexporttxt/README.md index 093f04604f..f9541ae25a 100644 --- a/plugin/apaexportsurvey/README.md +++ b/plugin/surveyexporttxt/README.md @@ -1,6 +1,6 @@ -# APA Export Survey +# Survey Export TXT -Export surveys for APA. +Export surveys to TXT file. This plugin will add a new action button in survey list allowing export the survey. diff --git a/plugin/apaexportsurvey/ApaExportSurvey.php b/plugin/surveyexporttxt/SurveyExportTxtPlugin.php similarity index 80% rename from plugin/apaexportsurvey/ApaExportSurvey.php rename to plugin/surveyexporttxt/SurveyExportTxtPlugin.php index 4edda23316..9aab536451 100644 --- a/plugin/apaexportsurvey/ApaExportSurvey.php +++ b/plugin/surveyexporttxt/SurveyExportTxtPlugin.php @@ -2,12 +2,12 @@ /* For licensing terms, see /license.txt */ /** - * Class ApaExportSurvey. + * Class SurveyExportTxtPlugin. */ -class ApaExportSurvey extends Plugin +class SurveyExportTxtPlugin extends Plugin { /** - * ApaExportSurvey constructor. + * SurveyExportTxtPlugin constructor. */ protected function __construct() { @@ -15,11 +15,11 @@ class ApaExportSurvey extends Plugin 'enabled' => 'boolean', ]; - parent::__construct('0.1', 'Angel Fernado Quiroz Campos', $settings); + parent::__construct('0.1', 'Angel Fernando Quiroz Campos', $settings); } /** - * @return ApaExportSurvey|null + * @return SurveyExportTxtPlugin|null */ public static function create() { @@ -49,7 +49,7 @@ class ApaExportSurvey extends Plugin */ public static function filterModify($params) { - $enabled = api_get_plugin_setting('apaexportsurvey', 'enabled'); + $enabled = api_get_plugin_setting('SurveyExportTxtPlugin', 'enabled'); if ($enabled !== 'true') { return ''; @@ -64,7 +64,7 @@ class ApaExportSurvey extends Plugin return Display::url( Display::return_icon('export_evaluation.png', get_lang('Export'), [], $iconSize), - api_get_path(WEB_PLUGIN_PATH).'apaexportsurvey/export.php?survey='.$surveyId.'&'.api_get_cidreq() + api_get_path(WEB_PLUGIN_PATH).'surveyexporttxt/export.php?survey='.$surveyId.'&'.api_get_cidreq() ); } @@ -89,6 +89,6 @@ class ApaExportSurvey extends Plugin { Database::getManager() ->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.link LIKE :link AND t.category = :category') - ->execute(['link' => 'apaexportsurvey/start.php%', 'category' => 'plugin']); + ->execute(['link' => 'surveyexporttxt/start.php%', 'category' => 'plugin']); } } diff --git a/plugin/apaexportsurvey/export.php b/plugin/surveyexporttxt/export.php similarity index 99% rename from plugin/apaexportsurvey/export.php rename to plugin/surveyexporttxt/export.php index a5c1bbacb2..45b7a58bd0 100644 --- a/plugin/apaexportsurvey/export.php +++ b/plugin/surveyexporttxt/export.php @@ -16,7 +16,7 @@ if (empty($surveyData)) { api_not_allowed(true); } -$plugin = ApaExportSurvey::create(); +$plugin = SurveyExportTxtPlugin::create(); if ($plugin->get('enabled') !== 'true') { api_not_allowed(true); diff --git a/plugin/apaexportsurvey/install.php b/plugin/surveyexporttxt/install.php similarity index 53% rename from plugin/apaexportsurvey/install.php rename to plugin/surveyexporttxt/install.php index 04091a8266..63130fdbc6 100644 --- a/plugin/apaexportsurvey/install.php +++ b/plugin/surveyexporttxt/install.php @@ -1,4 +1,4 @@ install(); +SurveyExportTxtPlugin::create()->install(); diff --git a/plugin/surveyexporttxt/lang/english.php b/plugin/surveyexporttxt/lang/english.php new file mode 100644 index 0000000000..ce38732846 --- /dev/null +++ b/plugin/surveyexporttxt/lang/english.php @@ -0,0 +1,7 @@ +get_info(); diff --git a/plugin/apaexportsurvey/start.php b/plugin/surveyexporttxt/start.php similarity index 90% rename from plugin/apaexportsurvey/start.php rename to plugin/surveyexporttxt/start.php index 684cbc0960..7c1c04be18 100644 --- a/plugin/apaexportsurvey/start.php +++ b/plugin/surveyexporttxt/start.php @@ -6,7 +6,7 @@ require_once __DIR__.'/../../main/inc/global.inc.php'; api_protect_course_script(true); api_protect_teacher_script(); -$plugin = ApaExportSurvey::create(); +$plugin = SurveyExportTxtPlugin::create(); $courseCode = api_get_course_id(); @@ -33,10 +33,10 @@ $table->set_column_filter(8, ['SurveyUtil', 'anonymous_filter']); if (api_get_configuration_value('allow_mandatory_survey')) { $table->set_header(9, get_lang('IsMandatory'), true, ['class' => 'text-center'], ['class' => 'text-center']); $table->set_header(10, get_lang('Export'), false, ['class' => 'text-center'], ['class' => 'text-center']); - $table->set_column_filter(10, ['ApaExportSurvey', 'filterModify']); + $table->set_column_filter(10, ['SurveyExportTxtPlugin', 'filterModify']); } else { $table->set_header(9, get_lang('Export'), false, ['class' => 'text-center'], ['class' => 'text-center']); - $table->set_column_filter(9, ['ApaExportSurvey', 'filterModify']); + $table->set_column_filter(9, ['SurveyExportTxtPlugin', 'filterModify']); } $pageTitle = $plugin->get_title(); diff --git a/plugin/apaexportsurvey/uninstall.php b/plugin/surveyexporttxt/uninstall.php similarity index 52% rename from plugin/apaexportsurvey/uninstall.php rename to plugin/surveyexporttxt/uninstall.php index 2aa9696833..e66e7e1aca 100644 --- a/plugin/apaexportsurvey/uninstall.php +++ b/plugin/surveyexporttxt/uninstall.php @@ -1,4 +1,4 @@ uninstall(); +SurveyExportTxtPlugin::create()->uninstall(); diff --git a/src/Chamilo/CoreBundle/Entity/Repository/SequenceRepository.php b/src/Chamilo/CoreBundle/Entity/Repository/SequenceRepository.php index 467cced6ae..ae96b903e5 100644 --- a/src/Chamilo/CoreBundle/Entity/Repository/SequenceRepository.php +++ b/src/Chamilo/CoreBundle/Entity/Repository/SequenceRepository.php @@ -40,7 +40,7 @@ class SequenceRepository extends EntityRepository public function getRequirementAndDependencies($resourceId, $type) { $sequence = $this->findRequirementForResource($resourceId, $type); - $result = ['requirements' => '', 'dependencies' => []]; + $result = ['requirements' => [], 'dependencies' => []]; if ($sequence && $sequence->hasGraph()) { $graph = $sequence->getSequence()->getUnSerializeGraph(); $vertex = $graph->getVertex($resourceId);