fixed - courses from session in gradebook tool - partial CT#462

skala
Cristian Fasanando 15 years ago
parent 0b2965a1c3
commit d04841fc57
  1. 3
      main/gradebook/index.php
  2. 10
      main/gradebook/lib/be/exerciselink.class.php
  3. 16
      main/gradebook/lib/be/forumthreadlink.class.php
  4. 12
      main/gradebook/lib/be/learnpathlink.class.php
  5. 18
      main/gradebook/lib/be/studentpublicationlink.class.php
  6. 19
      main/gradebook/lib/gradebook_functions_users.inc.php

@ -70,6 +70,7 @@ $status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_cour
$filter_confirm_msg = true;
$filter_warning_msg = true;
$session_id = api_get_session_id();
///direct access to one evaluation
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
if (empty($cats))
@ -839,7 +840,7 @@ if (api_is_platform_admin() || api_is_allowed_to_create_course() || $status==1)
}
}
}
if($first_time==1 && api_is_allowed_to_edit())
if($first_time==1 && api_is_allowed_to_edit(null,true))
{
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?cidReq='.$course_code.'" />';
}

@ -58,11 +58,11 @@ class ExerciseLink extends AbstractLink
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id,title from '.$this->get_exercise_table()
.' WHERE id NOT IN'
.' exe WHERE id NOT IN'
.' (SELECT ref_id FROM '.$tbl_grade_links
.' WHERE type = '.LINK_EXERCISE
." AND course_code = '".$this->get_course_code()."'"
.')';
.') AND exe.session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$cats=array();
@ -81,7 +81,7 @@ class ExerciseLink extends AbstractLink
}
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK,$course_info['dbName']);
$sql = 'SELECT id,title from '.$this->get_exercise_table().' where active=1';
$sql = 'SELECT id,title from '.$this->get_exercise_table().' WHERE active=1 AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$cats=array();
@ -201,7 +201,7 @@ class ExerciseLink extends AbstractLink
*/
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_exercise_table()
.' WHERE id = '.$this->get_ref_id();
.' WHERE id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$number=Database::fetch_row($result);
return ($number[0] != 0);
@ -255,7 +255,7 @@ class ExerciseLink extends AbstractLink
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * from '.$this->get_exercise_table()
.' WHERE id = '.$this->get_ref_id();
.' WHERE id = '.$this->get_ref_id().' AND session_id ='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$this->exercise_data=Database::fetch_array($result);
}

