|
|
|
@ -1,10 +1,12 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Defines a gradebook Result object |
|
|
|
* Defines a gradebook Result object |
|
|
|
* @author Bert Steppé, Stijn Konings |
|
|
|
* @author Bert Steppé, Stijn Konings |
|
|
|
* @package chamilo.gradebook |
|
|
|
* @package chamilo.gradebook |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Class |
|
|
|
* Class |
|
|
|
* @package chamilo.gradebook |
|
|
|
* @package chamilo.gradebook |
|
|
|
@ -22,49 +24,60 @@ class Result |
|
|
|
|
|
|
|
|
|
|
|
// CONSTRUCTORS |
|
|
|
// CONSTRUCTORS |
|
|
|
|
|
|
|
|
|
|
|
function Result() { |
|
|
|
function Result() |
|
|
|
|
|
|
|
{ |
|
|
|
$this->created_at = api_get_utc_datetime(); |
|
|
|
$this->created_at = api_get_utc_datetime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GETTERS AND SETTERS |
|
|
|
// GETTERS AND SETTERS |
|
|
|
|
|
|
|
|
|
|
|
public function get_id() { |
|
|
|
public function get_id() |
|
|
|
|
|
|
|
{ |
|
|
|
return $this->id; |
|
|
|
return $this->id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_user_id() { |
|
|
|
public function get_user_id() |
|
|
|
|
|
|
|
{ |
|
|
|
return $this->user_id; |
|
|
|
return $this->user_id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_evaluation_id() { |
|
|
|
public function get_evaluation_id() |
|
|
|
|
|
|
|
{ |
|
|
|
return $this->evaluation; |
|
|
|
return $this->evaluation; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_date() { |
|
|
|
public function get_date() |
|
|
|
|
|
|
|
{ |
|
|
|
return $this->created_at; |
|
|
|
return $this->created_at; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_score() { |
|
|
|
public function get_score() |
|
|
|
|
|
|
|
{ |
|
|
|
return $this->score; |
|
|
|
return $this->score; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function set_id ($id) { |
|
|
|
public function set_id($id) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->id = $id; |
|
|
|
$this->id = $id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function set_user_id ($user_id) { |
|
|
|
public function set_user_id($user_id) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->user_id = $user_id; |
|
|
|
$this->user_id = $user_id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function set_evaluation_id ($evaluation_id) { |
|
|
|
public function set_evaluation_id($evaluation_id) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->evaluation = $evaluation_id; |
|
|
|
$this->evaluation = $evaluation_id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function set_date ($creation_date) { |
|
|
|
public function set_date($creation_date) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->created_at = $creation_date; |
|
|
|
$this->created_at = $creation_date; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function set_score ($score) { |
|
|
|
public function set_score($score) |
|
|
|
|
|
|
|
{ |
|
|
|
$this->score = $score; |
|
|
|
$this->score = $score; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +89,8 @@ class Result |
|
|
|
* @param $user_id user id (student) |
|
|
|
* @param $user_id user id (student) |
|
|
|
* @param $evaluation_id evaluation where this is a result for |
|
|
|
* @param $evaluation_id evaluation where this is a result for |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function load ($id = null, $user_id = null, $evaluation_id = null) { |
|
|
|
public static function load($id = null, $user_id = null, $evaluation_id = null) |
|
|
|
|
|
|
|
{ |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$tbl_course_rel_course = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
$tbl_course_rel_course = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
$tbl_session_rel_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
|
|
$tbl_session_rel_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
|
|
@ -125,8 +139,10 @@ class Result |
|
|
|
$paramcount ++; |
|
|
|
$paramcount ++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!empty($user_id)) { |
|
|
|
if (!empty($user_id)) { |
|
|
|
if ($paramcount != 0) $sql .= ' AND'; |
|
|
|
if ($paramcount != 0) |
|
|
|
else $sql .= ' WHERE'; |
|
|
|
$sql .= ' AND'; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$sql .= ' WHERE'; |
|
|
|
$sql .= ' user_id = ' . Database::escape_string($user_id); |
|
|
|
$sql .= ' user_id = ' . Database::escape_string($user_id); |
|
|
|
$paramcount ++; |
|
|
|
$paramcount ++; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -157,7 +173,8 @@ class Result |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Insert this result into the database |
|
|
|
* Insert this result into the database |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function add() { |
|
|
|
public function add() |
|
|
|
|
|
|
|
{ |
|
|
|
if (isset($this->user_id) && isset($this->evaluation)) { |
|
|
|
if (isset($this->user_id) && isset($this->evaluation)) { |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$sql = "INSERT INTO " . $tbl_grade_results |
|
|
|
$sql = "INSERT INTO " . $tbl_grade_results |
|
|
|
@ -177,12 +194,13 @@ class Result |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
die('Error in Result add: required field empty'); |
|
|
|
die('Error in Result add: required field empty'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* insert log result |
|
|
|
* insert log result |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function add_result__log($userid,$evaluationid){ |
|
|
|
public function add_result__log($userid, $evaluationid) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (isset($userid) && isset($evaluationid)) { |
|
|
|
if (isset($userid) && isset($evaluationid)) { |
|
|
|
$tbl_grade_results_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG); |
|
|
|
$tbl_grade_results_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG); |
|
|
|
@ -209,10 +227,12 @@ class Result |
|
|
|
die('Error in Result add: required field empty'); |
|
|
|
die('Error in Result add: required field empty'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Update the properties of this result in the database |
|
|
|
* Update the properties of this result in the database |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function save() { |
|
|
|
public function save() |
|
|
|
|
|
|
|
{ |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$sql = 'UPDATE ' . $tbl_grade_results . ' |
|
|
|
$sql = 'UPDATE ' . $tbl_grade_results . ' |
|
|
|
SET user_id = ' . $this->get_user_id() |
|
|
|
SET user_id = ' . $this->get_user_id() |
|
|
|
@ -231,9 +251,11 @@ class Result |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Delete this result from the database |
|
|
|
* Delete this result from the database |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function delete() { |
|
|
|
public function delete() |
|
|
|
|
|
|
|
{ |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
$sql = 'DELETE FROM ' . $tbl_grade_results . ' WHERE id = ' . $this->id; |
|
|
|
$sql = 'DELETE FROM ' . $tbl_grade_results . ' WHERE id = ' . $this->id; |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|