Thematic: Use resources and doctrine entities

pull/3844/head
Julio Montoya 5 years ago
parent cb50ee3693
commit 69beb7c5e2
  1. 58
      public/main/course_progress/index.php
  2. 15
      public/main/inc/ajax/thematic.ajax.php
  3. 5
      public/main/inc/introductionSection.inc.php
  4. 40
      public/main/inc/lib/attendance.lib.php
  5. 138
      public/main/inc/lib/thematic.lib.php
  6. 5
      public/main/mySpace/course.php
  7. 4
      public/main/mySpace/myStudents.php
  8. 20
      public/main/template/default/course_progress/progress.html.twig
  9. 5
      public/plugin/dashboard/block_course/block_course.class.php
  10. 4
      src/CoreBundle/Resources/config/tools.yml
  11. 65
      src/CourseBundle/Entity/CThematic.php
  12. 33
      src/CourseBundle/Entity/CThematicAdvance.php
  13. 84
      src/CourseBundle/Entity/CThematicPlan.php
  14. 48
      src/CourseBundle/Repository/CThematicPlanRepository.php

@ -17,6 +17,8 @@ $current_course_tool = TOOL_COURSE_PROGRESS;
// protect a course script // protect a course script
api_protect_course_script(true); api_protect_course_script(true);
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$course = api_get_course_entity();
$session = api_get_session_entity();
$description_type = null; $description_type = null;
// get actions // get actions
@ -107,7 +109,7 @@ function check_per_custom_date(obj) {
$attendance = new Attendance(); $attendance = new Attendance();
// get data for attendance input select // get data for attendance input select
$attendance_list = $attendance->get_attendances_list(); $attendance_list = $attendance->getAttendanceList($course, $session);
$attendance_select = []; $attendance_select = [];
$attendance_select[0] = get_lang('Select an attendance'); $attendance_select[0] = get_lang('Select an attendance');
foreach ($attendance_list as $attendanceEntity) { foreach ($attendance_list as $attendanceEntity) {
@ -237,7 +239,6 @@ switch ($action) {
header('Location: '.$currentUrl); header('Location: '.$currentUrl);
exit; exit;
break; break;
case 'thematic_delete': case 'thematic_delete':
// Delete a thematic // Delete a thematic
if (!empty($thematicId) && api_is_allowed_to_edit(null, true)) { if (!empty($thematicId) && api_is_allowed_to_edit(null, true)) {
@ -252,7 +253,7 @@ switch ($action) {
if (isset($_POST['replace']) && $_POST['replace']) { if (isset($_POST['replace']) && $_POST['replace']) {
// Remove current thematic. // Remove current thematic.
$list = $thematicManager->get_thematic_list(); $list = $thematicManager->getThematicList($course, $session);
foreach ($list as $id) { foreach ($list as $id) {
$thematicManager->delete($id); $thematicManager->delete($id);
} }
@ -332,7 +333,7 @@ switch ($action) {
if (!api_is_allowed_to_edit(null, true)) { if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(); api_not_allowed();
} }
$thematicManager->move_thematic('up', $thematicId); $thematicManager->moveThematic('up', $thematicId, $course, $session);
header('Location: '.$currentUrl); header('Location: '.$currentUrl);
exit; exit;
@ -341,13 +342,13 @@ switch ($action) {
if (!api_is_allowed_to_edit(null, true)) { if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(); api_not_allowed();
} }
$thematicManager->move_thematic('down', $thematicId); $thematicManager->moveThematic('down', $thematicId, $course, $session);
header('Location: '.$currentUrl); header('Location: '.$currentUrl);
exit; exit;
break; break;
case 'thematic_export': case 'thematic_export':
$list = $thematicManager->get_thematic_list(); $list = $thematicManager->getThematicList($course, $session);
$csv = []; $csv = [];
$csv[] = ['type', 'data1', 'data2', 'data3']; $csv[] = ['type', 'data1', 'data2', 'data3'];
foreach ($list as $thematicEntity) { foreach ($list as $thematicEntity) {
@ -387,7 +388,7 @@ switch ($action) {
case 'thematic_export_pdf': case 'thematic_export_pdf':
$pdfOrientation = api_get_configuration_value('thematic_pdf_orientation'); $pdfOrientation = api_get_configuration_value('thematic_pdf_orientation');
$view = new Template('', false, false, false, true, false, false); $view = new Template('', false, false, false, true, false, false);
$list = $thematicManager->get_thematic_list(); $list = $thematicManager->getThematicList($course, $session);
$view->assign('data', $list); $view->assign('data', $list);
$template = $view->get_template('course_progress/pdf_general_thematic.tpl'); $template = $view->get_template('course_progress/pdf_general_thematic.tpl');
@ -494,17 +495,18 @@ switch ($action) {
$thematic_data[$thematicId] = $thematicEntity; $thematic_data[$thematicId] = $thematicEntity;
$data['total_average_of_advances'] = $thematicManager->get_average_of_advances_by_thematic($thematicId); $data['total_average_of_advances'] = $thematicManager->get_average_of_advances_by_thematic($thematicId);
} else { } else {
$thematic_data = $thematicManager->get_thematic_list(api_get_course_id(), api_get_session_id()); $thematic_data = $thematicManager->getThematicList($course, $session);
$max_thematic_item = $thematicManager->get_max_thematic_item(); //$max_thematic_item = $thematicManager->get_max_thematic_item($course, $session);
$last_done_thematic_advance = $thematicManager->get_last_done_thematic_advance(); $max_thematic_item = 0;
$total_average_of_advances = $thematicManager->get_total_average_of_thematic_advances(); $last_done_thematic_advance = $thematicManager->get_last_done_thematic_advance($course, $session);
$total_average_of_advances = $thematicManager->get_total_average_of_thematic_advances($course, $session);
} }
// Second column // Second column
$thematic_plan_data = $thematicManager->get_thematic_plan_data(); //$thematic_plan_data = $thematicManager->get_thematic_plan_data();
// Third column // Third column
$thematic_advance_data = $thematicManager->get_thematic_advance_list(null, true); //$thematic_advance_data = $thematicManager->get_thematic_advance_list(null, true);
if (!empty($message) && !empty($total_average_of_advances)) { if (!empty($message) && !empty($total_average_of_advances)) {
$tpl->assign('message', $message); $tpl->assign('message', $message);
@ -550,6 +552,7 @@ switch ($action) {
$list = []; $list = [];
$listThematic = []; $listThematic = [];
$extra = [];
// Display thematic data // Display thematic data
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
/** @var CThematic $thematic */ /** @var CThematic $thematic */
@ -557,9 +560,9 @@ switch ($action) {
$id = $thematic->getIid(); $id = $thematic->getIid();
$session_star = ''; $session_star = '';
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
if (api_get_session_id() == $thematic->getSessionId()) { /*if (api_get_session_id() == $thematic->getSessionId()) {
$session_star = api_get_session_image(api_get_session_id(), $user_info['status']); $session_star = api_get_session_image(api_get_session_id(), $user_info['status']);
} }*/
} }
//@todo add a validation in order to load or not course thematics in the session thematic //@todo add a validation in order to load or not course thematics in the session thematic
@ -597,7 +600,8 @@ switch ($action) {
Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_TINY).'</div>'; Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_TINY).'</div>';
} }
} }
if (api_get_session_id() == $thematic->getSessionId()) { if (0) {
//if (api_get_session_id() == $thematic->getSessionId()) {
$toolbarThematic .= Display::url( $toolbarThematic .= Display::url(
Display::return_icon('pdf.png', get_lang('Export to PDF'), null, ICON_SIZE_TINY), Display::return_icon('pdf.png', get_lang('Export to PDF'), null, ICON_SIZE_TINY),
api_get_self().'?'.api_get_cidreq()."$url_token&".http_build_query( api_get_self().'?'.api_get_cidreq()."$url_token&".http_build_query(
@ -633,12 +637,13 @@ switch ($action) {
.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_TINY).'</a>'; .Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_TINY).'</a>';
} }
} }
$list['last_done'] = $last_done_thematic_advance; $extra[$thematic->getIid()]['toolbar'] = $toolbarThematic;
$list['toolbar'] = $toolbarThematic; $extra[$thematic->getIid()]['last_done'] = $last_done_thematic_advance;
$listThematic[] = $thematic; $listThematic[] = $thematic;
} }
} }
$tpl->assign('extra', $extra);
$tpl->assign('data', $listThematic); $tpl->assign('data', $listThematic);
$thematicLayout = $tpl->get_template('course_progress/progress.html.twig'); $thematicLayout = $tpl->get_template('course_progress/progress.html.twig');
$content = $tpl->fetch($thematicLayout); $content = $tpl->fetch($thematicLayout);
@ -828,18 +833,18 @@ switch ($action) {
</script> </script>
"; ";
$thematic_plan_data = $thematicManager->get_thematic_plan_data($thematicId); $thematic_plan_data = $thematicEntity->getPlans();
$description_type = isset($_GET['description_type']) ? (int) $_GET['description_type'] : null; $description_type = isset($_GET['description_type']) ? (int) $_GET['description_type'] : null;
if (!empty($thematicId) && !empty($description_type)) { if (!empty($thematicId) && !empty($description_type)) {
$thematic_plan_data = $thematicManager->get_thematic_plan_data($thematicId, $description_type); //$thematic_plan_data = $thematicManager->get_thematic_plan_data($thematicId, $description_type);
} elseif (!empty($thematicId) && 'thematic_plan_list' === $action) { } elseif (!empty($thematicId) && 'thematic_plan_list' === $action) {
$thematic_plan_data = $thematicManager->get_thematic_plan_data($thematicId); //$thematic_plan_data = $thematicManager->get_thematic_plan_data($thematicId);
} }
$default_thematic_plan_title = $thematicManager->get_default_thematic_plan_title(); $default_thematic_plan_title = $thematicManager->get_default_thematic_plan_title();
$default_thematic_plan_icon = $thematicManager->get_default_thematic_plan_icon(); $default_thematic_plan_icon = $thematicManager->get_default_thematic_plan_icon();
$next_description_type = $thematicManager->get_next_description_type($thematicId); //$next_description_type = $thematicManager->get_next_description_type($thematicId);
$default_thematic_plan_question = $thematicManager->get_default_question(); $default_thematic_plan_question = $thematicManager->get_default_question();
//$thematic_data = $thematicManager->get_thematic_list($thematicId); //$thematic_data = $thematicManager->get_thematic_list($thematicId);
//$tpl->assign('title_thematic', $thematic_data['title']); //$tpl->assign('title_thematic', $thematic_data['title']);
@ -851,7 +856,6 @@ switch ($action) {
// actions menu // actions menu
$new_thematic_plan_data = []; $new_thematic_plan_data = [];
if (!empty($thematic_plan_data)) { if (!empty($thematic_plan_data)) {
/** @var CThematicPlan $thematic_item */
foreach ($thematic_plan_data as $thematic_item) { foreach ($thematic_plan_data as $thematic_item) {
$thematic_simple_list[] = $thematic_item->getDescriptionType(); $thematic_simple_list[] = $thematic_item->getDescriptionType();
$new_thematic_plan_data[$thematic_item->getDescriptionType()] = $thematic_item; $new_thematic_plan_data[$thematic_item->getDescriptionType()] = $thematic_item;
@ -1009,12 +1013,12 @@ switch ($action) {
); );
$form->addGroup($radios, null, get_lang('Start date options')); $form->addGroup($radios, null, get_lang('Start date options'));
if (isset($thematic_advance_data['attendance_id']) && /*if (isset($thematic_advance_data['attendance_id']) &&
0 == $thematic_advance_data['attendance_id']) { 0 == $thematic_advance_data['attendance_id']) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">'); $form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
} else { } else {
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">'); $form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
} }*/
$form->addElement('DateTimePicker', 'custom_start_date', get_lang('Start Date')); $form->addElement('DateTimePicker', 'custom_start_date', get_lang('Start Date'));
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
@ -1157,10 +1161,10 @@ switch ($action) {
if ($affected_rows) { if ($affected_rows) {
// get last done thematic advance before move thematic list // get last done thematic advance before move thematic list
$last_done_thematic_advance = $thematicManager->get_last_done_thematic_advance(); $last_done_thematic_advance = $thematicManager->get_last_done_thematic_advance($course, $session);
// update done advances with de current thematic list // update done advances with de current thematic list
if (!empty($last_done_thematic_advance)) { if (!empty($last_done_thematic_advance)) {
$thematicManager->update_done_thematic_advances($last_done_thematic_advance); $thematicManager->updateDoneThematicAdvance($last_done_thematic_advance, $course, $session);
} }
} }

@ -10,6 +10,8 @@ api_protect_course_script(true);
$action = $_GET['a']; $action = $_GET['a'];
$thematic = new Thematic(); $thematic = new Thematic();
$course = api_get_course_entity();
$session = api_get_session_entity();
switch ($action) { switch ($action) {
case 'save_thematic_plan': case 'save_thematic_plan':
@ -90,7 +92,7 @@ switch ($action) {
if (!empty($attendance_id)) { if (!empty($attendance_id)) {
$attendance = new Attendance(); $attendance = new Attendance();
$thematic = new Thematic(); $thematic = new Thematic();
$thematic_list = $thematic->get_thematic_list(); $thematic_list = $thematic->getThematicList($course, $session);
$my_list = $thematic_list_temp = []; $my_list = $thematic_list_temp = [];
foreach ($thematic_list as $item) { foreach ($thematic_list as $item) {
@ -144,15 +146,12 @@ switch ($action) {
<?php <?php
break; break;
case 'update_done_thematic_advance': case 'update_done_thematic_advance':
$advanceId = (int) $_GET['thematic_advance_id']; $id = (int) $_GET['thematic_advance_id'];
$average = 0; $average = 0;
if (!empty($advanceId)) { if (!empty($id)) {
$thematic = new Thematic(); $thematic = new Thematic();
$thematic->update_done_thematic_advances($advanceId); $thematic->updateDoneThematicAdvance($id, $course, $session);
$average = $thematic->get_total_average_of_thematic_advances( $average = $thematic->get_total_average_of_thematic_advances($course, $session);
api_get_course_id(),
api_get_session_id()
);
} }
echo $average; echo $average;
break; break;

@ -4,6 +4,7 @@
use Chamilo\CourseBundle\Entity\CToolIntro; use Chamilo\CourseBundle\Entity\CToolIntro;
/** /**
* @deprecated
* The INTRODUCTION MICRO MODULE is used to insert and edit * The INTRODUCTION MICRO MODULE is used to insert and edit
* an introduction section on a Chamilo module or on the course homepage. * an introduction section on a Chamilo module or on the course homepage.
* It can be inserted on any Chamilo module, provided the corresponding setting * It can be inserted on any Chamilo module, provided the corresponding setting
@ -180,7 +181,7 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
$class1 = ''; $class1 = '';
if ('1' === $displayMode) { if ('1' === $displayMode) {
// Show only the current course progress step // Show only the current course progress step
$last_done_advance = $thematic->get_last_done_thematic_advance(); $last_done_advance = $thematic->get_last_done_thematic_advance($course, $session);
$thematicAdvance = $thematic->getThematicAdvance($last_done_advance); $thematicAdvance = $thematic->getThematicAdvance($last_done_advance);
$subTitle1 = get_lang('Current topic'); $subTitle1 = get_lang('Current topic');
$class1 = ' current'; $class1 = ' current';
@ -193,7 +194,7 @@ if (TOOL_COURSE_HOMEPAGE == $tool && !isset($_GET['intro_cmdEdit'])) {
$subTitle1 = $subTitle2 = get_lang('Next topic'); $subTitle1 = $subTitle2 = get_lang('Next topic');
} elseif ('3' === $displayMode) { } elseif ('3' === $displayMode) {
// Show the current and next course progress steps // Show the current and next course progress steps
$last_done_advance = $thematic->get_last_done_thematic_advance(); $last_done_advance = $thematic->get_last_done_thematic_advance($course, $session);
$next_advance_not_done = $thematic->get_next_thematic_advance_not_done(); $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
$thematicAdvance = $thematic->getThematicAdvance($last_done_advance); $thematicAdvance = $thematic->getThematicAdvance($last_done_advance);
$thematicAdvance2 = $thematic->getThematicAdvance($next_advance_not_done); $thematicAdvance2 = $thematic->getThematicAdvance($next_advance_not_done);

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAttendance; use Chamilo\CourseBundle\Entity\CAttendance;
use Chamilo\CourseBundle\Entity\CAttendanceCalendar; use Chamilo\CourseBundle\Entity\CAttendanceCalendar;
@ -24,25 +26,18 @@ class Attendance
/** /**
* Get attendance list only the id, name and attendance_qualify_max fields. * Get attendance list only the id, name and attendance_qualify_max fields.
* *
* @param int $courseId
* @param int $sessionId
*
* @return CAttendance[] * @return CAttendance[]
*/ */
public function get_attendances_list($courseId = 0, $sessionId = 0) public function getAttendanceList(Course $course, Session $session = null)
{ {
$repo = Container::getAttendanceRepository(); $repo = Container::getAttendanceRepository();
$course = api_get_course_entity($courseId);
$session = api_get_session_entity($sessionId);
$qb = $repo->getResourcesByCourse($course, $session, null); $qb = $repo->getResourcesByCourse($course, $session, null);
//$qb->select('resource'); //$qb->select('resource');
$qb->andWhere('resource.active = 1'); $qb->andWhere('resource.active = 1');
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
$table = Database::get_course_table(TABLE_ATTENDANCE); /*$table = Database::get_course_table(TABLE_ATTENDANCE);
$course_id = (int) $course_id; $course_id = (int) $course_id;
if (empty($course_id)) { if (empty($course_id)) {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -63,7 +58,7 @@ class Attendance
} }
} }
return $data; return $data;*/
} }
/** /**
@ -1096,7 +1091,7 @@ class Attendance
//$course_info = api_get_course_info($course_code); //$course_info = api_get_course_info($course_code);
$course_id = $course['real_id']; $course_id = $course['real_id'];
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$attendances = $this->get_attendances_list($course_id); $attendances = $this->getAttendanceList(api_get_course_entity($course_id));
foreach ($attendances as $attendance) { foreach ($attendances as $attendance) {
$attendanceId = $attendance->getIid(); $attendanceId = $attendance->getIid();
@ -1132,22 +1127,18 @@ class Attendance
/** /**
* Get results of faults average by course. * Get results of faults average by course.
* *
* @param int $user_id
* @param string $course_code
* @param int Session id (optional)
*
* @return array results containing number of faults, * @return array results containing number of faults,
* total done attendance, percent of faults and color depend on result (red, orange) * total done attendance, percent of faults and color depend on result (red, orange)
*/ */
public function get_faults_average_by_course($user_id, $course_code, $session_id = null) public function get_faults_average_by_course($user_id, Course $course, Session $session = null)
{ {
// Database tables and variables // Database tables and variables
$course_info = api_get_course_info($course_code); $courseId = $course->getId();
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$user_id = (int) $user_id; $user_id = (int) $user_id;
$results = []; $results = [];
$total_faults = $total_weight = $porcent = 0; $total_faults = $total_weight = 0;
$attendances = $this->get_attendances_list($course_info['real_id'], $session_id); $attendances = $this->getAttendanceList($course, $session);
foreach ($attendances as $attendance) { foreach ($attendances as $attendance) {
$attendanceId = $attendance->getIid(); $attendanceId = $attendance->getIid();
@ -1155,7 +1146,7 @@ class Attendance
$total_done_attendance = $attendance->getAttendanceQualifyMax(); $total_done_attendance = $attendance->getAttendanceQualifyMax();
$sql = "SELECT score FROM $tbl_attendance_result $sql = "SELECT score FROM $tbl_attendance_result
WHERE WHERE
c_id = {$course_info['real_id']} AND c_id = {$courseId} AND
user_id = $user_id AND user_id = $user_id AND
attendance_id=".$attendanceId; attendance_id=".$attendanceId;
$rs = Database::query($sql); $rs = Database::query($sql);
@ -2269,7 +2260,7 @@ class Attendance
$courseId = $courseItem['course_id']; $courseId = $courseItem['course_id'];
/* Get all attendance by courses*/ /* Get all attendance by courses*/
$attendanceList = $attendanceLib->get_attendances_list($courseId); $attendanceList = $attendanceLib->getAttendanceList(api_get_course_entity($courseId));
$temp = []; $temp = [];
$sheetsProcessed = []; $sheetsProcessed = [];
$tempDate = []; $tempDate = [];
@ -2352,10 +2343,9 @@ class Attendance
$courseId = $row['c_id']; $courseId = $row['c_id'];
$sessionId = $row['session_id']; $sessionId = $row['session_id'];
$courseItem = api_get_course_info_by_id($courseId); $courseItem = api_get_course_info_by_id($courseId);
$attendanceList = $attendanceLib->getAttendanceList(
$attendanceList = $attendanceLib->get_attendances_list( api_get_course_entity($courseId),
$courseId, api_get_session_entity($sessionId)
$sessionId
); );
$temp = []; $temp = [];
$sheetsProcessed = []; $sheetsProcessed = [];

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CThematic; use Chamilo\CourseBundle\Entity\CThematic;
use Chamilo\CourseBundle\Entity\CThematicAdvance; use Chamilo\CourseBundle\Entity\CThematicAdvance;
@ -32,9 +34,6 @@ class Thematic
private $duration; private $duration;
private $course_int_id; private $course_int_id;
/**
* Constructor.
*/
public function __construct() public function __construct()
{ {
$this->course_int_id = api_get_course_int_id(); $this->course_int_id = api_get_course_int_id();
@ -76,20 +75,16 @@ class Thematic
*/ */
public function get_thematic_data($from, $number_of_items, $column, $direction) public function get_thematic_data($from, $number_of_items, $column, $direction)
{ {
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC); $column = (int) $column;
$condition_session = ''; $from = (int) $from;
if (!api_get_session_id()) { $number_of_items = (int) $number_of_items;
$condition_session = api_get_session_condition(0);
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
if (!in_array($direction, ['ASC', 'DESC'])) { if (!in_array($direction, ['ASC', 'DESC'])) {
$direction = 'ASC'; $direction = 'ASC';
} }
/*
$course_id = api_get_course_int_id(); $course = api_get_course_entity();
$session = api_get_session_entity();
$sql = "SELECT id AS col0, title AS col1, display_order AS col2, session_id $sql = "SELECT id AS col0, title AS col1, display_order AS col2, session_id
FROM $tbl_thematic FROM $tbl_thematic
@ -158,7 +153,7 @@ class Thematic
} else { } else {
$actions .= Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL); $actions .= Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
} }
if ($thematic[2] < self::get_max_thematic_item()) { /*if ($thematic[2] < self::get_max_thematic_item()) {
$actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'. $actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'.
Display::return_icon('down.png', get_lang('down'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('down.png', get_lang('down'), '', ICON_SIZE_SMALL).'</a>';
} else { } else {
@ -171,22 +166,20 @@ class Thematic
} }
$thematics[] = [$thematic[0], $thematic[1], $actions]; $thematics[] = [$thematic[0], $thematic[1], $actions];
} }
} }*/
return $thematics; //return $thematics;
} }
/** /**
* Get the maximum display order of the thematic item. * Get the maximum display order of the thematic item.
* *
* @param bool $use_session
*
* @return int Maximum display order * @return int Maximum display order
*/ */
public function get_max_thematic_item($use_session = true) public function get_max_thematic_item(Course $course, Session $session = null)
{ {
// Database table definition // Database table definition
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC); /*$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$session_id = api_get_session_id(); $session_id = api_get_session_id();
if ($use_session) { if ($use_session) {
$condition_session = api_get_session_condition($session_id); $condition_session = api_get_session_condition($session_id);
@ -200,7 +193,7 @@ class Thematic
$rs = Database::query($sql); $rs = Database::query($sql);
$row = Database::fetch_array($rs); $row = Database::fetch_array($rs);
return $row[0]; return $row[0];*/
} }
/** /**
@ -209,13 +202,13 @@ class Thematic
* @param string $direction (up, down) * @param string $direction (up, down)
* @param int $thematic_id * @param int $thematic_id
*/ */
public function move_thematic($direction, $thematic_id) public function moveThematic($direction, $thematic_id, $course, $session = null)
{ {
// Database table definition // Database table definition
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC); $tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
// sort direction // sort direction
if ('up' == $direction) { if ('up' === $direction) {
$sortorder = 'DESC'; $sortorder = 'DESC';
} else { } else {
$sortorder = 'ASC'; $sortorder = 'ASC';
@ -248,7 +241,7 @@ class Thematic
} }
// get last done thematic advance before move thematic list // get last done thematic advance before move thematic list
$last_done_thematic_advance = $this->get_last_done_thematic_advance(); $last_done_thematic_advance = $this->get_last_done_thematic_advance($course, $session);
if (!empty($next_display_order) && !empty($current_id)) { if (!empty($next_display_order) && !empty($current_id)) {
$sql = "UPDATE $tbl_thematic SET display_order = $next_display_order $sql = "UPDATE $tbl_thematic SET display_order = $next_display_order
@ -263,21 +256,18 @@ class Thematic
} }
// update done advances with de current thematic list // update done advances with de current thematic list
$this->update_done_thematic_advances($last_done_thematic_advance); $this->updateDoneThematicAdvance($last_done_thematic_advance, $course, $session);
} }
/** /**
* Get thematic list. * Get thematic list.
* *
* @param string $course_code
* @param int $session_id
*
* @return array Thematic data * @return array Thematic data
*/ */
public static function get_thematic_list($course_code = null, $session_id = null) public static function getThematicList(Course $course, Session $session = null)
{ {
// set current course and session // set current course and session
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC); /*$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
@ -293,22 +283,26 @@ class Thematic
} else { } else {
$condition_session = api_get_session_condition($session_id, true, true); $condition_session = api_get_session_condition($session_id, true, true);
} }
$condition = " WHERE active = 1 $condition_session "; $condition = " WHERE active = 1 $condition_session ";*/
$repo = Container::getThematicRepository();
$qb = $repo->getResourcesByCourse($course, $session);
return $qb->getQuery()->getResult();
$sql = "SELECT * /*$sql = "SELECT *
FROM $tbl_thematic $condition AND c_id = $course_id FROM $tbl_thematic $condition AND c_id = $course_id
ORDER BY display_order "; ORDER BY display_order ";
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
$repo = Container::getThematicRepository();
while ($row = Database::fetch_array($res, 'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$entity = $repo->find($row['iid']); $entity = $repo->find($row['iid']);
$data[$row['iid']] = $entity; $data[$row['iid']] = $entity;
} }
} }
return $data; return $data;*/
} }
/** /**
@ -325,7 +319,7 @@ class Thematic
$session_id = intval($this->session_id); $session_id = intval($this->session_id);
// get the maximum display order of all the glossary items // get the maximum display order of all the glossary items
$max_thematic_item = $this->get_max_thematic_item(false); //$max_thematic_item = $this->get_max_thematic_item(false);
$repo = Container::getThematicRepository(); $repo = Container::getThematicRepository();
@ -336,9 +330,8 @@ class Thematic
->setTitle($title) ->setTitle($title)
->setContent($content) ->setContent($content)
->setActive(1) ->setActive(1)
->setCId($this->course_int_id) //->setDisplayOrder($max_thematic_item + 1)
->setDisplayOrder($max_thematic_item + 1) ->setDisplayOrder(0)
->setSessionId($session_id)
->setParent($courseEntity) ->setParent($courseEntity)
->addCourseLink($courseEntity, api_get_session_entity()) ->addCourseLink($courseEntity, api_get_session_entity())
; ;
@ -512,16 +505,15 @@ class Thematic
* *
* @see SortableTable#get_total_number_of_items() * @see SortableTable#get_total_number_of_items()
*/ */
public static function get_number_of_thematic_advances() public static function get_number_of_thematic_advances(array $params)
{ {
global $thematic_id;
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE); $table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$thematic_id = (int) $thematic_id; $thematic_id = (int) $params['thematic_id'];
$sql = "SELECT COUNT(id) AS total_number_of_items $sql = "SELECT COUNT(iid) AS total_number_of_items
FROM $table FROM $table
WHERE c_id = $course_id AND thematic_id = $thematic_id "; WHERE thematic_id = $thematic_id ";
$res = Database::query($sql); $res = Database::query($sql);
$obj = Database::fetch_object($res); $obj = Database::fetch_object($res);
@ -553,9 +545,9 @@ class Thematic
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$thematic_id = (int) $params['thematic_id']; $thematic_id = (int) $params['thematic_id'];
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$sql = "SELECT id AS col0, start_date AS col1, duration AS col2, content AS col3 $sql = "SELECT iid AS col0, start_date AS col1, duration AS col2, content AS col3
FROM $table FROM $table
WHERE c_id = $course_id AND thematic_id = $thematic_id WHERE thematic_id = $thematic_id
ORDER BY col$column $direction ORDER BY col$column $direction
LIMIT $from,$number_of_items "; LIMIT $from,$number_of_items ";
@ -687,7 +679,6 @@ class Thematic
if (null === $advance) { if (null === $advance) {
$advance = new CThematicAdvance(); $advance = new CThematicAdvance();
$advance $advance
->setCId($this->course_int_id)
->setContent($content) ->setContent($content)
->setThematic($thematic) ->setThematic($thematic)
->setAttendance($attendance) ->setAttendance($attendance)
@ -714,7 +705,6 @@ class Thematic
$last_id = $advance->getIid(); $last_id = $advance->getIid();
} else { } else {
$advance $advance
->setCId($this->course_int_id)
->setContent($content) ->setContent($content)
->setStartDate(api_get_utc_datetime($start_date, true, true)) ->setStartDate(api_get_utc_datetime($start_date, true, true))
->setDuration($duration) ->setDuration($duration)
@ -922,9 +912,7 @@ class Thematic
}*/ }*/
$repo = Container::getThematicPlanRepository(); $repo = Container::getThematicPlanRepository();
$criteria = [ $criteria = [
'cId' => $course_id,
'thematic' => $thematic_id, 'thematic' => $thematic_id,
'descriptionType' => $description_type, 'descriptionType' => $description_type,
]; ];
@ -967,12 +955,10 @@ class Thematic
);*/ );*/
} else { } else {
$thematic = Container::getThematicRepository()->find($thematic_id); $thematic = Container::getThematicRepository()->find($thematic_id);
$course = api_get_course_entity();
$plan = new CThematicPlan(); $plan = new CThematicPlan();
$plan $plan
->setTitle($title) ->setTitle($title)
->setDescription($description) ->setDescription($description)
->setCId($this->course_int_id)
->setThematic($thematic) ->setThematic($thematic)
->setDescriptionType($description_type) ->setDescriptionType($description_type)
//->setParent($course) //->setParent($course)
@ -1097,11 +1083,11 @@ class Thematic
* *
* @return int Affected rows * @return int Affected rows
*/ */
public function update_done_thematic_advances($advanceId) public function updateDoneThematicAdvance($advanceId, $course, $session = null)
{ {
$repo = Container::getThematicRepository(); $repo = Container::getThematicRepository();
$em = Database::getManager(); $em = Database::getManager();
$list = self::get_thematic_list(api_get_course_id()); $list = self::getThematicList($course, $session);
$ordered = []; $ordered = [];
foreach ($list as $thematic) { foreach ($list as $thematic) {
@ -1132,12 +1118,12 @@ class Thematic
return true; return true;
$_course = api_get_course_info(); /*$_course = api_get_course_info();
$thematic_data = self::get_thematic_list(api_get_course_id()); $thematic_data = self::getThematicList(api_get_course_id());
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE); $table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$affected_rows = 0; $affected_rows = 0;
$user_id = api_get_user_id(); $user_id = api_get_user_id();*/
/*$all = []; /*$all = [];
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
@ -1243,9 +1229,9 @@ class Thematic
* *
* @return int Last done thematic advance id * @return int Last done thematic advance id
*/ */
public function get_last_done_thematic_advance() public function get_last_done_thematic_advance($course, $session = null)
{ {
$thematic_data = self::get_thematic_list(); $thematic_data = self::getThematicList($course, $session);
$a_thematic_advance_ids = []; $a_thematic_advance_ids = [];
$last_done_advance_id = 0; $last_done_advance_id = 0;
@ -1277,9 +1263,9 @@ class Thematic
* *
* @return int next thematic advance not done * @return int next thematic advance not done
*/ */
public function get_next_thematic_advance_not_done($offset = 1) public function get_next_thematic_advance_not_done($offset = 1, $course, $session = null)
{ {
$thematic_data = self::get_thematic_list(); $thematic_data = self::getThematicList($course, $session);
$thematic_advance_data = $this->get_thematic_advance_list(); $thematic_advance_data = $this->get_thematic_advance_list();
$a_thematic_advance_ids = []; $a_thematic_advance_ids = [];
$next_advance_not_done = 0; $next_advance_not_done = 0;
@ -1308,40 +1294,29 @@ class Thematic
/** /**
* Get total average of thematic advances. * Get total average of thematic advances.
* *
* @param string $course_code (optional)
* @param int $session_id (optional)
*
* @return float Average of thematic advances * @return float Average of thematic advances
*/ */
public function get_total_average_of_thematic_advances($course_code = null, $session_id = null) public function get_total_average_of_thematic_advances(Course $course, Session $session = null)
{ {
if (empty($course_code)) { $thematic_data = self::getThematicList($course, $session);
$course_code = api_get_course_id();
}
if (api_get_session_id()) {
$thematic_data = self::get_thematic_list($course_code);
} else {
$thematic_data = self::get_thematic_list($course_code, 0);
}
$a_average_of_advances_by_thematic = []; $list = [];
$total_average = 0; $total_average = 0;
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
/** @var CThematic $thematic */ /** @var CThematic $thematic */
foreach ($thematic_data as $thematic) { foreach ($thematic_data as $thematic) {
$thematic_id = $thematic->getIid(); $thematic_id = $thematic->getIid();
$a_average_of_advances_by_thematic[$thematic_id] = $this->get_average_of_advances_by_thematic( $list[$thematic_id] = $this->get_average_of_advances_by_thematic(
$thematic, $thematic
$course_code
); );
} }
} }
// calculate total average // calculate total average
if (!empty($a_average_of_advances_by_thematic)) { if (!empty($list)) {
$count_tematics = count($thematic_data); $count = count($thematic_data);
$score = array_sum($a_average_of_advances_by_thematic); $score = array_sum($list);
$total_average = round(($score * 100) / ($count_tematics * 100)); $total_average = round(($score * 100) / ($count * 100));
} }
return $total_average; return $total_average;
@ -1351,11 +1326,10 @@ class Thematic
* Get average of advances by thematic. * Get average of advances by thematic.
* *
* @param CThematic $thematic * @param CThematic $thematic
* @param string $course_code
* *
* @return float Average of thematic advances * @return float Average of thematic advances
*/ */
public function get_average_of_advances_by_thematic($thematic, $course_code = null) public function get_average_of_advances_by_thematic($thematic)
{ {
$advances = $thematic->getAdvances(); $advances = $thematic->getAdvances();
$average = 0; $average = 0;

@ -272,9 +272,12 @@ function get_courses($from, $limit, $column, $direction)
$courseList = []; $courseList = [];
if (!empty($courses)) { if (!empty($courses)) {
$session = api_get_session_entity($sessionId);
foreach ($courses as $data) { foreach ($courses as $data) {
$courseCode = $data['code']; $courseCode = $data['code'];
$courseInfo = api_get_course_info($courseCode); $courseInfo = api_get_course_info($courseCode);
$course = api_get_course_entity($courseCode['real_id']);
if (empty($sessionId)) { if (empty($sessionId)) {
$userList = CourseManager::get_user_list_from_course_code($data['code']); $userList = CourseManager::get_user_list_from_course_code($data['code']);
} else { } else {
@ -318,7 +321,7 @@ function get_courses($from, $limit, $column, $direction)
} }
$thematic = new Thematic(); $thematic = new Thematic();
$tematic_advance = $thematic->get_total_average_of_thematic_advances($courseCode, $sessionId); $tematic_advance = $thematic->get_total_average_of_thematic_advances($course, $session);
$tematicAdvanceProgress = '-'; $tematicAdvanceProgress = '-';
if (!empty($tematic_advance)) { if (!empty($tematic_advance)) {
$tematicAdvanceProgress = '<a title="'.get_lang('Go to thematic advance').'" href="'.api_get_path(WEB_CODE_PATH).'course_progress/index.php?cidReq='.$courseCode.'&id_session='.$sessionId.'">'. $tematicAdvanceProgress = '<a title="'.get_lang('Go to thematic advance').'" href="'.api_get_path(WEB_CODE_PATH).'course_progress/index.php?cidReq='.$courseCode.'&id_session='.$sessionId.'">'.

@ -1278,8 +1278,8 @@ if (empty($details)) {
// get average of faults in attendances by student // get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course( $results_faults_avg = $attendance->get_faults_average_by_course(
$studentId, $studentId,
$courseCodeItem, api_get_course_entity($courseId),
$sId api_get_session_entity($sId)
); );
$attendances_faults_avg = '0/0 (0%)'; $attendances_faults_avg = '0/0 (0%)';

@ -78,7 +78,7 @@
{% endif %} {% endif %}
{{ item.content }} {{ item.content }}
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
{{ item.toolbar }} {{ extra[item.iid]['toolbar'] }}
</div> </div>
</td> </td>
<td> <td>
@ -123,22 +123,22 @@
<td style="width: 90%" <td style="width: 90%"
class="thematic_advance_content" class="thematic_advance_content"
id="thematic_advance_content_id_{{ advance.iid }}"> id="thematic_advance_content_id_{{ advance.iid }}">
<div id="thematic_advance_{{ advance.id }}"> <div id="thematic_advance_{{ advance.iid }}">
<strong>{{ advance.startDate | format_date }}</strong> <strong>{{ advance.startDate | format_date }}</strong>
{{ advance.content }} {{ advance.content }}
</div> </div>
{% if tutor %} {% if tutor %}
<div class="toolbar-actions"> <div class="toolbar-actions">
<div id="thematic_advance_tools_{{ advance.id }}" class="thematic_advance_actions"> <div id="thematic_advance_tools_{{ advance.iid }}" class="thematic_advance_actions">
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<a class="btn btn-default btn-sm" <a class="btn btn-default btn-sm"
href="index.php?{{ course_url_params }}&action=thematic_advance_edit&thematic_id={{ item.iid }}&thematic_advance_id={{ advance.id }}" href="index.php?{{ course_url_params }}&action=thematic_advance_edit&thematic_id={{ item.iid }}&thematic_advance_id={{ advance.iid }}"
title="{{ 'Edit' |trans }}"> title="{{ 'Edit' |trans }}">
<i class="fa fa-pen" aria-hidden="true"></i> <i class="fa fa-pen" aria-hidden="true"></i>
</a> </a>
<a class="btn btn-default btn-sm" <a class="btn btn-default btn-sm"
onclick="javascript:if(!confirm('{{ 'Are you sure to delete' | trans }}')) return false;" onclick="javascript:if(!confirm('{{ 'Are you sure to delete' | trans }}')) return false;"
href="index.php?{{ course_url_params }}&action=thematic_advance_delete&thematic_id={{ item.iid }}&thematic_advance_id={{ advance.id }}" href="index.php?{{ course_url_params }}&action=thematic_advance_delete&thematic_id={{ item.iid }}&thematic_advance_id={{ advance.iid }}"
title="{{ 'Delete' |trans }}"> title="{{ 'Delete' |trans }}">
<i class="fa fa-trash" aria-hidden="true"></i> <i class="fa fa-trash" aria-hidden="true"></i>
</a> </a>
@ -148,7 +148,7 @@
{% endif %} {% endif %}
</div> </div>
</td> </td>
{% if advance.done_advance == 1 %} {% if advance.doneAdvance == 1 %}
{% set color = "background-color:#E5EDF9;" %} {% set color = "background-color:#E5EDF9;" %}
{% else %} {% else %}
{% set color = "background-color:#FFFFFF;" %} {% set color = "background-color:#FFFFFF;" %}
@ -156,17 +156,17 @@
{% if tutor %} {% if tutor %}
<td <td
style="width: 10%; {{ color }}" style="width: 10%; {{ color }}"
id="td_done_thematic_{{ advance.id }}"> id="td_done_thematic_{{ advance.iid }}">
{% set check = "" %} {% set check = "" %}
{% if item.last_done == advance.id %} {% if extra[item.iid]['last_done'] == advance.iid %}
{% set check = "checked" %} {% set check = "checked" %}
{% endif %} {% endif %}
<input <input
type="radio" type="radio"
class="done_thematic" class="done_thematic"
id="done_thematic_{{ advance.id }}" id="done_thematic_{{ advance.iid }}"
name="done_thematic" name="done_thematic"
value="{{ advance.id }}" {{ check }} value="{{ advance.iid }}" {{ check }}
onclick="updateDoneThematicAdvance(this.value);" onclick="updateDoneThematicAdvance(this.value);"
/> />
{% else %} {% else %}

@ -146,6 +146,7 @@ class BlockCourse extends Block
$course_code = $row_course['code']; $course_code = $row_course['code'];
$courseInfo = api_get_course_info($course_code); $courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id']; $courseId = $courseInfo['real_id'];
$course = api_get_course_entity($courseId);
$nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0; $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
// students directly subscribed to the course // students directly subscribed to the course
@ -165,8 +166,8 @@ class BlockCourse extends Block
$avg_time_spent_in_course = null; $avg_time_spent_in_course = null;
} }
$tematic_advance = $thematic->get_total_average_of_thematic_advances( $tematic_advance = $thematic->get_total_average_of_thematic_advances(
$course_code, $course,
0 null
); );
if (!empty($tematic_advance)) { if (!empty($tematic_advance)) {

@ -165,10 +165,6 @@ services:
- -
thematics: thematics:
repository: Chamilo\CourseBundle\Repository\CThematicRepository repository: Chamilo\CourseBundle\Repository\CThematicRepository
thematic_advance:
repository: Chamilo\CourseBundle\Repository\CThematicAdvanceRepository
thematic_plans:
repository: Chamilo\CourseBundle\Repository\CThematicPlanRepository
tags: tags:
- {name: chamilo_core.tool} - {name: chamilo_core.tool}

@ -16,8 +16,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table( * @ORM\Table(
* name="c_thematic", * name="c_thematic",
* indexes={ * indexes={
* @ORM\Index(name="course", columns={"c_id"}), * @ORM\Index(name="active", columns={"active"})
* @ORM\Index(name="active", columns={"active", "session_id"})
* } * }
* ) * )
* @ORM\Entity * @ORM\Entity
@ -33,13 +32,6 @@ class CThematic extends AbstractResource implements ResourceInterface
*/ */
protected $iid; protected $iid;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
*/
protected $cId;
/** /**
* @Assert\NotBlank() * @Assert\NotBlank()
* *
@ -66,13 +58,6 @@ class CThematic extends AbstractResource implements ResourceInterface
*/ */
protected $active; protected $active;
/**
* @var int
*
* @ORM\Column(name="session_id", type="integer", nullable=false)
*/
protected $sessionId;
/** /**
* @var CThematicPlan[] * @var CThematicPlan[]
* *
@ -188,59 +173,11 @@ class CThematic extends AbstractResource implements ResourceInterface
return $this->active; return $this->active;
} }
/**
* Set sessionId.
*
* @param int $sessionId
*
* @return CThematic
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId.
*
* @return int
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* Set cId.
*
* @param int $cId
*
* @return CThematic
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
public function getIid(): int public function getIid(): int
{ {
return $this->iid; return $this->iid;
} }
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
/** /**
* @return CThematicPlan[]|ArrayCollection * @return CThematicPlan[]|ArrayCollection
*/ */

@ -15,8 +15,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table( * @ORM\Table(
* name="c_thematic_advance", * name="c_thematic_advance",
* indexes={ * indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="thematic_id", columns={"thematic_id"})
* } * }
* ) * )
* @ORM\Entity * @ORM\Entity
@ -32,13 +30,6 @@ class CThematicAdvance //extends AbstractResource implements ResourceInterface
*/ */
protected $iid; protected $iid;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
*/
protected $cId;
/** /**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CThematic") * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CThematic")
* @ORM\JoinColumn(name="thematic_id", referencedColumnName="iid") * @ORM\JoinColumn(name="thematic_id", referencedColumnName="iid")
@ -192,30 +183,6 @@ class CThematicAdvance //extends AbstractResource implements ResourceInterface
return $this->doneAdvance; return $this->doneAdvance;
} }
/**
* Set cId.
*
* @param int $cId
*
* @return CThematicAdvance
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
/** /**
* @return Room * @return Room
*/ */

@ -15,7 +15,6 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table( * @ORM\Table(
* name="c_thematic_plan", * name="c_thematic_plan",
* indexes={ * indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="thematic_id", columns={"thematic_id", "description_type"}) * @ORM\Index(name="thematic_id", columns={"thematic_id", "description_type"})
* } * }
* ) * )
@ -39,13 +38,6 @@ class CThematicPlan //extends AbstractResource implements ResourceInterface
*/ */
protected string $title; protected string $title;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
*/
protected $cId;
/** /**
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CThematic", inversedBy="plans") * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CThematic", inversedBy="plans")
* @ORM\JoinColumn(name="thematic_id", referencedColumnName="iid") * @ORM\JoinColumn(name="thematic_id", referencedColumnName="iid")
@ -58,49 +50,21 @@ class CThematicPlan //extends AbstractResource implements ResourceInterface
protected ?string $description; protected ?string $description;
/** /**
* @var int
*
* @ORM\Column(name="description_type", type="integer", nullable=false) * @ORM\Column(name="description_type", type="integer", nullable=false)
*/ */
protected $descriptionType; protected int $descriptionType;
public function __toString(): string public function __toString(): string
{ {
return (string) $this->getIid(); return (string) $this->getIid();
} }
/**
* Set thematicId.
*
* @param int $thematicId
*
* @return CThematicPlan
*/
public function setThematicId($thematicId)
{
$this->thematicId = $thematicId;
return $this;
}
/**
* Get thematicId.
*
* @return int
*/
public function getThematicId()
{
return $this->thematicId;
}
/** /**
* Set title. * Set title.
* *
* @param string $title * @param string $title
*
* @return CThematicPlan
*/ */
public function setTitle($title) public function setTitle($title): self
{ {
$this->title = $title; $this->title = $title;
@ -119,12 +83,8 @@ class CThematicPlan //extends AbstractResource implements ResourceInterface
/** /**
* Set description. * Set description.
*
* @param string $description
*
* @return CThematicPlan
*/ */
public function setDescription($description) public function setDescription(?string $description): self
{ {
$this->description = $description; $this->description = $description;
@ -133,22 +93,16 @@ class CThematicPlan //extends AbstractResource implements ResourceInterface
/** /**
* Get description. * Get description.
*
* @return string
*/ */
public function getDescription() public function getDescription(): ?string
{ {
return $this->description; return $this->description;
} }
/** /**
* Set descriptionType. * Set descriptionType.
*
* @param int $descriptionType
*
* @return CThematicPlan
*/ */
public function setDescriptionType($descriptionType) public function setDescriptionType(int $descriptionType): self
{ {
$this->descriptionType = $descriptionType; $this->descriptionType = $descriptionType;
@ -157,38 +111,12 @@ class CThematicPlan //extends AbstractResource implements ResourceInterface
/** /**
* Get descriptionType. * Get descriptionType.
*
* @return int
*/ */
public function getDescriptionType() public function getDescriptionType(): int
{ {
return $this->descriptionType; return $this->descriptionType;
} }
/**
* Set cId.
*
* @param int $cId
*
* @return CThematicPlan
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
public function getIid(): int public function getIid(): int
{ {
return $this->iid; return $this->iid;

@ -8,21 +8,61 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceNode; use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\ResourceRepository; use Chamilo\CoreBundle\Repository\ResourceNodeRepository;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CourseBundle\Entity\CThematicPlan; use Chamilo\CourseBundle\Entity\CThematicPlan;
use Cocur\Slugify\SlugifyInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class CThematicPlanRepository extends ResourceRepository final class CThematicPlanRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)
{ {
parent::__construct($registry, CThematicPlan::class); parent::__construct($registry, CThematicPlan::class);
} }
public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroup $group = null): QueryBuilder public function setAuthorizationChecker(AuthorizationCheckerInterface $authorizationChecker): self
{ {
return $this->getResourcesByCourse($course, $session, $group, $parentNode); $this->authorizationChecker = $authorizationChecker;
return $this;
}
public function setRouter(RouterInterface $router): self
{
$this->router = $router;
return $this;
} }
public function setSlugify(SlugifyInterface $slugify): self
{
$this->slugify = $slugify;
return $this;
}
public function setToolChain(ToolChain $toolChain): self
{
$this->toolChain = $toolChain;
return $this;
}
public function setResourceNodeRepository(ResourceNodeRepository $resourceNodeRepository): self
{
$this->resourceNodeRepository = $resourceNodeRepository;
return $this;
}
/*public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroup $group = null): QueryBuilder
{
return $this->getResourcesByCourse($course, $session, $group, $parentNode);
}*/
} }

Loading…
Cancel
Save