Skip to content

Commit 3e82381

Browse files
authored
Merge pull request #6616 from christianbeeznest/ofaj-22850
Certificate: fix skills/badges rendering via AssetRepository
2 parents 3d7b417 + 03a6703 commit 3e82381

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

assets/vue/components/social/UserProfileCard.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
{{ user.fullName }}
1414
</div>
1515

16-
<div v-if="visibility.language && languageInfo">
17-
<template v-if="flagIconExists(languageInfo.code)">
18-
<i :class="`mdi mdi-flag-${languageInfo.code.toLowerCase()}`"></i>
19-
</template>
20-
<template v-else>
21-
{{ t(languageInfo.code) }}
22-
</template>
16+
<div v-if="visibility.language && languageInfo" class="flex items-center gap-2">
17+
<i v-if="countryFlag" :class="`flag-icon flag-icon-${countryFlag}`"></i>
18+
<span>{{ languageDisplay }}</span>
2319
</div>
2420

2521
<div class="mt-4">
@@ -273,4 +269,17 @@ async function handleUnsubscribe() {
273269
console.error("[Push] No user id for unsubscription.")
274270
}
275271
}
272+
273+
const languageDisplay = computed(() => {
274+
return languageInfo.value?.label
275+
?? languageInfo.value?.value
276+
?? languageInfo.value?.code?.toUpperCase()
277+
?? ''
278+
})
279+
280+
const countryFlag = computed(() => {
281+
const code = languageInfo.value?.code || ''
282+
const m = code.match(/[-_](?<region>[A-Za-z]{2})$/)
283+
return m?.groups?.region?.toLowerCase() || null
284+
})
276285
</script>

public/main/inc/lib/certificate.lib.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,17 @@ public function generateCustomCertificate(string $fileName = ''): string
660660
}
661661

662662
$skill = new SkillModel();
663-
// Ofaj
664663
$skills = $skill->getStudentSkills($this->user_id, 2);
664+
$allowAll = ('true' === api_get_setting('skill.allow_teacher_access_student_skills'));
665+
$courseIdForSkills = $allowAll ? 0 : 0;
666+
$sessionIdForSkills = $allowAll ? 0 : 0;
667+
$skillsTable = $skill->getUserSkillsTable(
668+
$this->user_id,
669+
$courseIdForSkills,
670+
$sessionIdForSkills,
671+
false
672+
);
673+
665674
$timeInSeconds = Tracking::get_time_spent_on_the_platform(
666675
$this->user_id,
667676
'ever'
@@ -710,6 +719,8 @@ public function generateCustomCertificate(string $fileName = ''): string
710719
)
711720
);
712721
$tplContent->assign('skills', $skills);
722+
$tplContent->assign('skills_table_html', $skillsTable['table']);
723+
$tplContent->assign('skills_rows', $skillsTable['skills']);
713724
$tplContent->assign('sessions', $sessionsApproved);
714725
$tplContent->assign('courses', $coursesApproved);
715726
$tplContent->assign('time_spent_in_lps', api_time_to_hms($totalTimeInLearningPaths));

