Internal: Migration: Fix name->title conversion for tracking page myStudent - refs #3581 #4706 BT#21007

pull/5107/head
NicoDucou 2 years ago
parent aca559233e
commit 2684e23137
  1. 56
      public/main/inc/lib/SkillModel.php
  2. 2
      public/main/inc/lib/api.lib.php
  3. 52
      public/main/inc/lib/tracking.lib.php

@ -107,10 +107,10 @@ class SkillModel extends Model
$result['icon_small'] = $iconSmall; $result['icon_small'] = $iconSmall;
$result['icon_big'] = $iconBig; $result['icon_big'] = $iconBig;
$result['img_mini'] = Display::img($iconBig, $result['name'], ['width' => ICON_SIZE_MEDIUM]); $result['img_mini'] = Display::img($iconBig, $result['title'], ['width' => ICON_SIZE_MEDIUM]);
$result['img_big'] = Display::img($iconBig, $result['name']); $result['img_big'] = Display::img($iconBig, $result['name']);
$result['img_small'] = Display::img($iconSmall, $result['name']);*/ $result['img_small'] = Display::img($iconSmall, $result['name']);*/
$result['name'] = self::translateName($result['name']); $result['title'] = self::translateName($result['title']);
$result['short_code'] = self::translateCode($result['short_code']); $result['short_code'] = self::translateCode($result['short_code']);
return $result; return $result;
@ -147,7 +147,7 @@ class SkillModel extends Model
$html .= '<li class="thumbnail">'; $html .= '<li class="thumbnail">';
$item = $skill[$imageSize]; $item = $skill[$imageSize];
$item .= '<div class="caption"> $item .= '<div class="caption">
<p class="text-center">'.$skill['name'].'</p> <p class="text-center">'.$skill['title'].'</p>
</div>'; </div>';
if (isset($skill['url'])) { if (isset($skill['url'])) {
$html .= Display::url($item, $skill['url'], ['target' => '_blank']); $html .= Display::url($item, $skill['url'], ['target' => '_blank']);
@ -209,9 +209,9 @@ class SkillModel extends Model
$item = '<div class="item"><img src="'.$url.$imageParams.'" /></div>'; $item = '<div class="item"><img src="'.$url.$imageParams.'" /></div>';
} }
$name = '<div class="caption">'.$skill['name'].'</div>'; $title = '<div class="caption">'.$skill['title'].'</div>';
if (!empty($skill['short_code'])) { if (!empty($skill['short_code'])) {
$name = $skill['short_code']; $title = $skill['short_code'];
} }
if (!$isHierarchicalTable) { if (!$isHierarchicalTable) {
@ -219,7 +219,7 @@ class SkillModel extends Model
} }
if ($showTitle) { if ($showTitle) {
$item .= $name; $item .= $title;
} }
if (isset($skill['url'])) { if (isset($skill['url'])) {
@ -272,9 +272,9 @@ class SkillModel extends Model
$skill['icon_small'] = sprintf( $skill['icon_small'] = sprintf(
'badges/%s-small.png', 'badges/%s-small.png',
sha1($skill['name']) sha1($skill['title'])
); );
$skill['name'] = self::translateName($skill['name']); $skill['title'] = self::translateName($skill['title']);
$skill['short_code'] = self::translateCode($skill['short_code']); $skill['short_code'] = self::translateCode($skill['short_code']);
} }
@ -315,7 +315,7 @@ class SkillModel extends Model
$sql = "SELECT $sql = "SELECT
s.id, s.id,
s.name, s.title,
s.description, s.description,
ss.parent_id, ss.parent_id,
ss.relation_type, ss.relation_type,
@ -339,7 +339,7 @@ class SkillModel extends Model
$row['asset'] = $assetRepo->getAssetUrl($skill->getAsset()); $row['asset'] = $assetRepo->getAssetUrl($skill->getAsset());
} }
$row['name'] = self::translateName($skill->getTitle()); $row['title'] = self::translateName($skill->getTitle());
$row['short_code'] = self::translateCode($skill->getShortCode()); $row['short_code'] = self::translateCode($skill->getShortCode());
$skillRelSkill = new SkillRelSkillModel(); $skillRelSkill = new SkillRelSkillModel();
$parents = $skillRelSkill->getSkillParents($skillId); $parents = $skillRelSkill->getSkillParents($skillId);
@ -674,7 +674,7 @@ class SkillModel extends Model
$sql = 'SELECT DISTINCT $sql = 'SELECT DISTINCT
s.id, s.id,
s.name, s.title,
s.icon, s.icon,
s.asset_id, s.asset_id,
u.id as issue, u.id as issue,
@ -814,7 +814,7 @@ class SkillModel extends Model
'skill_id' => $resultData['id'], 'skill_id' => $resultData['id'],
'asset_id' => $resultData['asset_id'], 'asset_id' => $resultData['asset_id'],
'skill_badge' => $badgeImage, 'skill_badge' => $badgeImage,
'skill_name' => self::translateName($resultData['name']), 'skill_title' => self::translateName($resultData['title']),
'short_code' => $resultData['short_code'], 'short_code' => $resultData['short_code'],
'skill_url' => $resultData['url'], 'skill_url' => $resultData['url'],
'achieved_at' => api_get_local_time($resultData['acquired_skill_at']), 'achieved_at' => api_get_local_time($resultData['acquired_skill_at']),
@ -981,7 +981,7 @@ class SkillModel extends Model
// Default root node // Default root node
$skills[1] = [ $skills[1] = [
'id' => '1', 'id' => '1',
'name' => get_lang('Root'), 'title' => get_lang('Root'),
'parent_id' => 0, 'parent_id' => 0,
'status' => 1, 'status' => 1,
]; ];
@ -1008,19 +1008,19 @@ class SkillModel extends Model
$skill['parent_id'] = 1; $skill['parent_id'] = 1;
} }
// because except main keys (id, name, children) others keys // because except main keys (id, title, children) others keys
// are not saved while in the space tree // are not saved while in the space tree
$skill['data'] = ['parent_id' => $skill['parent_id']]; $skill['data'] = ['parent_id' => $skill['parent_id']];
// If a short code was defined, send the short code to replace // If a short code was defined, send the short code to replace
// skill name (to shorten the text in the wheel) // skill title (to shorten the text in the wheel)
if (!empty($skill['short_code']) && if (!empty($skill['short_code']) &&
'false' === api_get_setting('show_full_skill_name_on_skill_wheel') 'false' === api_get_setting('show_full_skill_name_on_skill_wheel')
) { ) {
$skill['data']['short_code'] = $skill['short_code']; $skill['data']['short_code'] = $skill['short_code'];
} }
$skill['data']['name'] = $skill['name']; $skill['data']['title'] = $skill['title'];
$skill['data']['status'] = $skill['status']; $skill['data']['status'] = $skill['status'];
// In order to paint all members of a family with the same color // In order to paint all members of a family with the same color
@ -1090,7 +1090,7 @@ class SkillModel extends Model
} }
$skills_tree = [ $skills_tree = [
'name' => get_lang('Absolute skill'), 'title' => get_lang('Absolute skill'),
'id' => 1, 'id' => 1,
'children' => $refs[1]['children'], 'children' => $refs[1]['children'],
'data' => [], 'data' => [],
@ -1135,7 +1135,7 @@ class SkillModel extends Model
$children = $this->getSkillToJson($element['children'], 1, $main_depth); $children = $this->getSkillToJson($element['children'], 1, $main_depth);
} }
$simple_tree[] = [ $simple_tree[] = [
'name' => $element['name'], 'title' => $element['title'],
'children' => $children, 'children' => $children,
]; ];
} }
@ -1160,7 +1160,7 @@ class SkillModel extends Model
$counter = 1; $counter = 1;
foreach ($subtree as $elem) { foreach ($subtree as $elem) {
$tmp = []; $tmp = [];
$tmp['name'] = $elem['name']; $tmp['title'] = $elem['title'];
$tmp['id'] = $elem['id']; $tmp['id'] = $elem['id'];
$tmp['isSearched'] = self::isSearched($elem['id']); $tmp['isSearched'] = self::isSearched($elem['id']);
@ -1432,7 +1432,7 @@ class SkillModel extends Model
user.firstname, user.firstname,
user.username, user.username,
skill.id skill_id, skill.id skill_id,
skill.name skill_name, skill.title skill_title,
sru.acquired_skill_at sru.acquired_skill_at
FROM {$this->table_skill_rel_user} AS sru FROM {$this->table_skill_rel_user} AS sru
INNER JOIN {$this->table_course} INNER JOIN {$this->table_course}
@ -1446,7 +1446,7 @@ class SkillModel extends Model
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) { while ($row = Database::fetch_assoc($result)) {
$row['skill_name'] = self::translateName($row['skill_name']); $row['skill_title'] = self::translateName($row['skill_title']);
$list[] = $row; $list[] = $row;
} }
@ -1478,7 +1478,7 @@ class SkillModel extends Model
user.firstname, user.firstname,
user.username, user.username,
skill.id skill_id, skill.id skill_id,
skill.name skill_name, skill.title skill_title,
sru.acquired_skill_at sru.acquired_skill_at
FROM {$this->table_skill_rel_user} AS sru FROM {$this->table_skill_rel_user} AS sru
INNER JOIN {$this->table_course} INNER JOIN {$this->table_course}
@ -1491,7 +1491,7 @@ class SkillModel extends Model
$result = Database::query($sql); $result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) { while ($row = Database::fetch_assoc($result)) {
$row['skill_name'] = self::translateName($row['skill_name']); $row['skill_title'] = self::translateName($row['skill_title']);
$list[] = $row; $list[] = $row;
} }
@ -1509,7 +1509,7 @@ class SkillModel extends Model
{ {
$skillId = (int) $skillId; $skillId = (int) $skillId;
$sql = "SELECT s.id, s.name $sql = "SELECT s.id, s.title
FROM {$this->table_gradebook} g FROM {$this->table_gradebook} g
INNER JOIN {$this->table_skill_rel_gradebook} sg INNER JOIN {$this->table_skill_rel_gradebook} sg
ON g.id = sg.gradebook_id ON g.id = sg.gradebook_id
@ -1695,7 +1695,7 @@ class SkillModel extends Model
{ {
$userId = (int) $userId; $userId = (int) $userId;
$sql = "SELECT s.id, s.name, sru.acquired_skill_at $sql = "SELECT s.id, s.title, sru.acquired_skill_at
FROM {$this->table} s FROM {$this->table} s
INNER JOIN {$this->table_skill_rel_user} sru INNER JOIN {$this->table_skill_rel_user} sru
ON s.id = sru.skill_id ON s.id = sru.skill_id
@ -1707,7 +1707,7 @@ class SkillModel extends Model
foreach ($result as $item) { foreach ($result as $item) {
if (empty($level)) { if (empty($level)) {
$skills[] = [ $skills[] = [
'name' => self::translateName($item['name']), 'title' => self::translateName($item['title']),
'acquired_skill_at' => $item['acquired_skill_at'], 'acquired_skill_at' => $item['acquired_skill_at'],
]; ];
} else { } else {
@ -1715,7 +1715,7 @@ class SkillModel extends Model
// +2 because it takes into account the root // +2 because it takes into account the root
if (count($parents) == $level + 1) { if (count($parents) == $level + 1) {
$skills[] = [ $skills[] = [
'name' => self::translateName($item['name']), 'title' => self::translateName($item['title']),
'acquired_skill_at' => $item['acquired_skill_at'], 'acquired_skill_at' => $item['acquired_skill_at'],
]; ];
} }
@ -1770,7 +1770,7 @@ class SkillModel extends Model
continue; continue;
} }
$skillList[$skill['id']] = $skill['name']; $skillList[$skill['id']] = $skill['title'];
} }
$allGradeBooks = $objGradebook->find('all'); $allGradeBooks = $objGradebook->find('all');

@ -2384,7 +2384,7 @@ function api_get_session_name($session_id = 0)
//technically, there can be only one, but anyway we take the first //technically, there can be only one, but anyway we take the first
$rec = Database::fetch_array($r); $rec = Database::fetch_array($r);
return $rec['name']; return $rec['title'];
} }
return null; return null;

@ -112,7 +112,7 @@ class Tracking
$groupItem = [ $groupItem = [
'id' => $group->getIid(), 'id' => $group->getIid(),
'name' => $group->getTitle(), 'title' => $group->getTitle(),
'time' => api_time_to_hms($time), 'time' => api_time_to_hms($time),
'progress' => $averageProgress, 'progress' => $averageProgress,
'score' => $averageScore, 'score' => $averageScore,
@ -3900,11 +3900,11 @@ class Tracking
$keywordCondition = null; $keywordCondition = null;
if (!empty($keyword)) { if (!empty($keyword)) {
$keyword = Database::escape_string($keyword); $keyword = Database::escape_string($keyword);
$keywordCondition = " AND (name LIKE '%$keyword%' ) "; $keywordCondition = " AND (title LIKE '%$keyword%' ) ";
if (!empty($description)) { if (!empty($description)) {
$description = Database::escape_string($description); $description = Database::escape_string($description);
$keywordCondition = " AND (name LIKE '%$keyword%' OR description LIKE '%$description%' ) "; $keywordCondition = " AND (title LIKE '%$keyword%' OR description LIKE '%$description%' ) ";
} }
} }
@ -3919,7 +3919,7 @@ class Tracking
$orderBy = ''; $orderBy = '';
if (!empty($orderByName)) { if (!empty($orderByName)) {
if (in_array($orderByName, ['name', 'access_start_date'])) { if (in_array($orderByName, ['title', 'access_start_date'])) {
$orderByDirection = in_array(strtolower($orderByDirection), ['asc', 'desc']) ? $orderByDirection : 'asc'; $orderByDirection = in_array(strtolower($orderByDirection), ['asc', 'desc']) ? $orderByDirection : 'asc';
$orderByName = Database::escape_string($orderByName); $orderByName = Database::escape_string($orderByName);
$orderBy .= " ORDER BY `$orderByName` $orderByDirection"; $orderBy .= " ORDER BY `$orderByName` $orderByDirection";
@ -3931,7 +3931,7 @@ class Tracking
( (
SELECT DISTINCT SELECT DISTINCT
s.id, s.id,
name, title,
$injectExtraFields $injectExtraFields
access_start_date, access_start_date,
access_end_date access_end_date
@ -3949,7 +3949,7 @@ class Tracking
UNION UNION
SELECT DISTINCT SELECT DISTINCT
s.id, s.id,
s.name, s.title,
$injectExtraFields $injectExtraFields
s.access_start_date, s.access_start_date,
s.access_end_date s.access_end_date
@ -4653,7 +4653,7 @@ class Tracking
$courseIdList[] = $row['id']; $courseIdList[] = $row['id'];
} }
$orderBy = ' ORDER BY name '; $orderBy = ' ORDER BY title ';
$extraInnerJoin = null; $extraInnerJoin = null;
if (SessionManager::orderCourseIsEnabled() && !empty($session_id)) { if (SessionManager::orderCourseIsEnabled() && !empty($session_id)) {
@ -4670,7 +4670,7 @@ class Tracking
// Get the list of sessions where the user is subscribed as student // Get the list of sessions where the user is subscribed as student
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$sql = "SELECT DISTINCT c.code, s.id as session_id, name $sql = "SELECT DISTINCT c.code, s.id as session_id, s.title
FROM $tbl_session_course_user cu FROM $tbl_session_course_user cu
INNER JOIN $tbl_access_rel_session a INNER JOIN $tbl_access_rel_session a
ON (a.session_id = cu.session_id) ON (a.session_id = cu.session_id)
@ -4685,7 +4685,7 @@ class Tracking
$sessionCondition $sessionCondition
$orderBy "; $orderBy ";
} else { } else {
$sql = "SELECT DISTINCT c.code, s.id as session_id, name $sql = "SELECT DISTINCT c.code, s.id as session_id, s.title
FROM $tbl_session_course_user cu FROM $tbl_session_course_user cu
INNER JOIN $tbl_session s INNER JOIN $tbl_session s
ON (s.id = cu.session_id) ON (s.id = cu.session_id)
@ -4703,11 +4703,11 @@ class Tracking
while ($row = Database::fetch_array($rs, 'ASSOC')) { while ($row = Database::fetch_array($rs, 'ASSOC')) {
$course_info = api_get_course_info($row['code']); $course_info = api_get_course_info($row['code']);
$temp_course_in_session[$row['session_id']]['course_list'][$course_info['real_id']] = $course_info; $temp_course_in_session[$row['session_id']]['course_list'][$course_info['real_id']] = $course_info;
$temp_course_in_session[$row['session_id']]['name'] = $row['name']; $temp_course_in_session[$row['session_id']]['title'] = $row['title'];
$simple_session_array[$row['session_id']] = $row['name']; $simple_session_array[$row['session_id']] = $row['title'];
} }
foreach ($simple_session_array as $my_session_id => $session_name) { foreach ($simple_session_array as $my_session_id => $session_title) {
$course_list = $temp_course_in_session[$my_session_id]['course_list']; $course_list = $temp_course_in_session[$my_session_id]['course_list'];
$my_course_data = []; $my_course_data = [];
foreach ($course_list as $courseId => $course_data) { foreach ($course_list as $courseId => $course_data) {
@ -4725,7 +4725,7 @@ class Tracking
} }
} }
$course_in_session[$my_session_id]['course_list'] = $final_course_data; $course_in_session[$my_session_id]['course_list'] = $final_course_data;
$course_in_session[$my_session_id]['name'] = $session_name; $course_in_session[$my_session_id]['title'] = $session_title;
} }
if ($returnArray) { if ($returnArray) {
@ -5056,7 +5056,7 @@ class Tracking
foreach ($course_in_session as $my_session_id => $session_data) { foreach ($course_in_session as $my_session_id => $session_data) {
$course_list = $session_data['course_list']; $course_list = $session_data['course_list'];
$session_name = $session_data['name']; $session_name = $session_data['title'];
if (false == $showAllSessions) { if (false == $showAllSessions) {
if (isset($session_id) && !empty($session_id)) { if (isset($session_id) && !empty($session_id)) {
if ($session_id != $my_session_id) { if ($session_id != $my_session_id) {
@ -5121,7 +5121,7 @@ class Tracking
} }
$url = api_get_path(WEB_CODE_PATH)."session/index.php?session_id={$my_session_id}"; $url = api_get_path(WEB_CODE_PATH)."session/index.php?session_id={$my_session_id}";
$html .= Display::tag('td', Display::url($session_name, $url, ['target' => SESSION_LINK_TARGET])); $html .= Display::tag('td', Display::url($session_title, $url, ['target' => SESSION_LINK_TARGET]));
$html .= Display::tag('td', $all_exercises); $html .= Display::tag('td', $all_exercises);
$html .= Display::tag('td', $all_unanswered_exercises_by_user); $html .= Display::tag('td', $all_unanswered_exercises_by_user);
$html .= Display::tag('td', ExerciseLib::convert_to_percentage($all_average)); $html .= Display::tag('td', ExerciseLib::convert_to_percentage($all_average));
@ -5170,7 +5170,7 @@ class Tracking
$course_list = $session_data['course_list']; $course_list = $session_data['course_list'];
$html .= '<a name= "course_session_list"></a>'; $html .= '<a name= "course_session_list"></a>';
$html .= Display::tag('h3', $session_data['name'].' - '.get_lang('Course list')); $html .= Display::tag('h3', $session_data['title'].' - '.get_lang('Course list'));
$html .= '<div class="table-responsive">'; $html .= '<div class="table-responsive">';
$html .= '<table class="table table-hover table-striped">'; $html .= '<table class="table table-hover table-striped">';
@ -6351,7 +6351,7 @@ class Tracking
$sessions[$sessionId] = api_get_session_info($sessionId); $sessions[$sessionId] = api_get_session_info($sessionId);
} elseif (empty($sessionId) && !empty($courseId)) { } elseif (empty($sessionId) && !empty($courseId)) {
// if, to the contrary, course is defined but not sessions, get the sessions that include this course // if, to the contrary, course is defined but not sessions, get the sessions that include this course
// $sessions is an array like: [0] => ('id' => 3, 'name' => 'Session 35'), [1] => () etc; // $sessions is an array like: [0] => ('id' => 3, 'title' => 'Session 35'), [1] => () etc;
$course = api_get_course_info_by_id($courseId); $course = api_get_course_info_by_id($courseId);
$sessionsTemp = SessionManager::get_session_by_course($courseId); $sessionsTemp = SessionManager::get_session_by_course($courseId);
$courses[$courseId] = $course; $courses[$courseId] = $course;
@ -6511,7 +6511,7 @@ class Tracking
foreach ($data as $id => $row) { foreach ($data as $id => $row) {
$rowQuestId = $row['question_id']; $rowQuestId = $row['question_id'];
$rowAnsId = $row['answer_id']; $rowAnsId = $row['answer_id'];
$data[$id]['session'] = $sessions[$row['session_id']]['name']; $data[$id]['session'] = $sessions[$row['session_id']]['title'];
$data[$id]['firstname'] = $users[$row['user_id']]['firstname']; $data[$id]['firstname'] = $users[$row['user_id']]['firstname'];
$data[$id]['lastname'] = $users[$row['user_id']]['lastname']; $data[$id]['lastname'] = $users[$row['user_id']]['lastname'];
$data[$id]['username'] = $users[$row['user_id']]['username']; $data[$id]['username'] = $users[$row['user_id']]['username'];
@ -6525,7 +6525,7 @@ class Tracking
/* /*
The minimum expected array structure at the end is: The minimum expected array structure at the end is:
attempt_id, attempt_id,
session name, session title,
exercise_id, exercise_id,
quiz_title, quiz_title,
username, username,
@ -8178,7 +8178,7 @@ class TrackingCourseLog
$row_thematic = Database::fetch_array($rs_thematic); $row_thematic = Database::fetch_array($rs_thematic);
$thematic_id = $row_thematic['thematic_id']; $thematic_id = $row_thematic['thematic_id'];
$sql = "SELECT s.id, s.name, u.name $sql = "SELECT s.id, s.title, u.username
FROM $tbl_thematic t FROM $tbl_thematic t
INNER JOIN $tblSessionRelUser sru INNER JOIN $tblSessionRelUser sru
ON t.session_id = sru.session_id ON t.session_id = sru.session_id
@ -8193,7 +8193,7 @@ class TrackingCourseLog
$recorset = Database::query($sql); $recorset = Database::query($sql);
} }
} else { } else {
$sql = "SELECT session.id s.id, s.name u.username $sql = "SELECT s.id, s.title u.username
FROM c_tool t, session s, user u, $tblSessionRelUser sru FROM c_tool t, session s, user u, $tblSessionRelUser sru
WHERE WHERE
t.c_id = $course_id AND t.c_id = $course_id AND
@ -8210,7 +8210,7 @@ class TrackingCourseLog
$name_session = ''; $name_session = '';
$coach_name = ''; $coach_name = '';
if (!empty($obj)) { if (!empty($obj)) {
$name_session = $obj->name; $name_session = $obj->title;
$coach_name = $obj->username; $coach_name = $obj->username;
} }
@ -8259,20 +8259,20 @@ class TrackingCourseLog
} }
break; break;
case 'glossary': case 'glossary':
$sql = "SELECT name FROM $table_tool $sql = "SELECT title FROM $table_tool
WHERE c_id = $course_id AND glossary_id = $ref"; WHERE c_id = $course_id AND glossary_id = $ref";
$rs_document = Database::query($sql); $rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document); $obj_document = Database::fetch_object($rs_document);
if ($obj_document) { if ($obj_document) {
$row[5] = $obj_document->name; $row[5] = $obj_document->title;
} }
break; break;
case 'lp': case 'lp':
$sql = "SELECT name $sql = "SELECT title
FROM $table_tool WHERE c_id = $course_id AND id = $ref"; FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql); $rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document); $obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->name; $row[5] = $obj_document->title;
break; break;
case 'quiz': case 'quiz':
$sql = "SELECT title FROM $table_tool $sql = "SELECT title FROM $table_tool

Loading…
Cancel
Save