Now we can add exercises and LPs of the base course in the gradebook inside a session

skala
Julio Montoya 14 years ago
parent 6c1341b4ae
commit 41f0447aa0
  1. 2
      main/exercice/exercice.php
  2. 12
      main/gradebook/exercise_jump.php
  3. 1
      main/gradebook/gradebook_showlog_link.php
  4. 4
      main/gradebook/index.php
  5. 26
      main/gradebook/lib/be/abstractlink.class.php
  6. 52
      main/gradebook/lib/be/attendancelink.class.php
  7. 54
      main/gradebook/lib/be/category.class.php
  8. 8
      main/gradebook/lib/be/evaluation.class.php
  9. 124
      main/gradebook/lib/be/exerciselink.class.php
  10. 2
      main/gradebook/lib/be/gradebookitem.class.php
  11. 66
      main/gradebook/lib/be/learnpathlink.class.php
  12. 1
      main/gradebook/lib/be/linkfactory.class.php
  13. 53
      main/gradebook/lib/be/studentpublicationlink.class.php
  14. 6
      main/gradebook/lib/fe/gradebooktable.class.php
  15. 14
      main/gradebook/lib/fe/linkaddeditform.class.php
  16. 8
      main/gradebook/lib/gradebook_data_generator.class.php
  17. 5
      main/gradebook/user_stats.php
  18. 8
      main/newscorm/lp_impress.php
  19. 3
      main/work/work.lib.php

