Update from 1.11.x, fix queries, use iid, fix PHP warnings

pull/3741/head
Julio Montoya 4 years ago
parent 3ba91c46fc
commit 49b9ea1519
  1. 20
      public/main/course_info/infocours.php
  2. 12
      public/main/gradebook/gradebook_edit_all.php
  3. 14
      public/main/gradebook/lib/fe/catform.class.php
  4. 7
      public/main/gradebook/lib/fe/dataform.class.php
  5. 3
      public/main/inc/lib/document.lib.php
  6. 2
      public/main/lp/lp_add_category.php
  7. 4
      public/main/lp/lp_edit.php
  8. 2
      public/main/mySpace/myStudents.php
  9. 13
      public/main/survey/survey.lib.php
  10. 2
      public/main/work/edit.php
  11. 52
      public/main/work/view.php
  12. 59
      public/main/work/work.lib.php
  13. 3
      src/CoreBundle/Tool/Settings.php
  14. 9
      src/CoreBundle/Traits/ControllerTrait.php

@ -43,7 +43,7 @@ $router = Container::getRouter();
$translator = Container::getTranslator(); $translator = Container::getTranslator();
$show_delete_watermark_text_message = false; $show_delete_watermark_text_message = false;
if ('true' == api_get_setting('pdf_export_watermark_by_course')) { if ('true' === api_get_setting('pdf_export_watermark_by_course')) {
if (isset($_GET['delete_watermark'])) { if (isset($_GET['delete_watermark'])) {
PDF::delete_watermark($course_code); PDF::delete_watermark($course_code);
$show_delete_watermark_text_message = true; $show_delete_watermark_text_message = true;
@ -67,13 +67,18 @@ function card_settings_open($id, $title, $open = false, $icon, $parent)
$html = '<div class="card">'; $html = '<div class="card">';
$html .= '<div class="card-header" id="card_'.$id.'">'; $html .= '<div class="card-header" id="card_'.$id.'">';
$html .= '<h5 class="card-title">'; $html .= '<h5 class="card-title">';
$html .= '<a role="button" class="'.(($open) ? 'collapse' : ' ').'" data-toggle="collapse" data-target="#collapse_'.$id.'" aria-expanded="true" aria-controls="collapse_'.$id.'">'; $html .= '<a
role="button" class="'.(($open) ? 'collapse' : ' ').'"
data-toggle="collapse" data-target="#collapse_'.$id.'"
aria-expanded="true" aria-controls="collapse_'.$id.'">';
if ($icon) { if ($icon) {
$html .= Display::return_icon($icon, null, null, ICON_SIZE_SMALL); $html .= Display::return_icon($icon, null, null, ICON_SIZE_SMALL);
} }
$html .= $title; $html .= $title;
$html .= '</a></h5></div>'; $html .= '</a></h5></div>';
$html .= '<div id="collapse_'.$id.'" class="collapse show" aria-labelledby="heading_'.$id.'" data-parent="#'.$parent.'">'; $html .= '<div
id="collapse_'.$id.'"
class="collapse show" aria-labelledby="heading_'.$id.'" data-parent="#'.$parent.'">';
$html .= '<div class="card-body">'; $html .= '<div class="card-body">';
return $html; return $html;
@ -86,14 +91,17 @@ function card_settings_close()
return $html; return $html;
} }
$form->addHtml(card_settings_open('course_settings', get_lang('Course settings'), true, 'settings.png', 'accordionSettings')); $form->addHtml(
card_settings_open('course_settings', get_lang('Course settings'), true, 'settings.png', 'accordionSettings')
);
$image = ''; $image = '';
$illustrationUrl = $illustrationRepo->getIllustrationUrl($courseEntity, 'course_picture_medium'); $illustrationUrl = $illustrationRepo->getIllustrationUrl($courseEntity, 'course_picture_medium');
if (!empty($illustrationUrl)) { if (!empty($illustrationUrl)) {
$image = '<div class="row"><label class="col-md-2 control-label">'.get_lang('Image').'</label> $image = '<div class="row">
<div class="col-md-8"><img class="img-thumbnail" src="'.$illustrationUrl.'" /></div></div>'; <label class="col-md-2 control-label">'.get_lang('Image').'</label>
<div class="col-md-8"><img class="img-thumbnail" src="'.$illustrationUrl.'" /></div></div>';
} }
$form->addText('title', get_lang('Title'), true); $form->addText('title', get_lang('Title'), true);

@ -39,7 +39,7 @@ $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$table_evaluated[LINK_EXERCISE] = [ $table_evaluated[LINK_EXERCISE] = [
TABLE_QUIZ_TEST, TABLE_QUIZ_TEST,
'title', 'title',
'id', 'iid',
get_lang('Test'), get_lang('Test'),
]; ];
$table_evaluated[LINK_DROPBOX] = [ $table_evaluated[LINK_DROPBOX] = [
@ -51,31 +51,31 @@ $table_evaluated[LINK_DROPBOX] = [
$table_evaluated[LINK_STUDENTPUBLICATION] = [ $table_evaluated[LINK_STUDENTPUBLICATION] = [
TABLE_STUDENT_PUBLICATION, TABLE_STUDENT_PUBLICATION,
'url', 'url',
'id', 'iid',
get_lang('Assignments'), get_lang('Assignments'),
]; ];
$table_evaluated[LINK_LEARNPATH] = [ $table_evaluated[LINK_LEARNPATH] = [
TABLE_LP_MAIN, TABLE_LP_MAIN,
'name', 'name',
'id', 'iid',
get_lang('Courses'), get_lang('Courses'),
]; ];
$table_evaluated[LINK_FORUM_THREAD] = [ $table_evaluated[LINK_FORUM_THREAD] = [
TABLE_FORUM_THREAD, TABLE_FORUM_THREAD,
'thread_title_qualify', 'thread_title_qualify',
'thread_id', 'iid',
get_lang('Forum'), get_lang('Forum'),
]; ];
$table_evaluated[LINK_ATTENDANCE] = [ $table_evaluated[LINK_ATTENDANCE] = [
TABLE_ATTENDANCE, TABLE_ATTENDANCE,
'attendance_title_qualify', 'attendance_title_qualify',
'id', 'iid',
get_lang('Attendance'), get_lang('Attendance'),
]; ];
$table_evaluated[LINK_SURVEY] = [ $table_evaluated[LINK_SURVEY] = [
TABLE_SURVEY, TABLE_SURVEY,
'code', 'code',
'survey_id', 'iid',
get_lang('Survey'), get_lang('Survey'),
]; ];

@ -342,7 +342,7 @@ class CatForm extends FormValidator
if (isset($this->category_object) && if (isset($this->category_object) &&
0 == $this->category_object->get_parent_id() && 0 == $this->category_object->get_parent_id() &&
(api_is_platform_admin() || 'true' == api_get_setting('teachers_can_change_grade_model_settings')) (api_is_platform_admin() || 'true' === api_get_setting('teachers_can_change_grade_model_settings'))
) { ) {
// Getting grade models // Getting grade models
$obj = new GradeModel(); $obj = new GradeModel();
@ -370,7 +370,7 @@ class CatForm extends FormValidator
} }
if (count($test_cats) > 1 || !empty($links)) { if (count($test_cats) > 1 || !empty($links)) {
if ('true' == api_get_setting('gradebook_enable_grade_model')) { if ('true' === api_get_setting('gradebook_enable_grade_model')) {
$this->freeze('grade_model_id'); $this->freeze('grade_model_id');
} }
} }
@ -404,23 +404,25 @@ class CatForm extends FormValidator
$documentId = $this->category_object->getDocumentId(); $documentId = $this->category_object->getDocumentId();
if (!empty($documentId)) { if (!empty($documentId)) {
$documentData = DocumentManager::get_document_data_by_id($documentId, api_get_course_id()); $repo = \Chamilo\CoreBundle\Framework\Container::getDocumentRepository();
/** @var \Chamilo\CourseBundle\Entity\CDocument $documentData */
$documentData = $repo->find($documentId);
if (!empty($documentData)) { if (!empty($documentData)) {
$this->addLabel(get_lang('Certificate'), $documentData['title']); $this->addLabel(get_lang('Certificate'), $documentData->getTitle());
} }
} }
if (self::TYPE_ADD == $this->form_type) { if (self::TYPE_ADD == $this->form_type) {
$this->addButtonCreate(get_lang('Add category')); $this->addButtonCreate(get_lang('Add category'));
} else { } else {
$this->addElement('hidden', 'editcat', intval($_GET['editcat'])); $this->addElement('hidden', 'editcat', (int) $_GET['editcat']);
$this->addButtonUpdate(get_lang('Edit this category')); $this->addButtonUpdate(get_lang('Edit this category'));
} }
$setting = api_get_setting('tool_visible_by_default_at_creation'); $setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1; $visibility_default = 1;
if (isset($setting['gradebook']) && 'false' == $setting['gradebook']) { if (isset($setting['gradebook']) && 'false' === $setting['gradebook']) {
$visibility_default = 0; $visibility_default = 0;
} }

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -8,9 +9,9 @@
*/ */
class DataForm extends FormValidator class DataForm extends FormValidator
{ {
const TYPE_IMPORT = 1; public const TYPE_IMPORT = 1;
const TYPE_EXPORT = 2; public const TYPE_EXPORT = 2;
const TYPE_EXPORT_PDF = 3; public const TYPE_EXPORT_PDF = 3;
/** /**
* Builds a form containing form items based on a given parameter. * Builds a form containing form items based on a given parameter.

@ -1176,7 +1176,6 @@ class DocumentManager
$session_id = empty($session_id) ? api_get_session_id() : (int) $session_id; $session_id = empty($session_id) ? api_get_session_id() : (int) $session_id;
$groupId = api_get_group_id(); $groupId = api_get_group_id();
//$www = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document';
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$id = (int) $id; $id = (int) $id;
$sessionCondition = api_get_session_condition($session_id, true, true); $sessionCondition = api_get_session_condition($session_id, true, true);
@ -1189,7 +1188,7 @@ class DocumentManager
} }
$result = Database::query($sql); $result = Database::query($sql);
$courseParam = '&cidReq='.$course_code.'&id='.$id.'&sid='.$session_id.'&gidReq='.$groupId; $courseParam = '&cid='.$course_id.'&id='.$id.'&sid='.$session_id.'&gid='.$groupId;
if ($result && 1 == Database::num_rows($result)) { if ($result && 1 == Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
//@todo need to clarify the name of the URLs not nice right now //@todo need to clarify the name of the URLs not nice right now

@ -69,7 +69,7 @@ if ($form->validate()) {
if ($id) { if ($id) {
$item = learnpath::getCategory($id); $item = learnpath::getCategory($id);
$defaults = [ $defaults = [
'id' => $item->getId(), 'id' => $item->getIid(),
'name' => $item->getName(), 'name' => $item->getName(),
]; ];
$form->setDefaults($defaults); $form->setDefaults($defaults);

@ -375,7 +375,9 @@ if ($form->validate()) {
$request = Container::getRequest(); $request = Container::getRequest();
if ($request->files->has('lp_preview_image')) { if ($request->files->has('lp_preview_image')) {
$file = $request->files->get('lp_preview_image'); $file = $request->files->get('lp_preview_image');
$lpRepo->addFile($lp, $file); if (!empty($file)) {
$lpRepo->addFile($lp, $file);
}
} }
$em->persist($lp); $em->persist($lp);

@ -2133,7 +2133,7 @@ if (empty($details)) {
echo '<td class="text-center">'.api_convert_and_format_date( echo '<td class="text-center">'.api_convert_and_format_date(
$results['sent_date_from_db'] $results['sent_date_from_db']
).' '.$results['expiry_note'].'</td>'; ).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']); $assignment = get_work_assignment_by_id($work->iid, $courseInfo['real_id']);
echo '<td class="text-center">'; echo '<td class="text-center">';
if (!empty($assignment['expires_on'])) { if (!empty($assignment['expires_on'])) {

@ -311,7 +311,7 @@ class SurveyManager
$sql = 'SELECT survey_version FROM '.$table_survey.' $sql = 'SELECT survey_version FROM '.$table_survey.'
WHERE WHERE
c_id = '.$course_id.' AND c_id = '.$course_id.' AND
survey_id = '.intval($values['parent_id']); iid = '.intval($values['parent_id']);
$rs = Database::query($sql); $rs = Database::query($sql);
$getversion = Database::fetch_array($rs, 'ASSOC'); $getversion = Database::fetch_array($rs, 'ASSOC');
if (empty($getversion['survey_version'])) { if (empty($getversion['survey_version'])) {
@ -590,9 +590,6 @@ class SurveyManager
'".$_course['id']."')"; '".$_course['id']."')";
Database::query($sql); Database::query($sql);
$return = Database::insert_id(); $return = Database::insert_id();
$sql = "UPDATE $table_survey SET survey_id = $return WHERE iid = $return";
Database::query($sql);
} else { } else {
$sql = "UPDATE $table_survey SET $sql = "UPDATE $table_survey SET
code = '".Database::escape_string($values['survey_code'])."', code = '".Database::escape_string($values['survey_code'])."',
@ -2124,12 +2121,12 @@ class SurveyManager
Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $surveyAnswerTable $sql = "DELETE FROM $surveyAnswerTable
WHERE survey_id = $surveyId AND c_id = $courseId "; WHERE survey_id = $surveyId AND c_id = $courseId ";
Database::query($sql); Database::query($sql);
$sql = "UPDATE $surveyTable $sql = "UPDATE $surveyTable
SET invited = 0, answered = 0 SET invited = 0, answered = 0
WHERE survey_id = $surveyId AND c_id = $courseId AND session_id = $sessionId "; WHERE iid = $surveyId AND c_id = $courseId AND session_id = $sessionId ";
Database::query($sql); Database::query($sql);
return true; return true;
@ -2176,10 +2173,6 @@ class SurveyManager
$newSurveyId = Database::insert($surveyTable, $surveyData); $newSurveyId = Database::insert($surveyTable, $surveyData);
if ($newSurveyId) { if ($newSurveyId) {
$sql = "UPDATE $surveyTable SET survey_id = $newSurveyId
WHERE iid = $newSurveyId";
Database::query($sql);
$sql = "SELECT * FROM $surveyQuestionGroupTable $sql = "SELECT * FROM $surveyQuestionGroupTable
WHERE c_id = $originalCourseId AND survey_id = $surveyId"; WHERE c_id = $originalCourseId AND survey_id = $surveyId";
$res = Database::query($sql); $res = Database::query($sql);

@ -148,7 +148,7 @@ $form->addText('title', get_lang('Title'), true, ['id' => 'file_upload']);
if ($is_allowed_to_edit && !empty($item_id)) { if ($is_allowed_to_edit && !empty($item_id)) {
$sql = "SELECT contains_file, url $sql = "SELECT contains_file, url
FROM $work_table FROM $work_table
WHERE c_id = $course_id AND id ='$item_id' "; WHERE c_id = $course_id AND iid ='$item_id' ";
$result = Database::query($sql); $result = Database::query($sql);
if (false !== $result && Database::num_rows($result) > 0) { if (false !== $result && Database::num_rows($result) > 0) {
$row = Database::fetch_array($result); $row = Database::fetch_array($result);

@ -2,25 +2,32 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CStudentPublication;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION; $current_course_tool = TOOL_STUDENTPUBLICATION;
require_once 'work.lib.php'; require_once 'work.lib.php';
$id = isset($_GET['id']) ? (int) $_GET['id'] : null; $id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$work = get_work_data_by_id($id);
$repo = Container::getStudentPublicationRepository();
/** @var CStudentPublication $work */
$work = $repo->find($id);
if (empty($work)) { if (empty($work)) {
api_not_allowed(true); api_not_allowed(true);
} }
protectWork(api_get_course_info(), $work['parent_id']); $parentId = $work->getParentId();
protectWork(api_get_course_info(), $parentId);
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $action = $_REQUEST['action'] ?? null;
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null; $page = $_REQUEST['page'] ?? null;
$work['title'] = isset($work['title']) ? Security::remove_XSS($work['title']) : ''; /*$work['title'] = isset($work['title']) ? Security::remove_XSS($work['title']) : '';
$work['description'] = isset($work['description']) ? Security::remove_XSS($work['description']) : ''; $work['description'] = isset($work['description']) ? Security::remove_XSS($work['description']) : '';*/
$htmlHeadXtra[] = '<script>'.ExerciseLib::getJsCode().'</script>'; $htmlHeadXtra[] = '<script>'.ExerciseLib::getJsCode().'</script>';
$interbreadcrumb[] = [ $interbreadcrumb[] = [
@ -28,7 +35,7 @@ $interbreadcrumb[] = [
'name' => get_lang('Assignments'), 'name' => get_lang('Assignments'),
]; ];
$folderData = get_work_data_by_id($work['parent_id']); $folderData = get_work_data_by_id($parentId);
$courseInfo = api_get_course_info(); $courseInfo = api_get_course_info();
$courseEntity = api_get_course_entity(); $courseEntity = api_get_course_entity();
$isCourseManager = api_is_platform_admin() || api_is_coach() || api_is_allowed_to_edit(false, false, true); $isCourseManager = api_is_platform_admin() || api_is_coach() || api_is_allowed_to_edit(false, false, true);
@ -36,7 +43,9 @@ $isCourseManager = api_is_platform_admin() || api_is_coach() || api_is_allowed_t
$allowEdition = false; $allowEdition = false;
if ($isCourseManager) { if ($isCourseManager) {
$allowEdition = true; $allowEdition = true;
if (!empty($work['qualification']) && api_get_configuration_value('block_student_publication_score_edition')) { if (!empty($work->getQualification()) &&
api_get_configuration_value('block_student_publication_score_edition')
) {
$allowEdition = false; $allowEdition = false;
} }
} }
@ -50,26 +59,28 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
$courseInfo $courseInfo
); );
$isDrhOfSession = !empty(SessionManager::getSessionFollowedByDrh(api_get_user_id(), $work['session_id'])); $isDrhOfSession = false;
// @todo fix $isDrhOfSession check
//$isDrhOfSession = !empty(SessionManager::getSessionFollowedByDrh(api_get_user_id(), $work['session_id']));
if ((user_is_author($id) || $isDrhOfCourse || $allowEdition || $isDrhOfSession) || if (($isDrhOfCourse || $allowEdition || $isDrhOfSession || user_is_author($id)) ||
( (
0 == $courseInfo['show_score'] && 0 == $courseInfo['show_score'] &&
1 == $work['active'] && 1 == $work->getActive() &&
1 == $work['accepted'] 1 == $work->getAccepted()
) )
) { ) {
if ((api_is_allowed_to_edit() || api_is_coach()) || api_is_drh()) { if ((api_is_allowed_to_edit() || api_is_coach()) || api_is_drh()) {
$url_dir = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$folderData['id'].'&'.api_get_cidreq(); $url_dir = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$folderData['iid'].'&'.api_get_cidreq();
} else { } else {
$url_dir = api_get_path(WEB_CODE_PATH).'work/work_list.php?id='.$folderData['id'].'&'.api_get_cidreq(); $url_dir = api_get_path(WEB_CODE_PATH).'work/work_list.php?id='.$folderData['iid'].'&'.api_get_cidreq();
} }
$userInfo = api_get_user_info($work['user_id']); $userInfo = api_get_user_info($work->getUserId());
$interbreadcrumb[] = ['url' => $url_dir, 'name' => $folderData['title']]; $interbreadcrumb[] = ['url' => $url_dir, 'name' => $folderData['title']];
$interbreadcrumb[] = ['url' => '#', 'name' => $userInfo['complete_name']]; $interbreadcrumb[] = ['url' => '#', 'name' => $userInfo['complete_name']];
$interbreadcrumb[] = ['url' => '#', 'name' => $work['title']]; $interbreadcrumb[] = ['url' => '#', 'name' => $work->getTitle()];
$workId = $work->getIid();
if (( if ((
0 == $courseInfo['show_score'] && 0 == $courseInfo['show_score'] &&
1 == $work['active'] && 1 == $work['active'] &&
@ -78,9 +89,10 @@ if ((user_is_author($id) || $isDrhOfCourse || $allowEdition || $isDrhOfSession)
$isCourseManager || user_is_author($id) || $isDrhOfCourse || $isDrhOfSession $isCourseManager || user_is_author($id) || $isDrhOfCourse || $isDrhOfSession
) { ) {
if ('edit' === $page) { if ('edit' === $page) {
$url = api_get_path(WEB_CODE_PATH).'work/edit.php?id='.$folderData['id'].'&item_id='.$work['id'].'&'.api_get_cidreq(); $url = api_get_path(WEB_CODE_PATH).
'work/edit.php?id='.$folderData['iid'].'&item_id='.$workId.'&'.api_get_cidreq();
} else { } else {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq(); $url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$workId.'&'.api_get_cidreq();
$allowRedirect = api_get_configuration_value('allow_redirect_to_main_page_after_work_upload'); $allowRedirect = api_get_configuration_value('allow_redirect_to_main_page_after_work_upload');
$urlToRedirect = ''; $urlToRedirect = '';
@ -172,7 +184,7 @@ if ((user_is_author($id) || $isDrhOfCourse || $allowEdition || $isDrhOfSession)
$tpl->assign('comments', $comments); $tpl->assign('comments', $comments);
$actions = ''; $actions = '';
if (isset($work['contains_file']) && !empty($work['contains_file'])) { if ($work->getContainsFile()) {
if (isset($work['download_url']) && !empty($work['download_url'])) { if (isset($work['download_url']) && !empty($work['download_url'])) {
$actions = Display::url( $actions = Display::url(
Display::return_icon( Display::return_icon(

@ -142,15 +142,15 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
if (empty($studentPublication->getTitle())) { if (empty($studentPublication->getTitle())) {
$work['title'] = basename($studentPublication->getUrl()); $work['title'] = basename($studentPublication->getUrl());
} }
$work['download_url'] = $router->generate( $url = $router->generate(
'chamilo_core_resource_download', 'chamilo_core_resource_download',
[ [
'id' => $studentPublication->getResourceNode()->getId(), 'id' => $studentPublication->getResourceNode()->getId(),
'tool' => 'student_publication', 'tool' => 'student_publication',
'type' => 'student_publications', 'type' => 'student_publications',
] ]
).'?'.api_get_cidreq(); );
$work['download_url'] = $url.'?'.api_get_cidreq();
$work['view_url'] = $webCodePath.'work/view.php?id='.$workId.'&'.api_get_cidreq(); $work['view_url'] = $webCodePath.'work/view.php?id='.$workId.'&'.api_get_cidreq();
$showUrl = $work['show_url'] = $webCodePath.'work/show_file.php?id='.$workId.'&'.api_get_cidreq(); $showUrl = $work['show_url'] = $webCodePath.'work/show_file.php?id='.$workId.'&'.api_get_cidreq();
$work['show_content'] = ''; $work['show_content'] = '';
@ -697,7 +697,7 @@ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_d
$move_file = (int) $move_file; $move_file = (int) $move_file;
$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT title, url FROM $tbl_work $sql = "SELECT title, url FROM $tbl_work
WHERE c_id = $course_id AND id ='".$move_file."'"; WHERE c_id = $course_id AND iid ='".$move_file."'";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
$title = empty($row['title']) ? basename($row['url']) : $row['title']; $title = empty($row['title']) ? basename($row['url']) : $row['title'];
@ -3284,29 +3284,29 @@ function getWorkDescriptionToolbar()
} }
/** /**
* @param array $work
*
* @return array * @return array
*/ */
function getWorkComments($work) function getWorkComments(CStudentPublication $work)
{ {
$commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT); $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
$userTable = Database::get_main_table(TABLE_MAIN_USER); $userTable = Database::get_main_table(TABLE_MAIN_USER);
$courseId = (int) $work['c_id']; /*$courseId = (int) $work['c_id'];
$workId = (int) $work['iid']; $workId = (int) $work['iid'];
if (empty($courseId) || empty($workId)) { if (empty($courseId) || empty($workId)) {
return []; return [];
} }*/
$workId = $work->getIid();
$sql = "SELECT $sql = "SELECT
c.id, c.iid,
c.user_id c.user_id
FROM $commentTable c FROM $commentTable c
INNER JOIN $userTable u INNER JOIN $userTable u
ON (u.id = c.user_id) ON (u.id = c.user_id)
WHERE c_id = $courseId AND work_id = $workId WHERE work_id = $workId
ORDER BY sent_at ORDER BY sent_at
"; ";
$result = Database::query($sql); $result = Database::query($sql);
@ -3793,14 +3793,15 @@ function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
} }
/** /**
* @param array $work
* @param array $workParent * @param array $workParent
* *
* @return string * @return string
*/ */
function getWorkCommentForm($work, $workParent) function getWorkCommentForm(CStudentPublication $work, $workParent)
{ {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['iid'].'&action=send_comment&'.api_get_cidreq(); $id = $work->getIid();
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$id.'&action=send_comment&'.api_get_cidreq();
$form = new FormValidator( $form = new FormValidator(
'work_comment', 'work_comment',
'post', 'post',
@ -3815,7 +3816,9 @@ function getWorkCommentForm($work, $workParent)
$allowEdition = false; $allowEdition = false;
if ($isCourseManager) { if ($isCourseManager) {
$allowEdition = true; $allowEdition = true;
if (!empty($work['qualification']) && api_get_configuration_value('block_student_publication_score_edition')) { if (!empty($work->getQualification()) &&
api_get_configuration_value('block_student_publication_score_edition')
) {
$allowEdition = false; $allowEdition = false;
} }
} }
@ -3842,18 +3845,24 @@ function getWorkCommentForm($work, $workParent)
$form, $form,
'qualification', 'qualification',
$qualification, $qualification,
$work['qualification'] $work->getQualification()
); );
} }
$form->addFile('file', get_lang('Correction')); $form->addFile('file', get_lang('Correction'));
$form->setDefaults(['qualification' => $work['qualification']]); $form->setDefaults(['qualification' => $work->getQualification()]);
} }
} }
Skill::addSkillsToUserForm($form, ITEM_TYPE_STUDENT_PUBLICATION, $workParent['iid'], $work['user_id'], $work['iid']); Skill::addSkillsToUserForm(
$form,
ITEM_TYPE_STUDENT_PUBLICATION,
$workParent['iid'],
$work->getUserId(),
$id
);
$form->addHtmlEditor('comment', get_lang('Comment'), false); $form->addHtmlEditor('comment', get_lang('Comment'), false);
$form->addFile('attachment', get_lang('Attachment')); $form->addFile('attachment', get_lang('Attachment'));
$form->addElement('hidden', 'iid', $work['iid']); $form->addElement('hidden', 'iid', $id);
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$form->addCheckBox( $form->addCheckBox(

@ -4,9 +4,6 @@
namespace Chamilo\CoreBundle\Tool; namespace Chamilo\CoreBundle\Tool;
/**
* Class Announcement.
*/
class Settings extends AbstractTool class Settings extends AbstractTool
{ {
} }

@ -21,6 +21,7 @@ use Chamilo\CourseBundle\Repository\CLpCategoryRepository;
use Chamilo\CourseBundle\Repository\CLpRepository; use Chamilo\CourseBundle\Repository\CLpRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository; use Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository;
use Chamilo\CourseBundle\Repository\CQuizQuestionRepository; use Chamilo\CourseBundle\Repository\CQuizQuestionRepository;
use Chamilo\CourseBundle\Repository\CStudentPublicationRepository;
use Knp\Menu\FactoryInterface as MenuFactoryInterface; use Knp\Menu\FactoryInterface as MenuFactoryInterface;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory; use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -43,19 +44,21 @@ trait ControllerTrait
*/ */
$services[] = ResourceFactory::class; $services[] = ResourceFactory::class;
$services[] = ResourceNodeRepository::class; $services[] = ResourceNodeRepository::class;
$services[] = CAnnouncementRepository::class; $services[] = CAnnouncementRepository::class;
$services[] = CAnnouncementAttachmentRepository::class; $services[] = CAnnouncementAttachmentRepository::class;
$services[] = CAttendanceRepository::class; $services[] = CAttendanceRepository::class;
$services[] = CBlogRepository::class; $services[] = CBlogRepository::class;
$services[] = CCalendarEventAttachmentRepository::class; $services[] = CCalendarEventAttachmentRepository::class;
$services[] = CDocumentRepository::class; $services[] = CDocumentRepository::class;
$services[] = CQuizQuestionRepository::class;
$services[] = CQuizQuestionCategoryRepository::class;
$services[] = CForumForumRepository::class; $services[] = CForumForumRepository::class;
$services[] = CForumAttachmentRepository::class; $services[] = CForumAttachmentRepository::class;
$services[] = CLpRepository::class; $services[] = CLpRepository::class;
$services[] = CLpCategoryRepository::class; $services[] = CLpCategoryRepository::class;
$services[] = CQuizQuestionRepository::class;
$services[] = CQuizQuestionCategoryRepository::class;
$services[] = CStudentPublicationRepository::class;
$services[] = IllustrationRepository::class; $services[] = IllustrationRepository::class;

Loading…
Cancel
Save