Minor - format code, add int casting

pull/2487/head
Julio 7 years ago
parent 9d5ae95d7a
commit 136623afb5
  1. 7
      main/exercise/TestCategory.php
  2. 22
      main/inc/lib/skill.lib.php

@ -67,7 +67,7 @@ class TestCategory
// check if name already exists
$sql = "SELECT count(*) AS nb FROM $table
WHERE title = '".$this->name."' AND c_id=$courseId";
WHERE title = '".$this->name."' AND c_id = $courseId";
$result = Database::query($sql);
$row = Database::fetch_array($result);
// lets add in BDD if not the same name
@ -242,6 +242,8 @@ class TestCategory
public static function getCategoryForQuestion($questionId, $courseId = 0)
{
$courseId = (int) $courseId;
$questionId = (int) $questionId;
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
@ -251,7 +253,6 @@ class TestCategory
}
$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$questionId = intval($questionId);
$sql = "SELECT category_id
FROM $table
WHERE question_id = $questionId AND c_id = $courseId";
@ -630,7 +631,6 @@ class TestCategory
public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
{
$is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
// @todo fix $_SESSION['objExercise']
$objExercise = Session::read('objExercise');
if (!empty($objExercise)) {
$in_display_category_name = $objExercise->display_category_name;
@ -733,7 +733,6 @@ class TestCategory
$res_num_max = 0;
// foreach question
$categories = self::getListOfCategoriesIDForTest($exerciseId);
foreach ($categories as $category) {
if (empty($category['id'])) {
continue;

@ -254,6 +254,7 @@ class SkillRelSkill extends Model
$user_id = false,
$order = ''
) {
$skill_id = (int) $skill_id;
$sql = 'SELECT parent.* FROM '.$this->tableSkill.' skill
INNER JOIN '.$this->table.' parent
ON parent.id = skill.id
@ -352,19 +353,19 @@ class SkillRelGradebook extends Model
}
/**
* @param int $gradebook_id
* @param int $skill_id
* @param int $gradebookId
* @param int $skillId
* @return bool
*/
public function existsGradeBookSkill($gradebook_id, $skill_id)
public function existsGradeBookSkill($gradebookId, $skillId)
{
$result = $this->find(
'all',
array(
'where' => array(
'gradebook_id = ? AND skill_id = ?' => array(
$gradebook_id,
$skill_id
$gradebookId,
$skillId
)
)
)
@ -378,7 +379,7 @@ class SkillRelGradebook extends Model
/**
* Gets an element
*/
public function getSkillInfo($skill_id, $gradebook_id)
public function getSkillInfo($skill_id, $gradebookId)
{
if (empty($skill_id)) {
return array();
@ -390,7 +391,7 @@ class SkillRelGradebook extends Model
'where' => array(
'skill_id = ? AND gradebook_id = ? ' => array(
$skill_id,
$gradebook_id
$gradebookId
)
)
),
@ -530,7 +531,6 @@ class SkillRelUser extends Model
$courseId = intval($courseId);
$sessionId = $sessionId ? intval($sessionId) : null;
$whereConditions = array(
'user_id = ? ' => intval($userId)
);
@ -882,13 +882,13 @@ class Skill extends Model
/**
* @param int $user_id
* @param int $gradebook_id
* @param int $gradebookId
* @param int $courseId
* @param int $sessionId
*/
public function addSkillToUser(
$user_id,
$gradebook_id,
$gradebookId,
$courseId = 0,
$sessionId = 0
) {
@ -896,7 +896,7 @@ class Skill extends Model
$skill_rel_user = new SkillRelUser();
$skill_gradebooks = $skill_gradebook->get_all(
array('where' => array('gradebook_id = ?' => $gradebook_id))
array('where' => array('gradebook_id = ?' => $gradebookId))
);
if (!empty($skill_gradebooks)) {
foreach ($skill_gradebooks as $skill_gradebook) {

Loading…
Cancel
Save