Rename functions using camelCase

- Fix getCurrentScore and userFinishedCourse to use Category instead of
course and session code.
pull/2487/head
jmontoyaa 8 years ago
parent b5569fbb82
commit 45c148be3b
  1. 2
      main/admin/skills_profile.php
  2. 3
      main/badge/assertion.php
  3. 2
      main/gradebook/get_badges.php
  4. 2
      main/gradebook/gradebook.php
  5. 2
      main/gradebook/gradebook_add_link.php
  6. 2
      main/gradebook/gradebook_edit_link.php
  7. 12
      main/gradebook/index.php
  8. 2
      main/gradebook/lib/GradebookUtils.php
  9. 203
      main/gradebook/lib/be/category.class.php
  10. 21
      main/gradebook/lib/be/evaluation.class.php
  11. 2
      main/gradebook/lib/fe/catform.class.php
  12. 2
      main/gradebook/lib/fe/displaygradebook.php
  13. 2
      main/gradebook/lib/fe/gradebooktable.class.php
  14. 2
      main/inc/ajax/model.ajax.php
  15. 8
      main/inc/ajax/skill.ajax.php
  16. 5
      main/inc/lib/SequenceResourceManager.php
  17. 4
      main/inc/lib/gradebook.lib.php
  18. 15
      main/inc/lib/skill.lib.php
  19. 2
      main/inc/lib/social.lib.php
  20. 18
      main/lp/lp_final_item.php
  21. 2
      main/lp/lp_view.php
  22. 2
      main/social/skills_wheel.php
  23. 6
      plugin/grading_electronic/generate.php
  24. 8
      user_portal.php

