Add configuration "hide_skill_levels" see BT#13768

- Hides levels options when assigning a skill
pull/2487/head
jmontoyaa 7 years ago
parent 7518a6ba49
commit 484ea7a2ef
  1. 18
      main/badge/assign.php
  2. 37
      main/badge/issued.php
  3. 2
      main/badge/issued_all.php
  4. 5
      main/install/configuration.dist.php
  5. 23
      main/template/default/skill/issued.tpl
  6. 3
      main/template/default/skill/issued_all.tpl

@ -204,8 +204,14 @@ $form->addHidden('sub_skill_list', $subSkillListToString);
$form->addHidden('user', $user->getId());
$form->addHidden('id', $skillId);
$form->addRule('skill', get_lang('ThisFieldIsRequired'), 'required');
$form->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel);
//$form->addRule('acquired_level', get_lang('ThisFieldIsRequired'), 'required');
$showLevels = api_get_configuration_value('hide_skill_levels') === false;
if ($showLevels) {
$form->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel);
//$form->addRule('acquired_level', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addTextarea('argumentation', get_lang('Argumentation'), ['rows' => 6]);
$form->addRule('argumentation', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule(
@ -260,8 +266,12 @@ if ($form->validate()) {
$skillUser = new SkillRelUser();
$skillUser->setUser($user);
$skillUser->setSkill($skill);
$level = $skillLevelRepo->find(intval($values['acquired_level']));
$skillUser->setAcquiredLevel($level);
if ($showLevels) {
$level = $skillLevelRepo->find(intval($values['acquired_level']));
$skillUser->setAcquiredLevel($level);
}
$skillUser->setArgumentation($values['argumentation']);
$skillUser->setArgumentationAuthorId(api_get_user_id());
$skillUser->setAcquiredSkillAt(new DateTime());

@ -48,6 +48,8 @@ if (!$user || !$skill) {
Skill::isAllowed($user->getId());
$showLevels = api_get_configuration_value('hide_skill_levels') === false;
$userInfo = [
'id' => $user->getId(),
'complete_name' => $user->getCompleteName()
@ -168,24 +170,26 @@ if ($profile) {
}
}
$formAcquiredLevel = new FormValidator('acquired_level');
$formAcquiredLevel->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel);
$formAcquiredLevel->addHidden('user', $skillIssue->getUser()->getId());
$formAcquiredLevel->addHidden('issue', $skillIssue->getId());
$formAcquiredLevel->addButtonSave(get_lang('Save'));
if ($showLevels) {
$formAcquiredLevel = new FormValidator('acquired_level');
$formAcquiredLevel->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel);
$formAcquiredLevel->addHidden('user', $skillIssue->getUser()->getId());
$formAcquiredLevel->addHidden('issue', $skillIssue->getId());
$formAcquiredLevel->addButtonSave(get_lang('Save'));
if ($formAcquiredLevel->validate() && $allowComment) {
$values = $formAcquiredLevel->exportValues();
if ($formAcquiredLevel->validate() && $allowComment) {
$values = $formAcquiredLevel->exportValues();
$level = $skillLevelRepo->find(intval($values['acquired_level']));
$skillIssue->setAcquiredLevel($level);
$level = $skillLevelRepo->find(intval($values['acquired_level']));
$skillIssue->setAcquiredLevel($level);
$entityManager->persist($skillIssue);
$entityManager->flush();
Display::addFlash(Display::return_message(get_lang('Saved')));
$entityManager->persist($skillIssue);
$entityManager->flush();
Display::addFlash(Display::return_message(get_lang('Saved')));
header("Location: ".$skillIssue->getIssueUrl());
exit;
header("Location: ".$skillIssue->getIssueUrl());
exit;
}
}
$form = new FormValidator('comment');
@ -275,9 +279,12 @@ $template->assign('issue_info', $skillIssueInfo);
$template->assign('allow_comment', $allowComment);
$template->assign('allow_download_export', $allowDownloadExport);
$template->assign('comment_form', $form->returnForm());
$template->assign('acquired_level_form', $formAcquiredLevel->returnForm());
if ($showLevels) {
$template->assign('acquired_level_form', $formAcquiredLevel->returnForm());
}
$template->assign('badge_error', $badgeInfoError);
$template->assign('personal_badge', $personalBadge);
$template->assign('show_level', $showLevels);
$content = $template->fetch(
$template->get_template('skill/issued.tpl')

@ -274,7 +274,7 @@ foreach ($userSkills as $index => $skillIssue) {
$template = new Template(get_lang('IssuedBadgeInformation'));
$template->assign('user_badges', $allUserBadges);
$template->assign('show_level', api_get_configuration_value('hide_skill_levels') == false;
$content = $template->fetch(
$template->get_template('skill/issued_all.tpl')

@ -689,6 +689,10 @@ $_configuration['gradebook_badge_sidebar'] = [
3 => 'Dimension',
]
];*/
// Hide skill levels options
//$_configuration['hide_skill_levels'] = false;
// Hide the session list in Reporting tool. Useful when a course has too many sessions.
//$_configuration['hide_reporting_session_list'] = false;
@ -701,6 +705,7 @@ $_configuration['gradebook_badge_sidebar'] = [
// Google translate key
//$_configuration['translate_app_google_key'] = '';
// ------ Custom DB changes
// Add user activation by confirmation email
// This option prevents the new user to login in the platform if your account is not confirmed via email

@ -73,24 +73,29 @@
{% endif %}
</li>
</ul>
{% if show_level %}
<h4>{{ 'AcquiredLevel'|get_lang }}</h4>
<ul class="fa-ul">
<li>
<em class="fa-li fa fa-check-circle-o fa-fw"></em> {{ issue_info.acquired_level }}
</li>
</ul>
{% endif %}
{% if allow_comment %}
<hr>
<div class="panel panel-info">
<div class="panel-heading">
<em class="fa fa-check-circle-o fa-fw" aria-hidden="true"></em>
{{ 'ChangeAcquiredLevel'|get_lang }}
</div>
<div class="panel-body">
{{ acquired_level_form }}
{% if show_level %}
<hr>
<div class="panel panel-info">
<div class="panel-heading">
<em class="fa fa-check-circle-o fa-fw" aria-hidden="true"></em>
{{ 'ChangeAcquiredLevel'|get_lang }}
</div>
<div class="panel-body">
{{ acquired_level_form }}
</div>
</div>
</div>
{% endif %}
<hr>
<div class="panel panel-info">
<div class="panel-heading">

@ -68,12 +68,15 @@
{% endif %}
</li>
</ul>
{% if show_level %}
<h4>{{ 'AcquiredLevel'|get_lang }}</h4>
<ul class="fa-ul">
<li>
<em class="fa-li fa fa-check-circle-o fa-fw"></em> {{ badge.issue_info.acquired_level }}
</li>
</ul>
{% endif %}
{% if badge.allow_comment %}
<hr>

Loading…
Cancel
Save