|
|
@ -3,6 +3,7 @@ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Framework\Container; |
|
|
|
use Chamilo\CoreBundle\Framework\Container; |
|
|
|
|
|
|
|
use Chamilo\CourseBundle\Entity\CStudentPublication; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gradebook link to student publication item. |
|
|
|
* Gradebook link to student publication item. |
|
|
@ -12,7 +13,6 @@ use Chamilo\CoreBundle\Framework\Container; |
|
|
|
class StudentPublicationLink extends AbstractLink |
|
|
|
class StudentPublicationLink extends AbstractLink |
|
|
|
{ |
|
|
|
{ |
|
|
|
private $studpub_table; |
|
|
|
private $studpub_table; |
|
|
|
private $itemprop_table; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor. |
|
|
|
* Constructor. |
|
|
@ -23,43 +23,6 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
$this->set_type(LINK_STUDENTPUBLICATION); |
|
|
|
$this->set_type(LINK_STUDENTPUBLICATION); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the URL of a document |
|
|
|
|
|
|
|
* This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
|
|
|
|
|
|
* see issue #2705. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function get_view_url($stud_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
// find a file uploaded by the given student, |
|
|
|
|
|
|
|
// with the same title as the evaluation name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$eval = $this->get_evaluation(); |
|
|
|
|
|
|
|
$stud_id = (int) $stud_id; |
|
|
|
|
|
|
|
$itemProperty = $this->get_itemprop_table(); |
|
|
|
|
|
|
|
$workTable = $this->get_studpub_table(); |
|
|
|
|
|
|
|
$courseId = $this->course_id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT pub.url |
|
|
|
|
|
|
|
FROM $itemProperty prop |
|
|
|
|
|
|
|
INNER JOIN $workTable pub |
|
|
|
|
|
|
|
ON (prop.c_id = pub.c_id AND prop.ref = pub.id) |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
prop.c_id = $courseId AND |
|
|
|
|
|
|
|
pub.c_id = $courseId AND |
|
|
|
|
|
|
|
prop.tool = 'work' AND |
|
|
|
|
|
|
|
prop.insert_user_id = $stud_id AND |
|
|
|
|
|
|
|
pub.title = '".Database::escape_string($eval->get_name())."' AND |
|
|
|
|
|
|
|
pub.session_id=".api_get_session_id(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
if ($fileurl = Database::fetch_row($result)) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return string |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -83,7 +46,7 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
if (empty($this->course_code)) { |
|
|
|
if (empty($this->course_code)) { |
|
|
|
return []; |
|
|
|
return []; |
|
|
|
} |
|
|
|
} |
|
|
|
$em = Database::getManager(); |
|
|
|
|
|
|
|
$sessionId = $this->get_session_id(); |
|
|
|
$sessionId = $this->get_session_id(); |
|
|
|
$session = api_get_session_entity($sessionId); |
|
|
|
$session = api_get_session_entity($sessionId); |
|
|
|
/* |
|
|
|
/* |
|
|
@ -109,7 +72,7 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
'filetype' => 'folder', |
|
|
|
'filetype' => 'folder', |
|
|
|
'session' => $session, |
|
|
|
'session' => $session, |
|
|
|
]);*/ |
|
|
|
]);*/ |
|
|
|
|
|
|
|
$cats = []; |
|
|
|
foreach ($links as $data) { |
|
|
|
foreach ($links as $data) { |
|
|
|
$work_name = $data->getTitle(); |
|
|
|
$work_name = $data->getTitle(); |
|
|
|
if (empty($work_name)) { |
|
|
|
if (empty($work_name)) { |
|
|
@ -117,7 +80,6 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
} |
|
|
|
} |
|
|
|
$cats[] = [$data->getIid(), $work_name]; |
|
|
|
$cats[] = [$data->getIid(), $work_name]; |
|
|
|
} |
|
|
|
} |
|
|
|
$cats = isset($cats) ? $cats : []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $cats; |
|
|
|
return $cats; |
|
|
|
} |
|
|
|
} |
|
|
@ -127,14 +89,12 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function has_results() |
|
|
|
public function has_results() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->get_exercise_data(); |
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data)) { |
|
|
|
if (empty($studentPublication)) { |
|
|
|
return ''; |
|
|
|
return ''; |
|
|
|
} |
|
|
|
} |
|
|
|
$id = $data['id']; |
|
|
|
$id = $studentPublication->getIid(); |
|
|
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
|
|
|
$session = api_get_session_entity($this->get_session_id()); |
|
|
|
$session = api_get_session_entity($this->get_session_id()); |
|
|
|
$results = Container::getStudentPublicationRepository() |
|
|
|
$results = Container::getStudentPublicationRepository() |
|
|
|
->findBy([ |
|
|
|
->findBy([ |
|
|
@ -155,23 +115,26 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
{ |
|
|
|
{ |
|
|
|
$studentId = (int) $studentId; |
|
|
|
$studentId = (int) $studentId; |
|
|
|
$em = Database::getManager(); |
|
|
|
$em = Database::getManager(); |
|
|
|
$data = $this->get_exercise_data(); |
|
|
|
$assignment = $this->getStudentPublication(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data)) { |
|
|
|
if (empty($assignment)) { |
|
|
|
return []; |
|
|
|
return []; |
|
|
|
} |
|
|
|
} |
|
|
|
$id = $data['id']; |
|
|
|
|
|
|
|
$session = api_get_session_entity($this->get_session_id()); |
|
|
|
$session = api_get_session_entity($this->get_session_id()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @todo check session id / course id access |
|
|
|
|
|
|
|
/*$id = $studentPublication->getIid(); |
|
|
|
$assignment = Container::getStudentPublicationRepository() |
|
|
|
$assignment = Container::getStudentPublicationRepository() |
|
|
|
->findOneBy([ |
|
|
|
->findOneBy([ |
|
|
|
'cId' => $this->course_id, |
|
|
|
'cId' => $this->course_id, |
|
|
|
'id' => $id, |
|
|
|
'iid' => $id, |
|
|
|
'session' => $session, |
|
|
|
'session' => $session, |
|
|
|
]) |
|
|
|
]) |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
$parentId = !$assignment ? 0 : $assignment->getId(); |
|
|
|
$parentId = !$assignment ? 0 : $assignment->getId(); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parentId = $assignment->getIid(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($session)) { |
|
|
|
if (empty($session)) { |
|
|
|
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
|
|
$dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
|
@ -294,23 +257,26 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
|
|
|
|
|
|
|
|
public function get_name() |
|
|
|
public function get_name() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->get_exercise_data(); |
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
$name = isset($this->exercise_data['title']) && !empty($this->exercise_data['title']) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
|
|
$title = $studentPublication->getTitle(); |
|
|
|
|
|
|
|
|
|
|
|
return $name; |
|
|
|
return empty($title) ? get_lang('Untitled') : $title; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_description() |
|
|
|
public function get_description() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->get_exercise_data(); |
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
|
|
|
|
|
|
|
|
return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
|
|
return $studentPublication->getDescription(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_link() |
|
|
|
public function get_link() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
$sessionId = $this->get_session_id(); |
|
|
|
$sessionId = $this->get_session_id(); |
|
|
|
$url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->getCourseId(), $sessionId).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
|
|
$url = api_get_path(WEB_PATH).'main/work/work.php?'. |
|
|
|
|
|
|
|
api_get_cidreq_params($this->getCourseId(), $sessionId). |
|
|
|
|
|
|
|
'&id='.$studentPublication->getIid().'&gradebook=view'; |
|
|
|
|
|
|
|
|
|
|
|
return $url; |
|
|
|
return $url; |
|
|
|
} |
|
|
|
} |
|
|
@ -327,20 +293,9 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
|
|
|
|
|
|
|
|
public function is_valid_link() |
|
|
|
public function is_valid_link() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->get_exercise_data(); |
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data)) { |
|
|
|
return null !== $studentPublication; |
|
|
|
return ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$id = $data['id']; |
|
|
|
|
|
|
|
$sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
c_id = "'.$this->course_id.'" AND |
|
|
|
|
|
|
|
id = '.$id; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
$number = Database::fetch_row($result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0 != $number[0]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function get_icon_name() |
|
|
|
public function get_icon_name() |
|
|
@ -350,21 +305,17 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
|
|
|
|
|
|
|
|
public function save_linked_data() |
|
|
|
public function save_linked_data() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->get_exercise_data(); |
|
|
|
$studentPublication = $this->getStudentPublication(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data)) { |
|
|
|
if (empty($studentPublication)) { |
|
|
|
return ''; |
|
|
|
return ''; |
|
|
|
} |
|
|
|
} |
|
|
|
$id = $data['id']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$weight = api_float_val($this->get_weight()); |
|
|
|
$weight = api_float_val($this->get_weight()); |
|
|
|
if (!empty($id)) { |
|
|
|
$studentPublication->setWeight($weight); |
|
|
|
//Cleans works |
|
|
|
|
|
|
|
$sql = 'UPDATE '.$this->get_studpub_table().' |
|
|
|
$repo = Container::getStudentPublicationRepository(); |
|
|
|
SET weight= '.$weight.' |
|
|
|
$repo->update($studentPublication); |
|
|
|
WHERE c_id = '.$this->course_id.' AND id ='.$id; |
|
|
|
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -372,10 +323,10 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function delete_linked_data() |
|
|
|
public function delete_linked_data() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = $this->get_exercise_data(); |
|
|
|
/*$data = $this->get_exercise_data(); |
|
|
|
if (empty($data)) { |
|
|
|
if (empty($data)) { |
|
|
|
return ''; |
|
|
|
return ''; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
/*if (!empty($id)) { |
|
|
|
/*if (!empty($id)) { |
|
|
|
//Cleans works |
|
|
|
//Cleans works |
|
|
@ -394,39 +345,13 @@ class StudentPublicationLink extends AbstractLink |
|
|
|
return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
|
|
return $this->studpub_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
private function getStudentPublication(): ?CStudentPublication |
|
|
|
* Lazy load function to get the database table of the item properties. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private function get_itemprop_table() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->itemprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
$repo = Container::getStudentPublicationRepository(); |
|
|
|
} |
|
|
|
if (!empty($this->get_ref_id())) { |
|
|
|
|
|
|
|
return $repo->find($this->get_ref_id()); |
|
|
|
/** |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private function get_exercise_data() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$course_info = api_get_course_info($this->get_course_code()); |
|
|
|
|
|
|
|
if (!isset($this->exercise_data)) { |
|
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
c_id ='".$course_info['real_id']."' AND |
|
|
|
|
|
|
|
id = '".$this->get_ref_id()."' "; |
|
|
|
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
|
|
|
$this->exercise_data = Database::fetch_array($query); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Try with iid |
|
|
|
|
|
|
|
if (empty($this->exercise_data)) { |
|
|
|
|
|
|
|
$sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
|
|
|
|
|
|
WHERE |
|
|
|
|
|
|
|
c_id ='".$course_info['real_id']."' AND |
|
|
|
|
|
|
|
iid = '".$this->get_ref_id()."' "; |
|
|
|
|
|
|
|
$query = Database::query($sql); |
|
|
|
|
|
|
|
$this->exercise_data = Database::fetch_array($query); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->exercise_data; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|