|
|
@ -268,7 +268,14 @@ class Result |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$sql .= 'null'; |
|
|
|
$sql .= 'null'; |
|
|
|
} |
|
|
|
} |
|
|
|
$sql .= ' WHERE id = '.$this->id; |
|
|
|
if (isset($this->id)) { |
|
|
|
|
|
|
|
$sql .= " WHERE id = {$this->id}"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$sql .= " WHERE evaluation_id = {$this->evaluation} |
|
|
|
|
|
|
|
AND user_id = {$this->user_id} |
|
|
|
|
|
|
|
"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// no need to update creation date |
|
|
|
// no need to update creation date |
|
|
|
Database::query($sql); |
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
@ -302,16 +309,15 @@ class Result |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function exists() |
|
|
|
public function exists() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$em = Database::getManager(); |
|
|
|
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); |
|
|
|
|
|
|
|
$sql = "SELECT COUNT(*) AS count |
|
|
|
$result = $em |
|
|
|
FROM $table gr |
|
|
|
->createQuery( |
|
|
|
WHERE gr.evaluation_id = $this->evaluation |
|
|
|
'SELECT COUNT(gr) FROM ChamiloCoreBundle:GradebookResult gr |
|
|
|
AND gr.user_id = $this->user_id |
|
|
|
WHERE gr.evaluationId = :eval_id AND gr.userId = :user_id' |
|
|
|
"; |
|
|
|
) |
|
|
|
$result = Database::query($sql); |
|
|
|
->setParameters(['eval_id' => $this->evaluation, 'user_id' => $this->user_id]) |
|
|
|
$row = Database::fetch_array($result); |
|
|
|
->getSingleScalarResult(); |
|
|
|
$count = (int) $row['count']; |
|
|
|
$count = (int) $result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $count > 0; |
|
|
|
return $count > 0; |
|
|
|
} |
|
|
|
} |
|
|
|