@ -64,12 +64,12 @@ class ForumThreadLink extends AbstractLink
}
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT thread_id,thread_title,thread_title_qualify from '.$this->get_forum_thread_table()
.' WHERE thread_id NOT IN'
$sql = 'SELECT thread_id,thread_title,thread_title_qualify from '.$this->get_forum_thread_table()
.' forum_thread WHERE thread_id NOT IN'
.' (SELECT ref_id FROM '.$tbl_grade_links
.' WHERE type = '.LINK_FORUM_THREAD
." AND course_code = '".$this->get_course_code()."'"
.')';
.') AND forum_thread.session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
@ -94,7 +94,7 @@ class ForumThreadLink extends AbstractLink
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD,$course_info['dbName']);
$tbl_item_property=Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$sql = 'SELECT tl.thread_id,tl.thread_title,tl.thread_title_qualify FROM '.$tbl_grade_links.' tl ,'.$tbl_item_property.' ip where tl.thread_id=ip.ref and ip.tool="forum_thread" and ip.visibility<>2 group by ip.ref';
$sql = 'SELECT tl.thread_id,tl.thread_title,tl.thread_title_qualify FROM '.$tbl_grade_links.' tl ,'.$tbl_item_property.' ip WHERE tl.thread_id=ip.ref AND ip.tool="forum_thread" AND ip.visibility<>2 AND tl.session_id='.api_get_session_id().' GROUP BY ip.ref ';
$result = Database::query($sql, __FILE__, __LINE__);
while ($data=Database::fetch_array($result)) {
@ -127,7 +127,7 @@ class ForumThreadLink extends AbstractLink
if ($database_name!="") {
$thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY, $database_name);
$sql = 'SELECT thread_qualify_max FROM '.Database :: get_course_table(TABLE_FORUM_THREAD, $database_name)." WHERE thread_id = '".$this->get_ref_id()."'";
$sql = 'SELECT thread_qualify_max FROM '.Database :: get_course_table(TABLE_FORUM_THREAD, $database_name)." WHERE thread_id = '".$this->get_ref_id()."' AND session_id=".api_get_session_id()."";
$query = Database::query($sql,__FILE__,__LINE__);
$assignment = Database::fetch_array($query);
@ -239,7 +239,7 @@ class ForumThreadLink extends AbstractLink
*/
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_forum_thread_table()
.' WHERE thread_id = '.$this->get_ref_id();
.' WHERE thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$number=Database::fetch_row($result);
return ($number[0] != 0);
@ -253,7 +253,7 @@ class ForumThreadLink extends AbstractLink
//it was extracts the forum id
$tbl_name=$this->get_forum_thread_table();
if ($tbl_name!="") {
$sql = 'SELECT * FROM '.$this->get_forum_thread_table()." WHERE thread_id = '".$this->get_ref_id()."'";
$sql = 'SELECT * FROM '.$this->get_forum_thread_table()." WHERE thread_id = '".$this->get_ref_id()."' AND session_id = ".api_get_session_id()."";
$result = Database::query($sql,__FILE__,__LINE__);
$row = Database::fetch_array($result,'ASSOC');
$forum_id=$row['forum_id'];
@ -268,7 +268,7 @@ class ForumThreadLink extends AbstractLink
if ($tbl_name=='') {
return false;
}elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * FROM '.$this->get_forum_thread_table()." WHERE thread_id = '".$this->get_ref_id()."'";
$sql = 'SELECT * FROM '.$this->get_forum_thread_table()." WHERE thread_id = '".$this->get_ref_id()."' AND session_id=".api_get_session_id()."";
$query = Database::query($sql,__FILE__,__LINE__);
$this->exercise_data = Database::fetch_array($query);
}

@ -59,11 +59,11 @@ class LearnpathLink extends AbstractLink
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id,name from '.$this->get_learnpath_table()
.' WHERE id NOT IN'
.' lp WHERE id NOT IN'
.' (SELECT ref_id FROM '.$tbl_grade_links
.' WHERE type = '.LINK_LEARNPATH
." AND course_code = '".$this->get_course_code()."'"
.')';
.') AND lp.session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
@ -86,7 +86,7 @@ class LearnpathLink extends AbstractLink
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK,$course_info['dbName']);
$sql = 'SELECT id,name from '.$this->get_learnpath_table();
$sql = 'SELECT id,name FROM '.$this->get_learnpath_table().' WHERE session_id = '.api_get_session_id().' ';
$result = Database::query($sql, __FILE__, __LINE__);
$cats=array();
@ -213,8 +213,8 @@ class LearnpathLink extends AbstractLink
*/
public function is_valid_link()
{
$sql = 'SELECT count(id) from '.$this->get_learnpath_table()
.' WHERE id = '.$this->get_ref_id();
$sql = 'SELECT count(id) FROM '.$this->get_learnpath_table()
.' WHERE id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$number=Database::fetch_row($result,'NUM');
return ($number[0] != 0);
@ -271,7 +271,7 @@ class LearnpathLink extends AbstractLink
return false;
} elseif (!isset($this->learnpath_data)) {
$sql = 'SELECT * from '.$this->get_learnpath_table()
.' WHERE id = '.$this->get_ref_id();
.' WHERE id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$this->learnpath_data=Database::fetch_array($result);
}