@ -526,7 +526,7 @@ if (!empty($exercise_list)) {
$lp_blocked = '';
if (!$show_quiz_edition) {
$lp_blocked = Display::label(get_lang('AddedToALP'), 'warning');
$lp_blocked = Display::label(get_lang('AddedToALP'), 'info');
}
//Showing exercise title

@ -1,4 +1,4 @@
<?php //$id $
<?php
/* For licensing terms, see /license.txt */
/**
* Sets needed course variables and then jumps to the exercises result page.
@ -21,20 +21,22 @@ $course_code = api_get_course_id();
$course_info = Database::get_course_info($course_code);
$course_title = $course_info['title'];
$course_code = $return_result['code'];
$gradebook=Security::remove_XSS($_GET['gradebook']);
$gradebook = Security::remove_XSS($_GET['gradebook']);
$dbname = $course_info['db_name'];
$session_id = api_get_session_id();
$cidReq = Security::remove_XSS($_GET['cidReq']);
$_course['name'] = $course_title;
$_course['official_code'] = $course_code;
if (isset($_GET['doexercise'])) {
header('Location: ../exercice/overview.php?cidReq='.$cidReq.'&gradebook='.$gradebook.'&origin=&learnpath_id=&learnpath_item_id=&exerciseId='.intval($_GET['doexercise']));
header('Location: ../exercice/overview.php?session_id='.$session_id.'&cidReq='.$cidReq.'&gradebook='.$gradebook.'&origin=&learnpath_id=&learnpath_item_id=&exerciseId='.intval($_GET['doexercise']));
exit;
} else {
if (isset($_GET['gradebook'])) {
$add_url = '&gradebook=view&exerciseId='.intval($_GET['exerciseId']);
}
header('Location: ../exercice/exercice.php?cidReq='.Security::remove_XSS($cidReq).'&show=result'.$add_url);
header('Location: ../exercice/exercice.php??session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq).'&show=result'.$add_url);
exit;
}

@ -23,7 +23,6 @@ $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_d
$interbreadcrumb[] = array ('url' => 'gradebook_showlog_link.php?visiblelink='.Security::remove_XSS($_GET['visiblelink']).'&amp;selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('GradebookQualifyLog'));
$this_section = SECTION_COURSES;
Display :: display_header('');
echo '<div class="clear"></div>';
echo '<div class="actions">';
api_display_tool_title(get_lang('GradebookQualifyLog'));
echo '</div>';

@ -869,12 +869,12 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (!empty($grading_string)) {
Display::display_normal_message(get_lang('GradeModel').': '.$grading_string);
}
}
}
$gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams);
$gradebooktable->display();
}
}
}
}
//echo '<div id="chart3"></div>';
Display :: display_footer();

@ -47,6 +47,10 @@ abstract class AbstractLink implements GradebookItem {
public function get_ref_id() {
return $this->ref_id;
}
public function get_session_id() {
return $this->session_id;
}
public function get_user_id() {
return $this->user_id;
@ -107,6 +111,10 @@ abstract class AbstractLink implements GradebookItem {
public function set_visible ($visible) {
$this->visible = $visible;
}
public function set_session_id($id) {
$this->session_id = $id;
}
// CRUD FUNCTIONS
@ -115,8 +123,8 @@ abstract class AbstractLink implements GradebookItem {
* To keep consistency, do not call this method but LinkFactory::load instead.
*/
public function load ($id = null, $type = null, $ref_id = null, $user_id = null, $course_code = null, $category_id = null, $visible = null) {
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql='SELECT id, type, ref_id, user_id,course_code,category_id,created_at,weight,visible FROM '.$tbl_grade_links;
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql='SELECT id, type, ref_id, user_id, course_code, category_id, created_at, weight, visible FROM '.$tbl_grade_links;
$paramcount = 0;
if (isset ($id)) {
$sql.= ' WHERE id = '.Database::escape_string($id);
@ -187,16 +195,18 @@ abstract class AbstractLink implements GradebookItem {
$link->set_course_code($data['course_code']);
$link->set_category_id($data['category_id']);
$link->set_date($data['created_at']);
$link->set_weight($data['weight']);
$link->set_weight($data['weight']);
$link->set_visible($data['visible']);
//session id should depend of the category --> $data['category_id']
$session_id = api_get_session_id();
$link->set_session_id($session_id);
$links[]=$link;
}
return $links;
}
public function set_session_id($id) {
$this->session_id = $id;
}
/**
* Insert this link into the database
@ -377,7 +387,9 @@ abstract class AbstractLink implements GradebookItem {
abstract function needs_results();
abstract function is_allowed_to_change_name();
// TRIVIAL FUNCTIONS - to be overwritten by subclass if needed
/* TRIVIAL FUNCTIONS - to be overwritten by subclass if needed */
/* Seems to be not used anywhere */
public function get_not_created_links() {
return null;
}

@ -12,14 +12,11 @@
class AttendanceLink extends AbstractLink
{
// INTERNAL VARIABLES
// INTERNAL VARIABLES
private $attendance_table = null;
private $itemprop_table = null;
// CONSTRUCTORS
// CONSTRUCTORS
function __construct() {
parent::__construct();
$this->set_type(LINK_ATTENDANCE);
@ -29,19 +26,19 @@ class AttendanceLink extends AbstractLink
return get_lang('Attendance');
}
public function is_allowed_to_change_name() {
return false;
}
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
/**
* Generate an array of attendances that a teacher hasn't created a link for.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
* @todo seems to be depracated
*/
public function get_not_created_links() {
return false;
if (empty($this->course_code)) {
die('Error in get_not_created_links() : course code not set');
}
@ -73,11 +70,26 @@ class AttendanceLink extends AbstractLink
die('Error in get_not_created_links() : course code not set');
}
$tbl_attendance = $this->get_attendance_table();
$session_id = api_get_session_id();
$session_id = api_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 att.id, att.name, att.attendance_qualify_title
FROM '.$tbl_attendance.' att
WHERE att.c_id = '.$this->course_id.' AND att.active = 1 '.$session_condition;*/
$sql = 'SELECT att.id, att.name, att.attendance_qualify_title
FROM '.$tbl_attendance.' att
WHERE att.c_id = '.$this->course_id.' AND att.active = 1 AND att.session_id = '.intval($session_id).'';
WHERE att.c_id = '.$this->course_id.' AND att.active = 1 AND att.session_id = '.$session_id;
$result = Database::query($sql);
while ($data=Database::fetch_array($result)) {
if (isset($data['attendance_qualify_title']) && $data['attendance_qualify_title'] != ''){
$cats[] = array ($data['id'], $data['attendance_qualify_title']);
@ -95,8 +107,9 @@ class AttendanceLink extends AbstractLink
*/
public function has_results() {
$tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT);
$session_id = api_get_session_id();
$sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result."
WHERE c_id = '.$this->course_id.' AND attendance_id = '".intval($this->get_ref_id())."'";
WHERE session_id = $session_id AND c_id = '.$this->course_id.' AND attendance_id = '".intval($this->get_ref_id())."'";
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);
@ -198,7 +211,7 @@ class AttendanceLink extends AbstractLink
public function is_valid_link() {
$session_id = api_get_session_id();
$sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' ';
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);
@ -209,18 +222,15 @@ class AttendanceLink extends AbstractLink
}
public function get_link() {
//it was extracts the attendance id
$tbl_name = $this->get_attendance_table();
$session_id = api_get_session_id();
if ($tbl_name != '') {
//it was extracts the attendance id
$session_id = api_get_session_id();
$sql = 'SELECT * FROM '.$this->get_attendance_table().' att
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id = '.intval($session_id).' ';
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' ';
$result = Database::query($sql);
$row = Database::fetch_array($result,'ASSOC');
$attendance_id = $row['id'];
$url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&cidReq='.$this->get_course_code();
return $url;
}
$url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&session_id='.$session_id.'&cidReq='.$this->get_course_code();
return $url;
}
private function get_attendance_data() {
@ -230,7 +240,7 @@ class AttendanceLink extends AbstractLink
return false;
} elseif (!isset($this->attendance_data)) {
$sql = 'SELECT * FROM '.$this->get_attendance_table().' att
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' ';
$query = Database::query($sql);
$this->attendance_data = Database::fetch_array($query);
}

@ -16,7 +16,6 @@ class Category implements GradebookItem
{
// PROPERTIES
private $id;
private $name;
private $description;
@ -155,7 +154,7 @@ class Category implements GradebookItem
* @param int session id (in case we are in a session)
* @param bool Whether to show all "session" categories (true) or hide them (false) in case there is no session id
*/
public function load ($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session_id = null, $show_session_categories = true) {
public function load ($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session_id = null) {
//if the category given is explicitly 0 (not null), then create
// a root category object (in memory)
if ( isset($id) && (int)$id === 0 ) {
@ -181,23 +180,34 @@ class Category implements GradebookItem
$sql .= ' user_id = '.intval($user_id);
$paramcount ++;
}
if (isset($course_code)) {
$course_code = Database::escape_string($course_code);
if ($paramcount != 0) { $sql .= ' AND'; }
else { $sql .= ' WHERE'; }
if ($course_code == '0') { $sql .= ' course_code is null '; }
else { $sql .= " course_code = '".Database::escape_string($course_code)."'"; }
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
if (!empty($session_id)) {
$sql .= ' AND session_id = '.(int) $session_id.' ';
} else {
// a query on the course should show all
if ($course_code == '0') {
$sql .= ' course_code is null ';
} else {
$sql .= " course_code = '".Database::escape_string($course_code)."'";
}
/*if ($show_session_categories !== true) {
// a query on the course should show all
// the categories inside sessions for this course
// otherwise a special parameter is given to ask explicitely
if ($show_session_categories !== true) {
$sql .= " AND (session_id IS NULL OR session_id = 0) ";
$sql .= " AND (session_id IS NULL OR session_id = 0) ";
} else {*/
if (empty($session_id)) {
$sql .= ' AND (session_id IS NULL OR session_id = 0) ';
} else {
$sql .= ' AND session_id = '.(int) $session_id.' ';
}
}
//}
$paramcount ++;
}
if (isset($parent_id)) {
@ -219,8 +229,7 @@ class Category implements GradebookItem
}
$sql .= ' visible = '.intval($visible);
$paramcount ++;
}
}
$result = Database::query($sql);
$allcat = array();
if (Database::num_rows($result) > 0) {
@ -1110,19 +1119,18 @@ class Category implements GradebookItem
$course_code = api_get_course_id();
}
// no links in root or course independent categories
// no links in root or course independent categories
if ($this->id == 0) {
}
// 1 student $stud_id
elseif (isset($stud_id)) {
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$course_code,$this->id,
} elseif (isset($stud_id)) {
// 1 student $stud_id
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$course_code, $this->id,
api_is_allowed_to_edit() ? null : 1);
}
// all students -> only for course/platform admin
elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) {
} elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) {
// all students -> only for course/platform admin
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, null);
}
if ($recursive) {
$subcats = $this->get_subcategories($stud_id);

@ -24,12 +24,12 @@ class Evaluation implements GradebookItem
private $eval_max;
private $visible;
// CONSTRUCTORS
// CONSTRUCTORS
function __construct() {
}
// GETTERS AND SETTERS
// GETTERS AND SETTERS
public function get_id() {
return $this->id;
@ -117,8 +117,6 @@ class Evaluation implements GradebookItem
public function set_visible ($visible) {
$this->visible = $visible;
}
public function set_type ($type) {
$this->type = $type;
@ -129,7 +127,7 @@ class Evaluation implements GradebookItem
}
// CRUD FUNCTIONS
// CRUD FUNCTIONS
/**
* Retrieve evaluations and return them as an array of Evaluation objects

@ -11,49 +11,46 @@
*/
class ExerciseLink extends AbstractLink
{
// INTERNAL VARIABLES
// INTERNAL VARIABLES
private $course_info = null;
private $exercise_table = null;
private $exercise_data = null;
// CONSTRUCTORS
// CONSTRUCTORS
function __construct() {
parent::__construct();
$this->set_type(LINK_EXERCISE);
}
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
/**
* Generate an array of exercises that a teacher hasn't created a link for.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_not_created_links() {
return false;
if (empty($this->course_code)) {
die('Error in get_not_created_links() : course code not set');
die('Error in get_not_created_links() : course code not set');
}
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id, title from '.$this->get_exercise_table()
.' 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().' AND exe.c_id = '.$this->course_id.' ';
$sql = 'SELECT id, title from '.$this->get_exercise_table().' 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.c_id = ".$this->course_id;
$result = Database::query($sql);
$cats=array();
$cats = array();
while ($data=Database::fetch_array($result)) {
$cats[] = array ($data['id'], $data['title']);
}
return $cats;
}
/**
* Generate an array of all exercises available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
@ -62,20 +59,22 @@ class ExerciseLink extends AbstractLink
if (empty($this->course_code)) {
die('Error in get_not_created_links() : course code not set');
}
/*$session_id = api_get_session_id();
$session_id = api_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 id,title from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND active=1 '.$session_condition;
*/
$sql = 'SELECT id,title from '.$this->get_exercise_table().'
/* $sql = 'SELECT id,title from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND active=1 AND session_id='.api_get_session_id().'';
*/
$result = Database::query($sql);
$cats=array();
$cats = array();
while ($data=Database::fetch_array($result)) {
$cats[] = array ($data['id'], $data['title']);
}
@ -87,9 +86,11 @@ class ExerciseLink extends AbstractLink
*/
public function has_results() {
$tbl_stats = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = 'SELECT count(exe_id) AS number FROM '.$tbl_stats
." WHERE exe_cours_id = '".$this->get_course_code()."'"
.' AND exe_exo_id = '.(int)$this->get_ref_id();
$session_id = api_get_session_id();
$sql = 'SELECT count(exe_id) AS number FROM '.$tbl_stats."
WHERE session_id = $session_id AND
exe_cours_id = '".$this->get_course_code()."'".' AND
exe_exo_id = '.(int)$this->get_ref_id();
$result = Database::query($sql);
$number=Database::fetch_row($result);
return ($number[0] != 0);
@ -104,46 +105,55 @@ class ExerciseLink extends AbstractLink
*/
public function calc_score($stud_id = null) {
$tbl_stats = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_e_attempt_recording = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
//$tbl_stats_e_attempt_recording = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
//the following query should be similar (in conditions) to the one used in exercice/exercice.php, look for note-query-exe-results marker
$sql = 'SELECT * FROM '.$tbl_stats.' WHERE exe_exo_id = '.(int)$this->get_ref_id().' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND status <>\'incomplete\'';
$session_id = api_get_session_id();
$sql = "SELECT * FROM $tbl_stats
WHERE exe_exo_id = ".intval($this->get_ref_id())." AND
orig_lp_id = 0 AND
orig_lp_item_id = 0 AND
status <> 'incomplete' AND
session_id = $session_id
";
if (isset($stud_id)) {
$course_code_exe = $this->get_course_code();
$sql .= ' AND exe_cours_id="'.$course_code_exe.'" AND exe_user_id = '."'".$stud_id."'";
$sql .= " AND exe_cours_id = '$course_code_exe' AND
exe_user_id = '$stud_id' ";
}
$sql .= ' ORDER BY exe_id DESC';
$scores = Database::query($sql);
if (isset($stud_id)) {
// for 1 student
if ($data=Database::fetch_array($scores)) {
if ($data = Database::fetch_array($scores)) {
return array ($data['exe_result'], $data['exe_weighting']);
} else {
return null;
}
} else {// all students -> get average
} else {
/// all students -> get average
// normal way of getting the info
$students=array(); // user list, needed to make sure we only
$students = array(); // user list, needed to make sure we only
// take first attempts into account
$rescount = 0;
$student_count = 0;
$sum = 0;
while ($data=Database::fetch_array($scores)) {
if (!(array_key_exists($data['exe_user_id'],$students))) {
while ($data = Database::fetch_array($scores, 'ASSOC')) {
if (!in_array($data['exe_user_id'], $students)) {
if ($data['exe_weighting'] != 0) {
$students[$data['exe_user_id']] = $data['exe_result'];
$rescount++;
$sum += ($data['exe_result'] / $data['exe_weighting']);
$students[] = $data['exe_user_id'];
$student_count++;
$sum += $data['exe_result'] / $data['exe_weighting'];
}
}
}
}
if ($rescount == 0) {
if ($student_count == 0) {
return null;
} else {
return array ($sum , $rescount);
return array ($sum , $student_count);
}
}
}
@ -154,10 +164,11 @@ class ExerciseLink extends AbstractLink
*/
public function get_link() {
//status student
$user_id=api_get_user_id();
$course_code=$this->get_course_code();
$status_user=api_get_status_of_user_in_course ($user_id,$course_code);
$url = api_get_path(WEB_PATH).'main/gradebook/exercise_jump.php?cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id();
$user_id = api_get_user_id();
$course_code = $this->get_course_code();
$status_user=api_get_status_of_user_in_course ($user_id, $course_code);
$session_id =api_get_session_id();
$url = api_get_path(WEB_PATH).'main/gradebook/exercise_jump.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id();
if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) {
$url .= '&amp;doexercise='.$this->get_ref_id();
}
@ -168,7 +179,7 @@ class ExerciseLink extends AbstractLink
* Get name to display: same as exercise title
*/
public function get_name() {
$data = $this->get_exercise_data();
$data = $this->get_exercise_data();
return $data['title'];
}
@ -184,15 +195,15 @@ class ExerciseLink extends AbstractLink
* Check if this still links to an exercise
*/
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id='.api_get_session_id().'';
//$sql = 'SELECT count(id) from '.$this->get_exercise_table().' WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$sql = 'SELECT count(id) from '.$this->get_exercise_table().' WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
$result = Database::query($sql);
$number=Database::fetch_row($result);
return ($number[0] != 0);
}
public function get_type_name() {
return get_lang('Exercises');
return get_lang('Quiz');
}
public function needs_name_and_description() {
@ -212,7 +223,7 @@ class ExerciseLink extends AbstractLink
}
// INTERNAL FUNCTIONS
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the exercise
@ -225,13 +236,13 @@ class ExerciseLink extends AbstractLink
/**
* Lazy load function to get the database contents of this exercise
*/
private function get_exercise_data () {
$tbl_exercise=$this->get_exercise_table();
private function get_exercise_data() {
$tbl_exercise = $this->get_exercise_table();
if ($tbl_exercise=='') {
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id ='.api_get_session_id().'';
$sql = 'SELECT * FROM '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
$result = Database::query($sql);
$this->exercise_data=Database::fetch_array($result);
@ -242,5 +253,4 @@ class ExerciseLink extends AbstractLink
public function get_icon_name() {
return 'exercise';
}
}
}

@ -19,6 +19,6 @@ interface GradebookItem
public function get_weight();
public function get_date();
public function is_visible();
public function get_icon_name();
public function get_icon_name();
public function calc_score($stud_id = null);
}

@ -12,29 +12,25 @@
*/
class LearnpathLink extends AbstractLink
{
// INTERNAL VARIABLES
// INTERNAL VARIABLES
private $course_info = null;
private $learnpath_table = null;
private $learnpath_data = null;
// CONSTRUCTORS
// CONSTRUCTORS
function __construct() {
parent::__construct();
$this->set_type(LINK_LEARNPATH);
}
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
// FUNCTIONS IMPLEMENTING ABSTRACTLINK
/**
* Generate an array of learnpaths that a teacher hasn't created a link for.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_not_created_links()
{
public function get_not_created_links() {
return false;
if (empty($this->course_code))
die('Error in get_not_created_links() : course code not set');
@ -62,8 +58,16 @@ class LearnpathLink extends AbstractLink
public function get_all_links() {
if (empty($this->course_code))
die('Error in get_not_created_links() : course code not set');
$sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' WHERE c_id = '.$this->course_id.' AND session_id = '.api_get_session_id().' ';
$session_id = api_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 id, name FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' '.$session_condition.' ';
$result = Database::query($sql);
$cats = array();
@ -95,7 +99,12 @@ class LearnpathLink extends AbstractLink
*/
public function calc_score($stud_id = null) {
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT * FROM $tbl_stats WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id();
$session_id = api_get_session_id();
$sql = "SELECT * FROM $tbl_stats
WHERE c_id = ".$this->course_id." AND
lp_id = ".$this->get_ref_id()." AND
session_id = $session_id ";
if (isset($stud_id))
$sql .= ' AND user_id = '.intval($stud_id);
@ -105,7 +114,7 @@ class LearnpathLink extends AbstractLink
$scores = Database::query($sql);
// for 1 student
if (isset($stud_id)) {
if ($data=Database::fetch_array($scores)) {
if ($data = Database::fetch_array($scores)) {
return array ($data['progress'], 100);
} else
return null;
@ -135,18 +144,13 @@ class LearnpathLink extends AbstractLink
/**
* Get URL where to go to if the user clicks on the link.
*/
public function get_link()
{
$url = api_get_path(WEB_PATH)
.'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view';
if (!api_is_allowed_to_edit()
|| $this->calc_score(api_get_user_id()) == null)
{
$url .= '&action=view&lp_id='.$this->get_ref_id();
}
else
{
$url .= '&action=build&lp_id='.$this->get_ref_id();
public function get_link() {
$url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view';
$session_id = api_get_session_id();
if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) {
$url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
} else {
$url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
}
return $url;
}
@ -173,8 +177,8 @@ class LearnpathLink extends AbstractLink
* Check if this still links to a learnpath
*/
public function is_valid_link() {
$sql = 'SELECT count(id) FROM '.$this->get_learnpath_table()
.' WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
$result = Database::query($sql);
$number = Database::fetch_row($result,'NUM');
return ($number[0] != 0);
@ -200,7 +204,7 @@ class LearnpathLink extends AbstractLink
return false;
}
// INTERNAL FUNCTIONS
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the learnpath
@ -215,8 +219,8 @@ class LearnpathLink extends AbstractLink
*/
private function get_learnpath_data() {
if (!isset($this->learnpath_data)) {
$sql = 'SELECT * from '.$this->get_learnpath_table()
.' WHERE id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$sql = 'SELECT * FROM '.$this->get_learnpath_table().'
WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
$result = Database::query($sql);
$this->learnpath_data=Database::fetch_array($result);
}

@ -54,7 +54,6 @@ class LinkFactory
return AbstractLink::load($id, $type, $ref_id, $user_id, $course_code, $category_id, $visible);
}
/**
* Get the link object referring to an evaluation
*/

@ -12,20 +12,16 @@
class StudentPublicationLink extends AbstractLink
{
// INTERNAL VARIABLES
// INTERNAL VARIABLES
private $studpub_table = null;
private $itemprop_table = null;
// CONSTRUCTORS
// CONSTRUCTORS
public function __construct() {
parent::__construct();
$this->set_type(LINK_STUDENTPUBLICATION);
}
/**
*
* Returns the URL of a document
@ -60,9 +56,8 @@ class StudentPublicationLink extends AbstractLink
}
}
public function get_type_name() {
return get_lang('DokeosStudentPublications');
return get_lang('Works');
}
public function is_allowed_to_change_name() {
@ -76,12 +71,13 @@ class StudentPublicationLink extends AbstractLink
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_not_created_links() {
return false;
if (empty($this->course_code)) {
die('Error in get_not_created_links() : course code not set');
}
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id,url from '.$this->get_studpub_table()
$sql = 'SELECT id, url from '.$this->get_studpub_table()
.' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN'
.' (SELECT ref_id FROM '.$tbl_grade_links
.' WHERE type = '.LINK_STUDENTPUBLICATION
@ -96,21 +92,41 @@ class StudentPublicationLink extends AbstractLink
}
return $cats;
}
/**
* Generate an array of all exercises available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_all_links() {
if (empty($this->course_code)) {
die('Error in get_not_created_links() : course code not set');
}
$tbl_grade_links = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$session_id = api_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 id, url, title FROM $tbl_grade_links
WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/
//Only show works from the session
//AND has_properties != ''
$sql = "SELECT id, url, title FROM $tbl_grade_links
WHERE c_id = {$this->course_id} AND active = 1 AND filetype='folder' AND session_id = ".api_get_session_id()."";
$sql = "SELECT id, url FROM $tbl_grade_links
WHERE c_id = {$this->course_id} AND has_properties != '' AND filetype='folder' AND session_id = ".api_get_session_id()."";
$result = Database::query($sql);
while ($data = Database::fetch_array($result)) {
$cats[] = array ($data['id'], basename($data['url']));
$work_name = $data['title'];
if (empty($work_name)) {
$work_name = basename($data['url']);
}
$cats[] = array ($data['id'], $work_name);
}
$cats=isset($cats) ? $cats : array();
return $cats;
@ -130,7 +146,6 @@ class StudentPublicationLink extends AbstractLink
return ($number[0] != 0);
}
public function calc_score($stud_id = null) {
$stud_id = intval($stud_id);
$tbl_stats = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
@ -174,7 +189,7 @@ class StudentPublicationLink extends AbstractLink
if ($assignment['qualification'] != 0) {
$students[$data['user_id']] = $data['qualification'];
$rescount++;
$sum += ($data['qualification'] / $assignment['qualification']);
$sum += $data['qualification'] / $assignment['qualification'];
}
}
}
@ -222,7 +237,8 @@ class StudentPublicationLink extends AbstractLink
}
public function get_link() {
$url = api_get_path(WEB_PATH).'main/work/work.php?cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view';
$session_id = api_get_session_id();
$url = api_get_path(WEB_PATH).'main/work/work.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&id='.$this->exercise_data['id'].'&gradebook=view';
return $url;
}
@ -232,7 +248,7 @@ class StudentPublicationLink extends AbstractLink
if ($tbl_name=='') {
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE c_id ='".$course_info['real_id']."' AND id = '".intval($this->get_ref_id())."' AND session_id=".api_get_session_id()."";
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE c_id ='".$course_info['real_id']."' AND id = '".intval($this->get_ref_id())."' ";
$query = Database::query($sql);
$this->exercise_data = Database::fetch_array($query);
}
@ -248,8 +264,11 @@ class StudentPublicationLink extends AbstractLink
}
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_studpub_table().'
/* $sql = 'SELECT count(id) from '.$this->get_studpub_table().'
WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).' AND session_id='.api_get_session_id();
*/
$sql = 'SELECT count(id) from '.$this->get_studpub_table().'
WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).'';
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);

@ -252,7 +252,6 @@ class GradebookTable extends SortableTable {
//$row[] = $invisibility_span_open.$data[2] . $invisibility_span_close;
//Weight
$row[] = $invisibility_span_open . $data[3] .' / '.$category_weight.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
@ -408,7 +407,7 @@ class GradebookTable extends SortableTable {
* @return string
*/
private function build_name_link ($item) {
//$session_id = api_get_session_id();
switch ($item->get_item_type()) {
// category
case 'C' :
@ -420,7 +419,7 @@ class GradebookTable extends SortableTable {
}
}
$cat=new Category();
$cat = new Category();
$show_message=$cat->show_message_resource_delete($item->get_course_code());
return '&nbsp;<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">'
@ -431,6 +430,7 @@ class GradebookTable extends SortableTable {
case 'E' :
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
// course/platform admin can go to the view_results page

@ -38,13 +38,6 @@ class LinkAddEditForm extends FormValidator
} elseif (isset ($link_type) && isset ($category_object)) {
$link = LinkFactory :: create ($link_type);
$link->set_course_code(api_get_course_id());
/*
$cc = $category_object->get_course_code();
if (empty($cc) && !empty($_GET['course_code'])) {
$link->set_course_code(Database::escape_string($_GET['course_code']));
} else {
$link->set_course_code($category_object->get_course_code());
}*/
} else {
die ('LinkAddEditForm error: define link_type/category_object or link_object');
}
@ -74,6 +67,7 @@ class LinkAddEditForm extends FormValidator
$default_weight = 0;
if (!empty($category_object)) {
foreach ($category_object as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
if ($my_cat->get_parent_id() == 0 ) {
$default_weight = $my_cat->get_weight();
@ -89,10 +83,7 @@ class LinkAddEditForm extends FormValidator
}
}
// ELEMENT: weight
$this->add_textfield('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
'size' => '4',
'maxlength' => '5',
@ -125,7 +116,6 @@ class LinkAddEditForm extends FormValidator
//$this->add_datepicker('date',get_lang('Date'));
//$defaults['date'] = ($form_type == self :: TYPE_EDIT ? $link->get_date() : time());
// ELEMENT: description
if ($link->needs_name_and_description()) {
$this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34'));
@ -141,8 +131,6 @@ class LinkAddEditForm extends FormValidator
$defaults['visible'] = $link->is_visible();
}
// ELEMENT: add results
if ($form_type == self :: TYPE_ADD && $link->needs_results()) {
$this->addElement('checkbox', 'addresult', get_lang('AddResult'));

@ -96,9 +96,9 @@ class GradebookDataGenerator
$row[] = $item->get_name();
$row[] = $item->get_description();
$row[] = $item->get_weight();
if (api_is_allowed_to_edit(null, true)) {
//$row[] = $this->build_date_column($item);
}
/*if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_date_column($item);
}*/
if (count($this->evals_links) > 0) {
if (!api_is_allowed_to_edit() || $status_user != 1 ) {
$row[] = $this->build_result_column($item, $ignore_score_color);
@ -187,7 +187,7 @@ class GradebookDataGenerator
// Other functions
private function build_result_column($item, $ignore_score_color) {
$scoredisplay = ScoreDisplay :: instance();
$scoredisplay = ScoreDisplay :: instance();
$score = $item->calc_score(api_get_user_id());
if (!empty($score)) {

@ -26,10 +26,12 @@ $interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook'
));
$category= Category :: load(0);
$category = Category :: load($_GET['selectcat']);
$my_user_id=Security::remove_XSS($_GET['userid']);
$allevals= $category[0]->get_evaluations($my_user_id, true);
$alllinks= $category[0]->get_links($my_user_id, true);
if ($_GET['selectcat'] != null) {
$addparams= array (
'userid' => $my_user_id,
@ -43,6 +45,7 @@ if ($_GET['selectcat'] != null) {
}
$user_table= new UserTable($my_user_id, $allevals, $alllinks, $addparams);
if (isset ($_GET['exportpdf'])) {
$datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
$data_array = $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);

@ -23,7 +23,7 @@ $show_learnpath = true;
api_protect_course_script();
$lp_id = intval($_GET['lp_id']);
$lp_id = intval($_GET['lp_id']);
// Check if the learning path is visible for student - (LP requisites)
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
@ -61,16 +61,16 @@ foreach ($list as $toc) {
$html .= '<div id="step-'.$step.'" class="step slide" data-x="'.$x.'" data-y="-1500" >';
$html .= '<h2>'.$toc['title'].'</h2>';
$src = $_SESSION['oLP']->get_link('http', $toc['id']);
$src = $_SESSION['oLP']->get_link('http', $toc['id']);
//just showing the src in a iframe ...
$html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="'.$src.'"></iframe>';
$html .= "</div>\n";
$step ++;
}
//Setting the template
$tpl = new Template($tool_name, false, false, true);
$tpl->assign('html', $html);
$content = $tpl->fetch('default/learnpath/impress.tpl');
$tpl->assign('content', $content);

@ -280,10 +280,11 @@ function get_work_count_by_student($user_id, $work_id) {
$user_id = intval($user_id);
$work_id = intval($work_id);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT COUNT(*) as count FROM $work_table
WHERE c_id = $course_id AND parent_id = $work_id AND user_id = $user_id AND active = 1 ";
WHERE c_id = $course_id AND parent_id = $work_id AND user_id = $user_id AND active = 1 AND session_id = $session_id ";
$result = Database::query($sql);
$return = 0;
if (Database::num_rows($result)) {

Loading…
Cancel
Save