@ -64,7 +64,7 @@ if (!empty($users)) {
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$user_list[$user['user_id']]['user'] = $user_info;
$my_user_skills = $skill_rel_user->get_user_skills($user['user_id']);
$my_user_skills = $skill_rel_user->getUserSkills($user['user_id']);
$user_skills = array();
$found_counts = 0;
foreach ($my_user_skills as $my_skill) {

@ -20,8 +20,7 @@ if ($userId === 0 || $skillId === 0) {
}
$objSkill = new Skill();
if (!$objSkill->user_has_skill($userId, $skillId, $courseId, $sessionId)) {
if (!$objSkill->userHasSkill($userId, $skillId, $courseId, $sessionId)) {
exit;
}

@ -21,7 +21,7 @@ $courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$objSkillRelUser = new SkillRelUser();
$userSkills = $objSkillRelUser->get_user_skills($userId, $courseId, $sessionId);
$userSkills = $objSkillRelUser->getUserSkills($userId, $courseId, $sessionId);
if (empty($userSkills)) {
api_not_allowed(true);

@ -483,7 +483,7 @@ if (!empty($keyword)) {
$alleval = array();
$alllink = array();
} else {
$alleval = Evaluation::find_evaluations($keyword, $cats[0]->get_id());
$alleval = Evaluation::findEvaluations($keyword, $cats[0]->get_id());
$alllink = LinkFactory::find_links($keyword, $cats[0]->get_id());
}
} elseif (isset($_GET['studentoverview'])) {

@ -33,7 +33,7 @@ if ($session_id == 0) {
$session_id
);
} else {
$all_categories = Category::load_session_categories(null, $session_id);
$all_categories = Category::loadSessionCategories(null, $session_id);
}
$category = Category :: load($selectCat);
$url = api_get_self().'?selectcat='.$selectCat.'&newtypeselected='.$typeSelected.'&course_code='.api_get_course_id().'&'.api_get_cidreq();

@ -39,7 +39,7 @@ if ($session_id == 0) {
false
); //already init
} else {
$cats = Category :: load_session_categories(null, $session_id);
$cats = Category::loadSessionCategories(null, $session_id);
}
$form = new LinkAddEditForm(

@ -413,14 +413,14 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'lock':
$category_to_lock = Category :: load($_GET['category_id']);
$category_to_lock[0]->lock_all_items(1);
$category_to_lock = Category::load($_GET['category_id']);
$category_to_lock[0]->lockAllItems(1);
$confirmation_message = get_lang('GradebookLockedAlert');
break;
case 'unlock':
if (api_is_platform_admin()) {
$category_to_lock = Category :: load($_GET['category_id']);
$category_to_lock[0]->lock_all_items(0);
$category_to_lock = Category::load($_GET['category_id']);
$category_to_lock[0]->lockAllItems(0);
$confirmation_message = get_lang('EvaluationHasBeenUnLocked');
}
break;
@ -770,9 +770,7 @@ if (!empty($selectCat)) {
$currentScore = Category::getCurrentScore(
$stud_id,
$selectCat,
$course_code,
$session_id,
$cats[0],
true
);
Category::registerCurrentScore($currentScore, $stud_id, $selectCat);

@ -1285,7 +1285,7 @@ class GradebookUtils
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$id = intval($id);
$evaluation = new Evaluation();
$evaluation->add_evaluation_log($id);
$evaluation->addEvaluationLog($id);
$sql = 'UPDATE '.$table_evaluation.'
SET weight = '."'".Database::escape_string($weight)."'".'
WHERE id = '.$id;

@ -89,7 +89,7 @@ class Category implements GradebookItem
/**
* @return integer|null
*/
public function get_certificate_min_score()
public function getCertificateMinScore()
{
if (!empty($this->certificate_min_score)) {
return $this->certificate_min_score;
@ -317,9 +317,9 @@ class Category implements GradebookItem
public function get_skills($from_db = true)
{
if ($from_db) {
$cat_id = $this->get_id();
$categoryId = $this->get_id();
$gradebook = new Gradebook();
$skills = $gradebook->get_skills_by_gradebook($cat_id);
$skills = $gradebook->getSkillsByGradebook($categoryId);
} else {
$skills = $this->skills;
}
@ -367,7 +367,7 @@ class Category implements GradebookItem
*
* @return array
*/
public static function load_session_categories(
public static function loadSessionCategories(
$id = null,
$session_id = null
) {
@ -1289,7 +1289,7 @@ class Category implements GradebookItem
// course independent categories
if (empty($course_code)) {
$cats = self::get_independent_categories_with_result_for_student(
$cats = self::getIndependentCategoriesWithStudentResult(
0,
$stud_id,
$cats
@ -1691,12 +1691,14 @@ class Category implements GradebookItem
/**
* Check if a category contains evaluations with a result for a given student
* @param int $studentId
* @return bool
*/
public function has_evaluations_with_results_for_student($stud_id)
public function hasEvaluationsWithStudentResults($studentId)
{
$evals = Evaluation::get_evaluations_with_result_for_student(
$this->id,
$stud_id
$studentId
);
if (count($evals) != 0) {
return true;
@ -1708,8 +1710,9 @@ class Category implements GradebookItem
$this->id,
api_is_allowed_to_edit() ? null : 1
);
/** @var Category $cat */
foreach ($cats as $cat) {
if ($cat->has_evaluations_with_results_for_student($stud_id)) {
if ($cat->hasEvaluationsWithStudentResults($studentId)) {
return true;
}
}
@ -1721,30 +1724,31 @@ class Category implements GradebookItem
/**
* Retrieve all categories inside a course independent category
* that should be visible to a student.
* @param integer $cat_id parent category
* @param $stud_id student id
* @param int $categoryId parent category
* @param int $studentId
* @param array $cats optional: if defined, the categories will be added to this array
* @return array
*/
public function get_independent_categories_with_result_for_student(
$cat_id,
$stud_id,
public function getIndependentCategoriesWithStudentResult(
$categoryId,
$studentId,
$cats = array()
) {
$creator = api_is_allowed_to_edit() && !api_is_platform_admin() ? api_get_user_id() : null;
$crsindcats = self::load(
$categories = self::load(
null,
$creator,
'0',
$cat_id,
$categoryId,
api_is_allowed_to_edit() ? null : 1
);
if (!empty($crsindcats)) {
foreach ($crsindcats as $crsindcat) {
if ($crsindcat->has_evaluations_with_results_for_student($stud_id)) {
$cats[] = $crsindcat;
if (!empty($categories)) {
/** @var Category $category */
foreach ($categories as $category) {
if ($category->hasEvaluationsWithStudentResults($studentId)) {
$cats[] = $category;
}
}
}
@ -1763,7 +1767,7 @@ class Category implements GradebookItem
/**
* Get appropriate subcategories visible for the user (and optionally the course and session)
* @param int $stud_id student id (default: all students)
* @param int $studentId student id (default: all students)
* @param string $course_code Course code (optional)
* @param int $session_id Session ID (optional)
* @param bool $order
@ -1771,7 +1775,7 @@ class Category implements GradebookItem
* @return array Array of subcategories
*/
public function get_subcategories(
$stud_id = null,
$studentId = null,
$course_code = null,
$session_id = null,
$order = null
@ -1788,10 +1792,10 @@ class Category implements GradebookItem
}
// 1 student
if (isset($stud_id)) {
if (isset($studentId)) {
// Special case: this is the root
if ($this->id == 0) {
return self::get_root_categories_for_student($stud_id, $course_code, $session_id);
return self::get_root_categories_for_student($studentId, $course_code, $session_id);
} else {
return self::load(
null,
@ -1859,7 +1863,7 @@ class Category implements GradebookItem
/**
* Get appropriate evaluations visible for the user
* @param int $stud_id student id (default: all students)
* @param int $studentId student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion)
* @param string $course_code
* @param int $sessionId
@ -1867,7 +1871,7 @@ class Category implements GradebookItem
* @return array
*/
public function get_evaluations(
$stud_id = null,
$studentId = null,
$recursive = false,
$course_code = '',
$sessionId = 0
@ -1882,10 +1886,10 @@ class Category implements GradebookItem
}
// 1 student
if (isset($stud_id) && !empty($stud_id)) {
if (isset($studentId) && !empty($studentId)) {
// Special case: this is the root
if ($this->id == 0) {
$evals = Evaluation::get_evaluations_with_result_for_student(0, $stud_id);
$evals = Evaluation::get_evaluations_with_result_for_student(0, $studentId);
} else {
$evals = Evaluation::load(
null,
@ -1903,25 +1907,57 @@ class Category implements GradebookItem
) {
// root
if ($this->id == 0) {
$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
$evals = Evaluation::load(
null,
api_get_user_id(),
null,
$this->id,
null
);
} elseif (isset($this->course_code) && !empty($this->course_code)) {
// inside a course
$evals = Evaluation::load(null, null, $course_code, $this->id, null);
$evals = Evaluation::load(
null,
null,
$course_code,
$this->id,
null
);
} else {
// course independent
$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
$evals = Evaluation::load(
null,
api_get_user_id(),
null,
$this->id,
null
);
}
} else {
$evals = Evaluation::load(null, null, $course_code, $this->id, null);
$evals = Evaluation::load(
null,
null,
$course_code,
$this->id,
null
);
}
}
if ($recursive) {
$subcats = $this->get_subcategories($stud_id, $course_code, $sessionId);
$subcats = $this->get_subcategories(
$studentId,
$course_code,
$sessionId
);
if (!empty($subcats)) {
foreach ($subcats as $subcat) {
$subevals = $subcat->get_evaluations($stud_id, true, $course_code);
$subevals = $subcat->get_evaluations(
$studentId,
true,
$course_code
);
$evals = array_merge($evals, $subevals);
}
}
@ -1932,7 +1968,7 @@ class Category implements GradebookItem
/**
* Get appropriate links visible for the user
* @param int $stud_id student id (default: all students)
* @param int $studentId student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion)
* @param string $course_code
* @param int $sessionId
@ -1940,7 +1976,7 @@ class Category implements GradebookItem
* @return array
*/
public function get_links(
$stud_id = null,
$studentId = null,
$recursive = false,
$course_code = '',
$sessionId = 0
@ -1957,8 +1993,8 @@ class Category implements GradebookItem
// no links in root or course independent categories
if ($this->id == 0) {
} elseif (isset($stud_id)) {
// 1 student $stud_id
} elseif (isset($studentId)) {
// 1 student $studentId
$links = LinkFactory::load(
null,
null,
@ -1983,7 +2019,7 @@ class Category implements GradebookItem
if ($recursive) {
$subcats = $this->get_subcategories(
$stud_id,
$studentId,
$course_code,
$sessionId
);
@ -1991,7 +2027,7 @@ class Category implements GradebookItem
/** @var Category $subcat */
foreach ($subcats as $subcat) {
$sublinks = $subcat->get_links(
$stud_id,
$studentId,
false,
$course_code,
$sessionId
@ -2089,7 +2125,7 @@ class Category implements GradebookItem
/**
* @param $locked
*/
public function lock_all_items($locked)
public function lockAllItems($locked)
{
if (api_get_setting('gradebook_locking_enabled') == 'true') {
$this->lock($locked);
@ -2177,9 +2213,6 @@ class Category implements GradebookItem
$userFinishedCourse = self::userFinishedCourse(
$user_id,
$cats_course[0],
0,
$courseCode,
$sessionId,
true
);
@ -2203,7 +2236,7 @@ class Category implements GradebookItem
);
$objSkillRelUser = new SkillRelUser();
$userSkills = $objSkillRelUser->get_user_skills(
$userSkills = $objSkillRelUser->getUserSkills(
$user_id,
$courseId,
$sessionId
@ -2385,82 +2418,51 @@ class Category implements GradebookItem
* @param int $userId The user ID
* @param \Category $category Optional. The gradebook category.
* To check by the gradebook category
* @param int $categoryId Optional. The gradebook category ID.
* To check by the category ID
* @param string $courseCode Optional. The course code
* @param int $sessionId Optional. The session ID
* @param boolean $recalculateScore Whether recalculate the score
* @return boolean
*/
public static function userFinishedCourse(
$userId,
\Category $category = null,
$categoryId = 0,
$courseCode = null,
$sessionId = 0,
\Category $category,
$recalculateScore = false
) {
if (is_null($category) && empty($categoryId)) {
if (empty($category)) {
return false;
}
$courseCode = empty($courseCode) ? api_get_course_id() : $courseCode;
$sessionId = empty($sessionId) ? api_get_session_id() : $sessionId;
if (is_null($category) && !empty($categoryId)) {
$cats_course = self::load(
$categoryId,
null,
$courseCode,
null,
null,
$sessionId,
false
);
if (empty($cats_course)) {
return false;
}
$category = $cats_course[0];
}
$currentScore = self::getCurrentScore(
$userId,
$category->get_id(),
$courseCode,
$sessionId,
$category,
$recalculateScore
);
$minCertificateScore = $category->get_certificate_min_score();
$minCertificateScore = $category->getCertificateMinScore();
$passedCourse = $currentScore >= $minCertificateScore;
return !empty($minCertificateScore) && $currentScore >= $minCertificateScore;
return $passedCourse;
}
/**
* Get the current score (as percentage) on a gradebook category for a user
* @param int $userId The user id
* @param int $categoryId The gradebook category
* @param int $courseCode The course code
* @param int $sessionId Optional. The session id
* @param Category $category The gradebook category
* @param bool $recalculate
*
* @return float The score
*/
public static function getCurrentScore(
$userId,
$categoryId,
$courseCode,
$sessionId = 0,
$category,
$recalculate = false
) {
if (empty($category)) {
return 0;
}
if ($recalculate) {
return self::calculateCurrentScore(
$userId,
$categoryId,
$courseCode,
$sessionId
$category
);
}
@ -2469,7 +2471,7 @@ class Category implements GradebookItem
Database::get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_LOG),
[
'where' => [
'category_id = ? AND user_id = ?' => [$categoryId, $userId],
'category_id = ? AND user_id = ?' => [$category->get_id(), $userId],
],
'order' => 'registered_at DESC',
'limit' => '1',
@ -2487,32 +2489,16 @@ class Category implements GradebookItem
/**
* Calculate the current score on a gradebook category for a user
* @param int $userId The user id
* @param int $categoryId The gradebook category
* @param int $courseCode The course code
* @param int $sessionId Optional. The session id
* @param Category $category The gradebook category
* @return float The score
*/
private static function calculateCurrentScore(
$userId,
$categoryId,
$courseCode,
$sessionId
$category
) {
$cats_course = self::load(
$categoryId,
null,
$courseCode,
null,
null,
$sessionId,
false
);
if (empty($cats_course)) {
if (empty($category)) {
return 0;
}
$category = $cats_course[0];
$courseEvaluations = $category->get_evaluations($userId, true);
$courseLinks = $category->get_links($userId, true);
$evaluationsAndLinks = array_merge($courseEvaluations, $courseLinks);
@ -2521,7 +2507,6 @@ class Category implements GradebookItem
$item = $evaluationsAndLinks[$i];
$score = $item->calc_score($userId);
$itemValue = 0;
if (!empty($score)) {
$divider = $score[1] == 0 ? 1 : $score[1];
$itemValue = $score[0] / $divider * $item->get_weight();

@ -372,15 +372,15 @@ class Evaluation implements GradebookItem
}
/**
* @param int $idevaluation
* @param int $id
*/
public function add_evaluation_log($idevaluation)
public function addEvaluationLog($id)
{
if (!empty($idevaluation)) {
if (!empty($id)) {
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$tbl_grade_linkeval_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
$eval = new Evaluation();
$dateobject = $eval->load($idevaluation, null, null, null, null);
$dateobject = $eval->load($id, null, null, null, null);
$arreval = get_object_vars($dateobject[0]);
if (!empty($arreval['id'])) {
$sql = 'SELECT weight from '.$tbl_grade_evaluations.'
@ -437,7 +437,7 @@ class Evaluation implements GradebookItem
//recorded history
$eval_log = new Evaluation();
$eval_log->add_evaluation_log($this->id);
$eval_log->addEvaluationLog($this->id);
Database::query($sql);
}
@ -447,7 +447,8 @@ class Evaluation implements GradebookItem
public function delete()
{
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'DELETE FROM '.$tbl_grade_evaluations.' WHERE id = '.intval($this->id);
$sql = 'DELETE FROM '.$tbl_grade_evaluations.'
WHERE id = '.intval($this->id);
Database::query($sql);
}
@ -464,9 +465,9 @@ class Evaluation implements GradebookItem
$parent = $this->category;
}
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'SELECT count(id) AS number'
.' FROM '.$tbl_grade_evaluations
." WHERE name = '".Database::escape_string($name)."'";
$sql = "SELECT count(id) AS number
FROM $tbl_grade_evaluations
WHERE name = '".Database::escape_string($name)."'";
if (api_is_allowed_to_edit()) {
$parent = Category::load($parent);
@ -779,7 +780,7 @@ class Evaluation implements GradebookItem
* @return array evaluation objects matching the search criterium
* @todo can be written more efficiently using a new (but very complex) sql query
*/
public function find_evaluations($name_mask, $selectcat)
public function findEvaluations($name_mask, $selectcat)
{
$rootcat = Category::load($selectcat);
$evals = $rootcat[0]->get_evaluations(

@ -177,7 +177,7 @@ class CatForm extends FormValidator
'skills' => $skills,
'weight' => $this->category_object->get_weight(),
'visible' => $this->category_object->is_visible(),
'certif_min_score' => $this->category_object->get_certificate_min_score(),
'certif_min_score' => $this->category_object->getCertificateMinScore(),
'generate_certificates' => $this->category_object->getGenerateCertificates(),
'is_requirement' => $this->category_object->getIsRequirement(),
)

@ -449,7 +449,7 @@ class DisplayGradebook
$weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
$weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight;
$min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0);
$min_certification = (intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0);
$min_certification = get_lang('CertificateMinScore').' : '.$min_certification;
$edit_icon = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';

@ -904,7 +904,7 @@ class GradebookTable extends SortableTable
*/
private function build_certificate_min_score($item)
{
return $item->get_certificate_min_score();
return $item->getCertificateMinScore();
}
/**

@ -1525,7 +1525,7 @@ switch ($action) {
if ($item['parent_id'] != 0) {
continue;
}
$skills = $obj->get_skills_by_gradebook($item['id']);
$skills = $obj->getSkillsByGradebook($item['id']);
//Fixes bug when gradebook doesn't have names
if (empty($item['name'])) {

@ -146,7 +146,7 @@ switch ($action) {
break;
case 'get_user_skill':
$skillId = isset($_REQUEST['profile_id']) ? intval($_REQUEST['profile_id']) : 0;
$skill = $skill->user_has_skill($userId, $skillId);
$skill = $skill->userHasSkill($userId, $skillId);
if ($skill) {
echo 1;
} else {
@ -154,11 +154,11 @@ switch ($action) {
}
break;
case 'get_all_user_skills':
$skills = $skill->get_user_skills($userId, true);
$skills = $skill->getUserSkills($userId, true);
echo json_encode($skills);
break;
case 'get_user_skills':
$skills = $skill->get_user_skills($userId, true);
$skills = $skill->getUserSkills($userId, true);
Display::display_no_header();
Display::$global_template->assign('skills', $skills);
$template = Display::$global_template->get_template('skill/user_skills.tpl');
@ -222,7 +222,7 @@ switch ($action) {
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$user_list[$user['user_id']]['user'] = $user_info;
$my_user_skills = $skill_rel_user->get_user_skills($user['user_id']);
$my_user_skills = $skill_rel_user->getUserSkills($user['user_id']);
$user_skill_list = array();
foreach ($my_user_skills as $skill_item) {

@ -78,10 +78,7 @@ class SequenceResourceManager
if (!empty($userId)) {
$itemSession['status'] = $itemSession['status'] && Category::userFinishedCourse(
$userId,
$category,
null,
$course->getCode(),
$sessionRequired->getId()
$category
);
}
}

@ -191,7 +191,7 @@ class Gradebook extends Model
)
);
$selected_skills = self::get_skills_by_gradebook($gradebook_id);
$selected_skills = self::getSkillsByGradebook($gradebook_id);
$clean_selected_skills = array();
if (!empty($selected_skills)) {
foreach ($selected_skills as $skill) {
@ -209,7 +209,7 @@ class Gradebook extends Model
* @param int $gradebook_id
* @return array|resource
*/
public function get_skills_by_gradebook($gradebook_id)
public function getSkillsByGradebook($gradebook_id)
{
$gradebook_id = intval($gradebook_id);
$sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill

@ -254,7 +254,7 @@ class SkillRelSkill extends Model
$skill_rel_user = new SkillRelUser();
if ($load_user_data) {
$passed_skills = $skill_rel_user->get_user_skills($user_id);
$passed_skills = $skill_rel_user->getUserSkills($user_id);
$done_skills = array();
foreach ($passed_skills as $done_skill) {
$done_skills[] = $done_skill['skill_id'];
@ -510,7 +510,7 @@ class SkillRelUser extends Model
* @param int $sessionId Optional. The session id
* @return array The skill list. Otherwise return false
*/
public function get_user_skills($userId, $courseId = 0, $sessionId = 0)
public function getUserSkills($userId, $courseId = 0, $sessionId = 0)
{
if (empty($userId)) {
return array();
@ -886,7 +886,7 @@ class Skill extends Model
);
if (!empty($skill_gradebooks)) {
foreach ($skill_gradebooks as $skill_gradebook) {
$user_has_skill = $this->user_has_skill(
$user_has_skill = $this->userHasSkill(
$user_id,
$skill_gradebook['skill_id'],
$courseId,
@ -978,7 +978,7 @@ class Skill extends Model
*
* @return array
*/
public function get_user_skills($userId, $get_skill_data = false)
public function getUserSkills($userId, $get_skill_data = false)
{
$userId = intval($userId);
$sql = 'SELECT DISTINCT s.id, s.name, s.icon, u.id as issue
@ -1117,7 +1117,10 @@ class Skill extends Model
// User achieved the skill (depends in the gradebook with certification)
$skill['data']['achieved'] = false;
if ($user_id) {
$skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']);
$skill['data']['achieved'] = $this->userHasSkill(
$user_id,
$skill['id']
);
}
// Check if the skill has related gradebooks
@ -1387,7 +1390,7 @@ class Skill extends Model
* @param int $sessionId Optional. The session id
* @return boolean Whether the user has the skill return true. Otherwise return false
*/
public function user_has_skill($userId, $skillId, $courseId = 0, $sessionId = 0)
public function userHasSkill($userId, $skillId, $courseId = 0, $sessionId = 0)
{
$courseId = intval($courseId);
$sessionId = intval($sessionId);

@ -2070,7 +2070,7 @@ class SocialManager extends UserManager
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true);
$skills = $skill->getUserSkills($userId, true);
$template = new Template(null, false, false, false, false, false);
$template->assign('ranking', $ranking);

@ -115,7 +115,9 @@ if ($accessGranted == false) {
// TODO: Missing validation of learning path completion
} else {
// A gradebook was found, proceed...
$categoryId = $catLoad[0]->get_id();
/** @var Category $category */
$category = $catLoad[0];
$categoryId = $category->get_id();
$link = LinkFactory::load(
null,
null,
@ -137,8 +139,12 @@ if ($accessGranted == false) {
$userId
);
if (!empty($certificate['pdf_url']) || !empty($certificate['badge_link'])) {
if (is_array($certificate) && isset($certificate['pdf_url'])) {
if (!empty($certificate['pdf_url']) ||
!empty($certificate['badge_link'])
) {
if (is_array($certificate) &&
isset($certificate['pdf_url'])
) {
$downloadCertificateLink = generateLPFinalItemTemplateCertificateLinks(
$certificate
);
@ -158,9 +164,7 @@ if ($accessGranted == false) {
$currentScore = Category::getCurrentScore(
$userId,
$categoryId,
$courseCode,
$sessionId,
$category,
true
);
Category::registerCurrentScore(
@ -235,7 +239,7 @@ function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId =
{
$em = Database::getManager();
$skillRelUser = new SkillRelUser();
$userSkills = $skillRelUser->get_user_skills($userId, $courseId, $sessionId);
$userSkills = $skillRelUser->getUserSkills($userId, $courseId, $sessionId);
$skillList = '';
$badgeLink = '';

@ -465,7 +465,7 @@ if ($_SESSION['oLP']->current == $_SESSION['oLP']->get_last()) {
$gradebookLinks[0]->get_type() == LINK_LEARNPATH &&
$gradebookLinks[0]->get_ref_id() == $_SESSION['oLP']->lp_id
) {
$gradebookMinScore = $categories[0]->get_certificate_min_score();
$gradebookMinScore = $categories[0]->getCertificateMinScore();
$userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
if ($userScore[0] >= $gradebookMinScore) {

@ -27,7 +27,7 @@ $userInfo = api_get_user_info();
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$skills = $skill->get_user_skills($userId, true);
$skills = $skill->getUserSkills($userId, true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addLabel(

@ -116,9 +116,6 @@ try {
$userFinishedCourse = Category::userFinishedCourse(
$student->getId(),
$gradebook,
0,
$course->getCode(),
$session ? $session->getId() : 0,
true
);
@ -133,8 +130,7 @@ try {
$score = Category::getCurrentScore(
$student->getId(),
$gradebook->get_id(),
$course->getCode(),
$gradebook,
$session ? $session->getId() : 0
);

@ -313,9 +313,7 @@ if (!empty($courseAndSessions['courses']) && $allow) {
foreach ($mainCategoryList as $category) {
$parentScore = Category::getCurrentScore(
$userId,
$category->get_id(),
$category->get_course_code(),
0,
$category,
true
);
@ -332,9 +330,7 @@ if (!empty($courseAndSessions['courses']) && $allow) {
if (!empty($subCategory)) {
$score = Category::getCurrentScore(
$userId,
$subCategory->get_id(),
$subCategory->get_course_code(),
0,
$subCategory,
true
);
$totalScoreWithChildren += $score;

Loading…
Cancel
Save