@ -58,7 +58,7 @@ class StudentPublicationLink extends AbstractLink
." WHERE prop.tool = 'work'"
.' AND prop.insert_user_id = '.$stud_id
.' AND prop.ref = pub.id'
." AND pub.title = '".Database::escape_string($eval->get_name())."'";
." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id()."";
$result = Database::query($sql, __FILE__, __LINE__);
if ($fileurl = Database::fetch_row($result)) {
@ -99,11 +99,11 @@ class StudentPublicationLink extends AbstractLink
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id,url from '.$this->get_studpub_table()
.' WHERE has_properties != '."''".' AND id NOT IN'
.' pup WHERE has_properties != '."''".' AND id NOT IN'
.' (SELECT ref_id FROM '.$tbl_grade_links
.' WHERE type = '.LINK_STUDENTPUBLICATION
." AND course_code = '".$this->get_course_code()."'"
.')';
.') AND pub.session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
@ -124,7 +124,7 @@ class StudentPublicationLink extends AbstractLink
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION,$course_info['dbName']);
$sql = 'SELECT id,url FROM '.$tbl_grade_links.' WHERE has_properties != '."'' AND filetype='folder'";
$sql = "SELECT id,url FROM $tbl_grade_links WHERE has_properties != '' AND filetype='folder' AND session_id = ".api_get_session_id()."";
$result = Database::query($sql, __FILE__, __LINE__);
while ($data=Database::fetch_array($result)) {
@ -140,7 +140,7 @@ class StudentPublicationLink extends AbstractLink
public function has_results() {
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION,$course_info['dbName']);
$sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." WHERE parent_id = '".$this->get_ref_id()."'";
$sql = 'SELECT count(*) AS number FROM '.$tbl_grade_links." WHERE parent_id = '".$this->get_ref_id()."' AND session_id=".api_get_session_id()."";
$result = Database::query($sql, __FILE__, __LINE__);
$number=Database::fetch_row($result);
return ($number[0] != 0);
@ -154,7 +154,7 @@ class StudentPublicationLink extends AbstractLink
if (is_null($database_name)===true) {
return false;
}
$sql = 'SELECT * FROM '.$tbl_stats." WHERE id = '".$this->get_ref_id()."'";
$sql = 'SELECT * FROM '.$tbl_stats." WHERE id = '".$this->get_ref_id()."' AND session_id=".api_get_session_id()."";
$query = Database::query($sql,__FILE__,__LINE__);
$assignment = Database::fetch_array($query);
@ -163,7 +163,7 @@ class StudentPublicationLink extends AbstractLink
} else {
$v_assigment_id = $assignment['id'];
}
$sql = 'SELECT * FROM '.$tbl_stats.' WHERE parent_id ="'.$v_assigment_id.'"';
$sql = 'SELECT * FROM '.$tbl_stats.' WHERE parent_id ="'.$v_assigment_id.'" AND session_id='.api_get_session_id().'';
if (isset($stud_id)){
$sql1='SELECT firstname, lastname FROM '.Database::get_main_table(TABLE_MAIN_USER)." WHERE user_id = '".((int)$stud_id)."'";
$query = Database::query($sql1,__FILE__,__LINE__);
@ -269,7 +269,7 @@ class StudentPublicationLink extends AbstractLink
if ($tbl_name=='') {
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE id = '".$this->get_ref_id()."'";
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE id = '".$this->get_ref_id()."' AND session_id=".api_get_session_id()."";
$query = Database::query($sql,__FILE__,__LINE__);
$this->exercise_data = Database::fetch_array($query);
}
@ -286,7 +286,7 @@ class StudentPublicationLink extends AbstractLink
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_studpub_table()
.' WHERE id = '.$this->get_ref_id();
.' WHERE id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$result = Database::query($sql, __FILE__, __LINE__);
$number=Database::fetch_row($result);
return ($number[0] != 0);

@ -32,15 +32,30 @@
*/
function get_users_in_course($course_id) {
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname ASC' : ' ORDER BY lastname, firstname ASC';
$sql = 'SELECT user.user_id,lastname,firstname'
$current_session = api_get_session_id();
if (!empty($current_session)) {
$sql = "SELECT user.user_id,lastname,firstname
FROM $tbl_session_course_user as scru, $tbl_user as user
WHERE scru.id_user=user.user_id
AND scru.status=0
AND scru.course_code='$course_id' AND id_session ='$current_session' $order_clause ";
} else {
$sql = 'SELECT user.user_id,lastname,firstname'
.' FROM '.$tbl_course_user.' as course_rel_user, '.$tbl_user.' as user'
.' WHERE course_rel_user.user_id=user.user_id'
.' AND course_rel_user.status='.STUDENT
." AND course_rel_user.course_code='".$course_id."'"
.$order_clause;
.$order_clause;
}
$result = Database::query($sql, __FILE__, __LINE__);
return get_user_array_from_sql_result($result);
}

Loading…
Cancel
Save