Internal: Remove c_id in queries when not necessary + survey.survey_id -> survey.iid

pull/5002/head
Yannick Warnier 1 year ago
parent 52835e82a0
commit 21fc215026
  1. 2
      public/main/gradebook/index.php
  2. 5
      public/main/gradebook/lib/be/attendancelink.class.php
  3. 25
      public/main/gradebook/lib/be/learnpathlink.class.php
  4. 2
      public/main/survey/survey_question.php

@ -458,7 +458,7 @@ if (isset($_GET['deletelink'])) {
thread_qualify_max = 0,
thread_weight = 0,
thread_title_qualify = ""
WHERE c_id = '.$course_id.' AND iid = (
WHERE iid = (
SELECT ref_id FROM '.$tbl_grade_links.'
WHERE id = '.$get_delete_link.' AND type = '.LINK_FORUM_THREAD.'
)';

@ -85,8 +85,7 @@ class AttendanceLink extends AbstractLink
$sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result."
WHERE
session_id = $sessionId AND
c_id = '.$this->course_id.' AND
attendance_id = '".$this->get_ref_id()."'";
attendance_id = ".$this->get_ref_id();
$result = Database::query($sql);
$number = Database::fetch_row($result);
@ -114,7 +113,7 @@ class AttendanceLink extends AbstractLink
// Get results
$sql = 'SELECT *
FROM '.$tbl_attendance_result.'
WHERE c_id = '.$this->course_id.' AND attendance_id = '.$this->get_ref_id();
WHERE attendance_id = '.$this->get_ref_id();
if (isset($studentId)) {
$sql .= ' AND user_id = '.intval($studentId);
}

@ -50,24 +50,6 @@ class LearnpathLink extends AbstractLink
}
return $list;
/*$session_id = $this->get_session_id();
if (empty($session_id)) {
$session_condition = api_get_session_condition(0, true);
} else {
$session_condition = api_get_session_condition($session_id, true, true);
}
$sql = 'SELECT iid, name FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' '.$session_condition.' ';
$result = Database::query($sql);
$cats = [];
while ($data = Database::fetch_array($result)) {
$cats[] = [$data['iid'], $data['name']];
}
return $cats;*/
}
/**
@ -77,7 +59,7 @@ class LearnpathLink extends AbstractLink
{
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT count(id) AS number FROM $tbl_stats
WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id();
WHERE lp_id = ".$this->get_ref_id();
$result = Database::query($sql);
$number = Database::fetch_array($result, 'NUM');
@ -104,7 +86,6 @@ class LearnpathLink extends AbstractLink
$sql = "SELECT * FROM $tbl_stats
WHERE
c_id = ".$this->course_id." AND
lp_id = ".$this->get_ref_id()." AND
session_id = $session_id ";
@ -211,7 +192,7 @@ class LearnpathLink extends AbstractLink
public function is_valid_link()
{
$sql = 'SELECT count(iid) FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
WHERE iid = '.$this->get_ref_id().' ';
$result = Database::query($sql);
$number = Database::fetch_row($result, 'NUM');
@ -265,7 +246,7 @@ class LearnpathLink extends AbstractLink
{
if (!isset($this->learnpath_data)) {
$sql = 'SELECT * FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' AND iid = '.$this->get_ref_id().' ';
WHERE iid = '.$this->get_ref_id().' ';
$result = Database::query($sql);
$this->learnpath_data = Database::fetch_array($result);
}

@ -19,7 +19,7 @@ class survey_question
*/
public function addParentMenu($formData, FormValidator $form, $surveyData)
{
$surveyId = $surveyData['survey_id'];
$surveyId = $surveyData['iid'];
$questionId = isset($formData['question_id']) ? $formData['question_id'] : 0;
$parentId = isset($formData['parent_id']) ? $formData['parent_id'] : 0;
$optionId = isset($formData['parent_option_id']) ? $formData['parent_option_id'] : 0;

Loading…
Cancel
Save