public/main/template/default/gradebook/custom_certificate.html.twig

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<td style="border-collapse: collapse; padding: 0;">
2727
<table border="0" cellspacing="0" cellpadding="0" width="100%">
2828
<tr>
29-
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647" width=58 height="91">
29+
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647" width="58" height="91">
3030
<img src="{{ theme_asset_base64('images/lado-b.png') }}" style="display:block;">
3131
</td>
3232
<td bgcolor="#92c647" width="700" height="91"
@@ -59,25 +59,55 @@
5959
<br />
6060
<p style="font-size: 16px;">{{ 'This preparation corresponds to a volume of approximately %s training hours.'|trans|format(time_spent_in_lps_in_hours)|raw }}</p>
6161
<br />
62-
<p style="font-size: 16px;">{{ 'The following contents have been validated'|trans|raw }}
63-
:</p>
62+
<p style="font-size: 16px;">{{ 'The following contents have been validated'|trans|raw }} :</p>
63+
6464
{% if sessions %}
65-
<ul style="color: #672290; font-size: 16px;">
66-
{% for session in sessions %}
67-
<li> {{ session.session_name }}</li>
68-
{% endfor %}
69-
</ul>
70-
{% endif %}<br />
65+
<ul style="color: #672290; font-size: 16px;">
66+
{% for session in sessions %}
67+
<li>{{ session.session_name }}</li>
68+
{% endfor %}
69+
</ul>
70+
{% endif %}
71+
72+
<br />
7173
<h4 style="color: #672290; font-size: 16px;">{{ complete_name }}</h4>
72-
<p style="color:#40ad49; font-size: 16px;">{{ 'Obtained the following skills'|trans|raw }}
73-
:</p>
74+
<p style="color:#40ad49; font-size: 16px;">{{ 'Obtained the following skills'|trans|raw }} :</p>
75+
76+
{# Lista simple de nombres de skills (si la quieres mantener) #}
7477
{% if skills %}
7578
<ul style="color: #672290; font-size: 16px;">
7679
{% for skill in skills %}
7780
<li>{{ skill.title }}</li>
7881
{% endfor %}
7982
</ul>
8083
{% endif %}
84+
85+
{% if skills_table_html is defined and skills_table_html %}
86+
<br />
87+
<p style="color:#40ad49; font-size:16px;">{{ 'Badges obtained'|trans|raw }} :</p>
88+
<div>
89+
{{ skills_table_html|raw }}
90+
</div>
91+
{% endif %}
92+
93+
{% if (skills_table_html is not defined or not skills_table_html) and skills_rows is defined and skills_rows|length %}
94+
<br />
95+
<p style="color:#40ad49; font-size:16px;">{{ 'Badges obtained'|trans|raw }} :</p>
96+
<table border="0" cellspacing="6" cellpadding="0">
97+
<tr>
98+
{% for r in skills_rows %}
99+
<td align="center" valign="top" style="text-align:center;">
100+
{{ r.skill_badge|raw }}
101+
<div style="font-size:10px; line-height:1.2; color:#672290; max-width:90px;">
102+
{{ r.skill_title }}
103+
</div>
104+
</td>
105+
{% if loop.index % 6 == 0 %}</tr><tr>{% endif %}
106+
{% endfor %}
107+
</tr>
108+
</table>
109+
{% endif %}
110+
81111
<br />
82112
<p style="color:#40ad49; font-size: 16px;">
83113
{{ 'The'|trans }}
@@ -87,7 +117,7 @@
87117
</p>
88118
<br />
89119
</td>
90-
<td height=755 bgcolor="#92c647" style="border-collapse: collapse; padding: 0;">
120+
<td height="755" bgcolor="#92c647" style="border-collapse: collapse; padding: 0;">
91121
<img src="{{ theme_asset_base64('images/lado-b.png') }}" style="display:block;">
92122
</td>
93123
</tr>
@@ -98,16 +128,14 @@
98128
<td style="border-collapse: collapse; padding: 0;">
99129
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="91">
100130
<tr>
101-
<td bgcolor="#92c647" width="58" height="91"
102-
style="border-collapse: collapse; padding: 0;">
131+
<td bgcolor="#92c647" width="58" height="91" style="border-collapse: collapse; padding: 0;">
103132
<img src="{{ theme_asset_base64('images/lado-b.png') }}" style="display:block;">
104133
</td>
105-
<td bgcolor="#92c647" width=500 height=91
134+
<td bgcolor="#92c647" width="500" height="91"
106135
style="border-collapse: collapse; padding: 0; font-family:CourierSans-Light; line-height: 18px; color:#FFF;">
107136
{{ 'Chamilo LMS'|trans|raw }}
108137
</td>
109-
<td bgcolor="#92c647" width="245" height="91"
110-
style="border-collapse: collapse; padding: 0;">
138+
<td bgcolor="#92c647" width="245" height="91" style="border-collapse: collapse; padding: 0;">
111139
</td>
112140
</tr>
113141
</table>

0 commit comments

Comments
 (0)