CThematic + CAttendance - Use entities

pull/3844/head
Julio Montoya 4 years ago
parent 221dc304be
commit 98d4d73567
  1. 40
      public/main/attendance/index.php
  2. 25
      public/main/course_progress/index.php
  3. 20
      public/main/inc/ajax/thematic.ajax.php
  4. 272
      public/main/inc/lib/attendance.lib.php
  5. 110
      public/main/inc/lib/thematic.lib.php
  6. 4
      src/CoreBundle/Repository/Node/UserRepository.php
  7. 15
      src/CourseBundle/Entity/CAnnouncementAttachment.php
  8. 38
      src/CourseBundle/Entity/CAttendance.php
  9. 36
      src/CourseBundle/Entity/CAttendanceCalendar.php
  10. 85
      src/CourseBundle/Entity/CAttendanceCalendarRelGroup.php
  11. 96
      src/CourseBundle/Entity/CAttendanceResult.php
  12. 88
      src/CourseBundle/Entity/CAttendanceSheet.php
  13. 55
      src/CourseBundle/Repository/CThematicAdvanceRepository.php

@ -405,38 +405,7 @@ switch ($action) {
if ('attendance_sheet_list_no_edit' === $action) {
$edit = false;
}
$groupId = isset($_REQUEST['group_id']) ? $_REQUEST['group_id'] : null;
$users_in_course = $attendance->get_users_rel_course($attendanceId, $groupId);
$filter_type = 'today';
if (!empty($_REQUEST['filter'])) {
$filter_type = $_REQUEST['filter'];
}
if ('POST' === strtoupper($_SERVER['REQUEST_METHOD'])) {
$my_calendar_id = null;
if (is_numeric($filter_type)) {
$my_calendar_id = $filter_type;
$filter_type = 'calendar_id';
}
$attendant_calendar = $attendance->get_attendance_calendar(
$attendanceId,
$filter_type,
$my_calendar_id,
$groupId
);
$attendant_calendar_all = $attendance->get_attendance_calendar(
$attendanceId,
'all',
null,
$groupId
);
$users_presence = $attendance->get_users_attendance_sheet($attendanceId, 0, $groupId);
$next_attendance_calendar_id = $attendance->get_next_attendance_calendar_id($attendanceId);
$next_attendance_calendar_datetime = $attendance->getNextAttendanceCalendarDatetime($attendanceId);
}
$content = $attendance->getCalendarSheet($edit, $attendanceId, $student_id);
$content = $attendance->getCalendarSheet($edit, $attendanceEntity, $student_id);
$tpl->assign('table', $content);
$content = $tpl->fetch('@ChamiloCore/Attendance/sheet.html.twig');
break;
@ -462,7 +431,7 @@ switch ($action) {
$attendance->attendance_sheet_add(
$cal_id,
$users_present,
$attendanceId
$attendanceEntity
);
}
}
@ -650,8 +619,7 @@ switch ($action) {
api_not_allowed(true);
}
$attendance->attendance_calendar_delete(0, $attendanceId, true);
$attendance->attendance_calendar_delete(0, $attendanceEntity, true);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.$currentUrl.'&action=calendar_list&attendance_id='.$attendanceId);
@ -661,7 +629,7 @@ switch ($action) {
if (!$allowToEdit) {
api_not_allowed(true);
}
$attendance->attendance_calendar_delete($calendarId, $attendanceId);
$attendance->attendance_calendar_delete($calendarId, $attendanceEntity);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.$currentUrl.'&action=calendar_list&attendance_id='.$attendanceId);

@ -137,11 +137,9 @@ $interbreadcrumb[] = [
$actionLeft = '';
// instance thematic object for using like library here
$thematicManager = new Thematic();
$thematicEntity = null;
$repo = Container::getThematicRepository();
if (!empty($thematicId)) {
$repo = Container::getThematicRepository();
// thematic data by id
/** @var CThematic $thematicEntity */
$thematicEntity = $repo->find($thematicId);
}
@ -383,7 +381,6 @@ switch ($action) {
Export::arrayToCsv($csv);
exit;
break;
case 'export_documents':
case 'thematic_export_pdf':
$pdfOrientation = api_get_configuration_value('thematic_pdf_orientation');
@ -491,6 +488,7 @@ switch ($action) {
$tpl->assign('token', $url_token);
$tpl->assign('is_allowed_to_edit', $isTeacher);
$toolbar = null;
$last_done_thematic_advance = null;
if ($thematicEntity) {
$thematic_data[$thematicId] = $thematicEntity;
$data['total_average_of_advances'] = $thematicManager->get_average_of_advances_by_thematic($thematicId);
@ -600,8 +598,9 @@ switch ($action) {
Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_TINY).'</div>';
}
}
if (0) {
//if (api_get_session_id() == $thematic->getSessionId()) {
if (true) {
//if (api_get_session_id() == $thematic->getSessionId()) {
$toolbarThematic .= Display::url(
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(
@ -612,7 +611,7 @@ switch ($action) {
),
['class' => 'btn btn-default']
);
$toolbarThematic .= Display::url(
/*$toolbarThematic .= Display::url(
Display::return_icon(
'export_to_documents.png',
get_lang('Export latest version of this page to Documents'),
@ -623,7 +622,7 @@ switch ($action) {
['action' => 'export_single_documents', 'thematic_id' => $id]
),
['class' => 'btn btn-default']
);
);*/
$toolbarThematic .= '<a
class="btn btn-default"
href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$id.$params.$url_token.'">'
@ -927,7 +926,7 @@ switch ($action) {
}
$form->addGroup(
[
$form->addButton(
/*$form->addButton(
'add_item',
get_lang('Save and add new item'),
'plus',
@ -936,7 +935,7 @@ switch ($action) {
null,
[],
true
),
),*/
$form->addButtonSave(get_lang('Save'), 'submit', true),
]
);
@ -1191,7 +1190,11 @@ switch ($action) {
if (!empty($thematicAdvanceId)) {
if (api_is_allowed_to_edit(null, true)) {
$thematicManager->thematic_advance_destroy($thematicAdvanceId);
$repo = Container::getThematicAdvanceRepository();
$advance = $repo->find($thematicAdvanceId);
if ($advance) {
$repo->delete($advance);
}
}
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.$currentUrl);

@ -96,25 +96,31 @@ switch ($action) {
$my_list = $thematic_list_temp = [];
foreach ($thematic_list as $item) {
$my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
$thematic_list_temp = array_merge($my_list, $thematic_list_temp);
$thematic_list_temp[] = $item->getAdvances();
}
$new_thematic_list = [];
foreach ($thematic_list_temp as $item) {
if (!empty($item['attendance_id'])) {
foreach ($thematic_list_temp as $advanceList) {
foreach ($advanceList as $advance) {
$new_thematic_list[$advance->getIid()] = [
'attendance_id' => $advance->getAttendance()->getIid(),
'start_date' => $advance->getStartDate()->format('Y-m-d H:i:s'),
];
}
/*if (!empty($item['attendance_id'])) {
$new_thematic_list[$item['id']] = [
'attendance_id' => $item['attendance_id'],
'start_date' => $item['start_date'],
];
}
}*/
}
$attendance_calendar = $attendance->get_attendance_calendar($attendance_id);
$label = get_lang('Start Date');
if (!empty($attendance_calendar)) {
$input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" size="7" class="form-control">';
$input_select .= '<select
id="start_date_select_calendar"
name="start_date_by_attendance" size="7" class="form-control">';
foreach ($attendance_calendar as $calendar) {
$selected = null;
$insert = true;

@ -7,6 +7,7 @@ use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAttendance;
use Chamilo\CourseBundle\Entity\CAttendanceCalendar;
use Doctrine\Common\Collections\Criteria;
class Attendance
{
@ -249,7 +250,7 @@ class Attendance
}
// display lock/unlock icon
$is_done_all_calendar = self::is_all_attendance_calendar_done($id);
$is_done_all_calendar = self::is_all_attendance_calendar_done($attendance);
if ($is_done_all_calendar) {
$locked = $attendance->getLocked();
@ -268,7 +269,7 @@ class Attendance
$actions .= '&nbsp;<a
onclick="javascript:if(!confirm(\''.get_lang('Are you sure you want to unlock the attendance?').'\')) return false;"
href="index.php?'.api_get_cidreq().'&action=unlock_attendance&attendance_id='.$id.'">'.
Display::return_icon('locked.png', get_lang('Unlock attendance')).'</a>';
Display::return_icon('lock.png', get_lang('Unlock attendance')).'</a>';
} else {
$actions .= '&nbsp;'.Display::return_icon('locked_na.png', get_lang('Locked attendance'));
}
@ -755,17 +756,16 @@ class Attendance
*
* @param int $calendar_id attendance calendar id
* @param array $users_present present users during current class
* @param int $attendanceId
*
* @return int affected rows
*/
public function attendance_sheet_add($calendar_id, $users_present, $attendanceId)
public function attendance_sheet_add($calendar_id, $users_present, CAttendance $attendance)
{
$attendanceId = $attendance->getIid();
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$calendar_id = (int) $calendar_id;
$attendanceId = (int) $attendanceId;
$users = $this->get_users_rel_course();
$course_id = api_get_course_int_id();
@ -785,11 +785,10 @@ class Attendance
$uid = (int) $user_present;
// check if user already was registered with the $calendar_id
$sql = "SELECT user_id FROM $tbl_attendance_sheet
WHERE c_id = $course_id AND user_id='$uid' AND attendance_calendar_id = '$calendar_id'";
WHERE user_id = $uid AND attendance_calendar_id = $calendar_id";
$rs = Database::query($sql);
if (0 == Database::num_rows($rs)) {
$sql = "INSERT INTO $tbl_attendance_sheet SET
c_id = $course_id,
user_id = '$uid',
attendance_calendar_id = '$calendar_id',
presence = 1";
@ -797,11 +796,11 @@ class Attendance
$affected_rows += Database::affected_rows($result);
} else {
$sql = "UPDATE $tbl_attendance_sheet SET presence = 1
$sql = "UPDATE $tbl_attendance_sheet
SET presence = 1
WHERE
c_id = $course_id AND
user_id ='$uid' AND
attendance_calendar_id = '$calendar_id'
user_id = $uid AND
attendance_calendar_id = $calendar_id
";
$result = Database::query($sql);
$affected_rows += Database::affected_rows($result);
@ -813,11 +812,10 @@ class Attendance
$uid = (int) $user_absent;
// check if user already was registered with the $calendar_id
$sql = "SELECT user_id FROM $tbl_attendance_sheet
WHERE c_id = $course_id AND user_id='$uid' AND attendance_calendar_id = '$calendar_id'";
WHERE user_id = $uid AND attendance_calendar_id = '$calendar_id'";
$rs = Database::query($sql);
if (0 == Database::num_rows($rs)) {
$sql = "INSERT INTO $tbl_attendance_sheet SET
c_id = $course_id,
user_id ='$uid',
attendance_calendar_id = '$calendar_id',
presence = 0";
@ -826,7 +824,6 @@ class Attendance
} else {
$sql = "UPDATE $tbl_attendance_sheet SET presence = 0
WHERE
c_id = $course_id AND
user_id ='$uid' AND
attendance_calendar_id = '$calendar_id'";
$result = Database::query($sql);
@ -840,7 +837,7 @@ class Attendance
Database::query($sql);
// save users' results
$this->updateUsersResults($user_ids, $attendanceId);
$this->updateUsersResults($user_ids, $attendance);
if ($affected_rows) {
//save attendance sheet log
@ -860,15 +857,13 @@ class Attendance
* update users' attendance results.
*
* @param array $user_ids registered users inside current course
* @param int $attendanceId
*/
public function updateUsersResults($user_ids, $attendanceId)
public function updateUsersResults($user_ids, CAttendance $attendance)
{
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$course_id = api_get_course_int_id();
$attendanceId = (int) $attendanceId;
$attendanceId = $attendance->getIid();
// fill results about presence of students
$attendance_calendar = $this->get_attendance_calendar(
$attendanceId,
@ -892,8 +887,7 @@ class Attendance
$sql = "SELECT count(presence) as count_presences
FROM $tbl_attendance_sheet
WHERE
c_id = $course_id AND
user_id = '$uid' AND
user_id = $uid AND
attendance_calendar_id IN (".implode(',', $calendar_ids).') AND
presence = 1';
$rs_count = Database::query($sql);
@ -904,7 +898,6 @@ class Attendance
// save results
$sql = "SELECT iid FROM $tbl_attendance_result
WHERE
c_id = $course_id AND
user_id = '$uid' AND
attendance_id = '$attendanceId' ";
$rs_check_result = Database::query($sql);
@ -914,14 +907,12 @@ class Attendance
$sql = "UPDATE $tbl_attendance_result SET
score = '$count_presences'
WHERE
c_id = $course_id AND
user_id='$uid' AND
attendance_id='$attendanceId'";
Database::query($sql);
} else {
// insert new result
$sql = "INSERT INTO $tbl_attendance_result SET
c_id = $course_id ,
user_id = '$uid',
attendance_id = '$attendanceId',
score = '$count_presences'";
@ -932,7 +923,7 @@ class Attendance
}
// update attendance qualify max
$count_done_calendar = self::get_done_attendance_calendar($attendanceId);
$count_done_calendar = self::get_done_attendance_calendar($attendance);
$sql = "UPDATE $tbl_attendance SET
attendance_qualify_max = '$count_done_calendar'
WHERE iid = '$attendanceId'";
@ -988,13 +979,21 @@ class Attendance
/**
* Get number of done attendances inside current sheet.
*
* @param int attendance id
*
* @return int number of done attendances
*/
public static function get_done_attendance_calendar($attendanceId)
public static function get_done_attendance_calendar(CAttendance $attendance)
{
$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$criteria = Criteria::create()->where(
Criteria::expr()->eq('doneAttendance', 1)
);
if (!$attendance->getCalendars()) {
return 0;
}
return $attendance->getCalendars()->matching($criteria);
/*$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$attendanceId = (int) $attendanceId;
$course_id = api_get_course_int_id();
$sql = "SELECT count(done_attendance) as count
@ -1007,7 +1006,7 @@ class Attendance
$row = Database::fetch_array($rs);
$count = $row['count'];
return $count;
return $count;*/
}
/**
@ -1038,11 +1037,7 @@ class Attendance
true,
$user_id
);
$attendance_user_score = $this->get_user_score(
$user_id,
$attendanceId,
$groupId
);
$attendance_user_score = $this->get_user_score($user_id, $attendanceId, $groupId);
//This is the main change of the BT#1381
//$total_done_attendance = $calendar_count;
@ -1100,7 +1095,6 @@ class Attendance
$sql = "SELECT score
FROM $tbl_attendance_result
WHERE
c_id = $course_id AND
user_id = $user_id AND
attendance_id = ".$attendanceId;
$rs = Database::query($sql);
@ -1146,7 +1140,6 @@ class Attendance
$total_done_attendance = $attendance->getAttendanceQualifyMax();
$sql = "SELECT score FROM $tbl_attendance_result
WHERE
c_id = {$courseId} AND
user_id = $user_id AND
attendance_id=".$attendanceId;
$rs = Database::query($sql);
@ -1227,7 +1220,6 @@ class Attendance
$uid = (int) $uid;
$sql = "SELECT * FROM $tbl_attendance_sheet
WHERE
c_id = $course_id AND
user_id = '$uid' AND
attendance_calendar_id IN(".implode(',', $calendar_ids).')
';
@ -1248,8 +1240,7 @@ class Attendance
INNER JOIN $tbl_attendance_calendar cal
ON cal.iid = att.attendance_calendar_id
WHERE
att.c_id = $course_id AND
att.user_id = '$user_id' AND
att.user_id = $user_id AND
att.attendance_calendar_id IN (".implode(',', $calendar_ids).")
$whereDate
ORDER BY date_time";
@ -1346,22 +1337,19 @@ class Attendance
if (empty($groupId)) {
$sql = "SELECT score FROM $tbl_attendance_result
WHERE
c_id = $course_id AND
user_id='$user_id' AND
attendance_id='$attendanceId'";
} else {
$sql = "SELECT count(presence) as score
FROM $tbl_attendance_sheet
WHERE
c_id = $course_id AND
user_id='$user_id' AND
user_id = '$user_id' AND
presence = 1 AND
attendance_calendar_id IN (
SELECT calendar_id FROM $tbl_attendance_cal_rel_group crg
INNER JOIN $tbl_attendance_cal c
ON (crg.calendar_id = c.iid)
WHERE
crg.c_id = $course_id AND
crg.group_id = $groupId AND
c.attendance_id = $attendanceId
)
@ -1449,7 +1437,7 @@ class Attendance
attendance_id = '$attendanceId' AND
iid NOT IN (
SELECT calendar_id FROM $tbl_acrg
WHERE c_id = $course_id AND group_id != 0 AND group_id IS NOT NULL
WHERE attendance_id = '$attendanceId' AND group_id != 0 AND group_id IS NOT NULL
)
$whereDate
";
@ -1551,7 +1539,7 @@ class Attendance
iid NOT IN (
SELECT calendar_id FROM $calendarRelGroup
WHERE
c_id = $course_id AND
attendance_id = $attendanceId AND
group_id != 0 AND
group_id IS NOT NULL
)
@ -1577,7 +1565,6 @@ class Attendance
iid NOT IN (
SELECT calendar_id FROM $calendarRelGroup
WHERE
c_id = $course_id AND
group_id != 0 AND
group_id IS NOT NULL AND
group_id NOT IN (
@ -1634,19 +1621,21 @@ class Attendance
/**
* check if all calendar of an attendance is done.
*
* @param int $attendanceId
*
* @return bool True if all calendar is done, otherwise false
*/
public static function is_all_attendance_calendar_done($attendanceId)
public static function is_all_attendance_calendar_done(CAttendance $attendance)
{
$attendanceId = (int) $attendanceId;
$done_calendar = self::get_done_attendance_calendar($attendanceId);
$count_dates_in_calendar = self::get_count_dates_inside_attendance_calendar($attendanceId);
$number_of_dates = self::get_number_of_attendance_calendar($attendanceId);
$done_calendar = self::get_done_attendance_calendar($attendance);
//$count_dates_in_calendar = self::get_count_dates_inside_attendance_calendar($attendanceId);
$count_dates_in_calendar = 0;
if ($attendance->getCalendars()) {
$count_dates_in_calendar = $attendance->getCalendars()->count();
}
//$number_of_dates = self::get_number_of_attendance_calendar($attendanceId);
$result = false;
if ($number_of_dates && intval($count_dates_in_calendar) == intval($done_calendar)) {
if ($count_dates_in_calendar == $done_calendar) {
$result = true;
}
@ -1677,12 +1666,10 @@ class Attendance
*/
public function attendance_calendar_add($attendance, $groupList = [])
{
$attendanceId = $attendance->getIid();
$course_id = api_get_course_int_id();
$calendar = new CAttendanceCalendar();
$calendar
->setAttendanceId($attendanceId)
->setAttendance($attendance)
->setDateTime(new Datetime($this->date_time))
->setDoneAttendance(0);
@ -1693,7 +1680,7 @@ class Attendance
$this->addAttendanceCalendarToGroup($calendar->getIid(), $course_id, $groupList);
// update locked attendance
$is_all_calendar_done = $this->is_all_attendance_calendar_done($attendanceId);
$is_all_calendar_done = $this->is_all_attendance_calendar_done($attendance);
if (!$is_all_calendar_done) {
$this->lock($attendance, false);
} else {
@ -1731,7 +1718,6 @@ class Attendance
if (empty($result)) {
$params = [
'calendar_id' => $calendarId,
'c_id' => $courseId,
'group_id' => $groupId,
];
Database::insert($table, $params);
@ -1743,11 +1729,10 @@ class Attendance
/**
* @param int $calendarId
* @param int $courseId
*
* @return array
*/
public function getGroupListByAttendanceCalendar($calendarId, $courseId)
public function getGroupListByAttendanceCalendar($calendarId)
{
$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP);
@ -1756,7 +1741,7 @@ class Attendance
$table,
[
'where' => [
'calendar_id = ? AND c_id = ?' => [$calendarId, $courseId],
'calendar_id = ? ' => [$calendarId],
],
]
);
@ -1769,7 +1754,7 @@ class Attendance
*
* @return array
*/
public function getAttendanceCalendarGroup($calendarId, $courseId, $groupId)
public function getAttendanceCalendarGroup($calendarId, $groupId)
{
$table = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP);
@ -1778,7 +1763,7 @@ class Attendance
$table,
[
'where' => [
'calendar_id = ? AND c_id = ? AND group_id = ?' => [$calendarId, $courseId, $groupId],
'calendar_id = ? AND group_id = ?' => [$calendarId, $groupId],
],
]
);
@ -1794,7 +1779,7 @@ class Attendance
Database::delete(
$table,
[
'calendar_id = ? AND c_id = ?' => [$calendarId, $courseId],
'calendar_id = ?' => [$calendarId, $courseId],
]
);
}
@ -1882,7 +1867,7 @@ class Attendance
}
// update locked attendance
$is_all_calendar_done = self::is_all_attendance_calendar_done($attendanceId);
$is_all_calendar_done = self::is_all_attendance_calendar_done($attendance);
if (!$is_all_calendar_done) {
$this->lock($attendance, false);
} else {
@ -1895,21 +1880,18 @@ class Attendance
/**
* delete a datetime from attendance calendar table.
*
* @param int attendance calendar id
* @param int attendance id
* @param bool true for removing all calendar inside current attendance, false for removing by calendar id
* @param int attendance calendar id
* @param CAttendance attendance
* @param bool true for removing all calendar inside current attendance, false for removing by calendar id
*
* @return int affected rows
*/
public function attendance_calendar_delete(
$calendar_id,
$attendanceId,
$all_delete = false
) {
public function attendance_calendar_delete($calendar_id, CAttendance $attendance, $all_delete = false)
{
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
$attendanceId = (int) $attendanceId;
$attendanceId = $attendance->getIid();
$calendar_id = (int) $calendar_id;
// get all registered users inside current course
@ -1924,7 +1906,7 @@ class Attendance
foreach ($attendance_calendar as $cal) {
// delete all data from attendance sheet
$sql = "DELETE FROM $tbl_attendance_sheet
WHERE c_id = $course_id AND attendance_calendar_id = '".intval($cal['iid'])."'";
WHERE attendance_calendar_id = '".intval($cal['iid'])."'";
Database::query($sql);
// delete data from attendance calendar
$sql = "DELETE FROM $tbl_attendance_calendar
@ -1938,7 +1920,7 @@ class Attendance
} else {
// delete just one row from attendance sheet by the calendar id
$sql = "DELETE FROM $tbl_attendance_sheet
WHERE c_id = $course_id AND attendance_calendar_id = '".$calendar_id."'";
WHERE attendance_calendar_id = '".$calendar_id."'";
Database::query($sql);
// delete data from attendance calendar
$sql = "DELETE FROM $tbl_attendance_calendar
@ -1950,7 +1932,7 @@ class Attendance
}
// update users' results
$this->updateUsersResults($user_ids, $attendanceId);
$this->updateUsersResults($user_ids, $attendance);
return $affected_rows;
}
@ -2328,14 +2310,8 @@ class Attendance
/* Sessions */
$studentId = (int) $studentId;
$sql = "
SELECT
session_id,
c_id
FROM
session_rel_course_rel_user
WHERE
user_id = $studentId";
$sql = "SELECT session_id, c_id FROM session_rel_course_rel_user
WHERE user_id = $studentId";
$rs = Database::query($sql);
// get info from sessions
@ -2504,8 +2480,9 @@ class Attendance
return $form;
}
public function getCalendarSheet($edit, $attendanceId, $student_id)
public function getCalendarSheet($edit, CAttendance $attendance, $student_id)
{
$attendanceId = $attendance->getIid();
$content = '';
$groupId = isset($_REQUEST['group_id']) ? $_REQUEST['group_id'] : null;
$filter_type = 'today';
@ -2529,13 +2506,15 @@ class Attendance
$groupId
);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
$allowToEdit = api_is_allowed_to_edit(null, true);
$isDrhOfCourse = api_is_drh() || CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
) || api_is_drh();
if (true == $edit) {
if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) {
$data['users_presence'] = $this->get_users_attendance_sheet(
);
if ($edit) {
if ($isDrhOfCourse || $allowToEdit) {
$users_presence = $this->get_users_attendance_sheet(
$attendanceId,
0,
$groupId
@ -2548,34 +2527,24 @@ class Attendance
$user_id = api_get_user_id();
}
if (api_is_allowed_to_edit(null, true) ||
api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
$isDrhOfCourse
if ($isDrhOfCourse ||
$allowToEdit ||
api_is_coach(api_get_session_id(), api_get_course_int_id())
) {
$users_presence = $this->get_users_attendance_sheet(
$attendanceId,
0,
$groupId
);
$users_presence = $this->get_users_attendance_sheet($attendanceId, 0, $groupId);
} else {
$users_presence = $this->get_users_attendance_sheet(
$attendanceId,
$user_id,
$groupId
);
$users_presence = $this->get_users_attendance_sheet($attendanceId, $user_id, $groupId);
}
$faults = $this->get_faults_of_user($user_id, $attendanceId, $groupId);
}
$next_attendance_calendar_id = $this->get_next_attendance_calendar_id($attendanceId);
$next_attendance_calendar_datetime = $this->getNextAttendanceCalendarDatetime($attendanceId);
if (api_is_allowed_to_edit(null, true) ||
api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
$isDrhOfCourse
if ($isDrhOfCourse ||
$allowToEdit ||
api_is_coach(api_get_session_id(), api_get_course_int_id())
) {
$groupId = isset($_REQUEST['group_id']) ? (int) ($_REQUEST['group_id']) : null;
$form = new FormValidator(
'filter',
'post',
@ -2621,7 +2590,9 @@ class Attendance
if (!$exists_attendance_today) {
$content .= Display::return_message(
get_lang('There is no class scheduled today, try picking another day or add your attendance entry yourself using the action icons.'),
get_lang(
'There is no class scheduled today, try picking another day or add your attendance entry yourself using the action icons.'
),
'warning'
);
}
@ -2643,14 +2614,12 @@ class Attendance
$form->addSelect('group_id', get_lang('Group'), $groupIdList);
}
$default_filter = 'today';
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
$default_filter = $_REQUEST['filter'];
}
} else {
$default_filter = 'today';
}
$renderer = $form->defaultRenderer();
$renderer->setCustomElementTemplate(
'<div class="col-md-2">{label}</div><div class="col-md-10"> {element} </div>'
@ -2664,16 +2633,23 @@ class Attendance
);
if (!$is_locked_attendance || api_is_platform_admin()) {
$actionsLeft = '<a style="float:left;" href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendanceId.'">'.
Display::return_icon('attendance_calendar.png', get_lang('Attendance calendar'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a id="pdf_export" style="float:left;" href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendanceId.'&filter='.$default_filter.'&group_id='.$groupId.'">'.
$actionsLeft = '<a
style="float:left;"
href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendanceId.'">'.
Display::return_icon('attendance_calendar.png', get_lang('Attendance calendar'), '', ICON_SIZE_MEDIUM).
'</a>';
$actionsLeft .= '<a
id="pdf_export" style="float:left;"
href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendanceId.'&filter='.$default_filter.'&group_id='.$groupId.'">'.
Display::return_icon('pdf.png', get_lang('Export to PDF'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight = $form->returnForm();
$content .= Display::toolbarAction('toolbar-attendance', [$actionsLeft, $actionsRight]);
}
$message_information = get_lang('The attendance sheets allow you to specify a list of dates in which you will report attendance to your courses');
$message_information = get_lang(
'The attendance sheets allow you to specify a list of dates in which you will report attendance to your courses'
);
if (!empty($message_information)) {
$message = '<strong>'.get_lang('Information').'</strong><br />';
$message .= $message_information;
@ -2689,18 +2665,23 @@ class Attendance
if (count($users_in_course) > 0) {
$form = '
<form method="post" action="index.php?action=attendance_sheet_add&'.api_get_cidreq().$param_filter.'&attendance_id='.$attendanceId.'">
<div class="attendance-sheet-content" style="width:100%;background-color:#E1E1E1;margin-top:20px;">
<div class="divTableWithFloatingHeader attendance-users-table" style="width:45%;float:left;margin:0px;padding:0px;">
<div
class="attendance-sheet-content"
style="width:100%;background-color:#E1E1E1;margin-top:20px;">
<div
class="divTableWithFloatingHeader attendance-users-table"
style="width:45%;float:left;margin:0px;padding:0px;">
<table class="tableWithFloatingHeader data_table" width="100%">
<thead>
<tr class="tableFloatingHeader" style="position: absolute; top: 0px; left: 0px; visibility: hidden; margin:0px;padding:0px" >
<tr class="tableFloatingHeader"
style="position: absolute; top: 0px; left: 0px; visibility: hidden; margin:0px;padding:0px" >
<th width="10px">#</th>
<th width="10px">'.get_lang('Photo').'</th>
<th width="100px">'.get_lang('Last name').'</th>
<th width="100px">'.get_lang('First name').'</th>
<th width="100px">'.get_lang('Not attended').'</th>
</tr>
<tr class="tableFloatingHeaderOriginal" >
<tr class="tableFloatingHeaderOriginal">
<th width="10px">#</th>
<th width="10px">'.get_lang('Photo').'</th>
<th width="150px">'.get_lang('Last name').'</th>
@ -2709,15 +2690,12 @@ class Attendance
</tr>
</thead>
<tbody>';
$i = 1;
$class = '';
foreach ($users_in_course as $data) {
$faults = 0;
$class = 'row_even';
if (0 == $i % 2) {
$class = 'row_odd';
} else {
$class = 'row_even';
}
$username = api_htmlentities(
sprintf(get_lang('Login: %s'), $data['username']),
@ -2736,7 +2714,6 @@ class Attendance
</div>
</td>
</tr>';
$i++;
}
$form .= '</tbody>
@ -2749,7 +2726,6 @@ class Attendance
$form .= '<table class="tableWithFloatingHeader data_table" width="100%">';
$form .= '<thead>';
$result = null;
if (count($attendant_calendar) > 0) {
foreach ($attendant_calendar as $calendar) {
$calendarId = $calendar['iid'];
@ -2771,7 +2747,9 @@ class Attendance
type="hidden" id="hidden_input_'.$calendarId.'" name="hidden_input[]" value="" disabled />';
if ($next_attendance_calendar_id == $calendarId) {
$input_hidden = '<input
type="hidden" id="hidden_input_'.$calendarId.'" name="hidden_input[]" value="'.$calendarId.'" />';
type="hidden"
id="hidden_input_'.$calendarId.'" name="hidden_input[]"
value="'.$calendarId.'" />';
$disabled_check = '';
$img_lock = Display::return_icon(
'lock-closed.png',
@ -2782,14 +2760,20 @@ class Attendance
$result .= '<th>';
$result .= '<div class="date-attendance">'.$datetime.'&nbsp;';
if (api_is_allowed_to_edit(null, true)) {
$result .= '<span id="attendance_lock" style="cursor:pointer">'.(!$is_locked_attendance || api_is_platform_admin() ? $img_lock : '').'</span>';
if ($allowToEdit) {
$result .= '<span
id="attendance_lock"
style="cursor:pointer">'.
(!$is_locked_attendance || api_is_platform_admin() ? $img_lock : '').
'</span>';
}
if (false == $is_locked_attendance) {
if (api_is_allowed_to_edit(null, true)) {
if ($allowToEdit) {
$result .= '<input
type="checkbox" class="checkbox_head_'.$calendarId.'" id="checkbox_head_'.$calendarId.'" '.$disabled_check.' checked="checked" />'.
type="checkbox"
class="checkbox_head_'.$calendarId.'"
id="checkbox_head_'.$calendarId.'" '.$disabled_check.' checked="checked" />'.
$input_hidden.'</div></th>';
}
}
@ -2818,25 +2802,21 @@ class Attendance
$form .= '<tbody>';
$i = 0;
foreach ($users_in_course as $user) {
$class = '';
$class = 'row_odd';
if (0 == $i % 2) {
$class = 'row_even';
} else {
$class = 'row_odd';
}
$form .= '<tr class="'.$class.'">';
if (count($attendant_calendar) > 0) {
foreach ($attendant_calendar as $calendar) {
$checked = 'checked';
$presence = -1;
if (isset($users_presence[$user['user_id']][$calendar['iid']]['presence'])) {
$presence = $users_presence[$user['user_id']][$calendar['iid']]['presence'];
$checked = '';
if (1 == (int) $presence) {
$checked = 'checked';
} else {
$checked = '';
}
} else {
//if the user wasn't registered at that time, consider unchecked
@ -2848,7 +2828,6 @@ class Attendance
}
$disabled = 'disabled';
$style_td = '';
if ($next_attendance_calendar_id == $calendar['iid']) {
if (0 == $i % 2) {
$style_td = 'background-color:#eee;';
@ -2860,11 +2839,12 @@ class Attendance
$form .= '<td style="'.$style_td.'" class="checkboxes_col_'.$calendar['iid'].'">';
$form .= '<div class="check">';
if (api_is_allowed_to_edit(null, true)) {
if ($allowToEdit) {
if (!$is_locked_attendance || api_is_platform_admin()) {
$form .= '<input
type="checkbox" name="check_presence['.$calendar['iid'].'][]" value="'.$user['user_id'].'" '.$disabled.' '.$checked.' />';
type="checkbox"
name="check_presence['.$calendar['iid'].'][]"
value="'.$user['user_id'].'" '.$disabled.' '.$checked.' />';
$form .= '<span class="anchor_'.$calendar['iid'].'"></span>';
} else {
$form .= $presence ? Display::return_icon(
@ -2917,7 +2897,7 @@ class Attendance
$form .= '<div class="row">
<div class="col-md-12">';
if (!$is_locked_attendance || api_is_platform_admin()) {
if (api_is_allowed_to_edit(null, true)) {
if ($allowToEdit) {
$form .= '<button type="submit" class="btn btn-primary">'.get_lang('Save').'</button>';
}
}

@ -262,7 +262,7 @@ class Thematic
/**
* Get thematic list.
*
* @return array Thematic data
* @return CThematic[]
*/
public static function getThematicList(Course $course, Session $session = null)
{
@ -313,16 +313,13 @@ class Thematic
public function thematic_save()
{
// protect data
$id = intval($this->thematic_id);
$id = (int) $this->thematic_id;
$title = $this->thematic_title;
$content = $this->thematic_content;
$session_id = intval($this->session_id);
// get the maximum display order of all the glossary items
//$max_thematic_item = $this->get_max_thematic_item(false);
$repo = Container::getThematicRepository();
if (empty($id)) {
$thematic = new CThematic();
$courseEntity = api_get_course_entity();
@ -402,17 +399,13 @@ class Thematic
*/
public function delete($thematic_id)
{
$_course = api_get_course_info();
$tbl_thematic = Database::get_course_table(TABLE_THEMATIC);
$affected_rows = 0;
$user_id = api_get_user_id();
$course_id = api_get_course_int_id();
if (is_array($thematic_id)) {
foreach ($thematic_id as $id) {
$id = intval($id);
$id = (int) $id;
$sql = "UPDATE $tbl_thematic SET active = 0
WHERE c_id = $course_id AND id = $id";
WHERE iid = $id";
$result = Database::query($sql);
$affected_rows += Database::affected_rows($result);
if (!empty($affected_rows)) {
@ -427,9 +420,9 @@ class Thematic
}
}
} else {
$thematic_id = intval($thematic_id);
$thematic_id = (int) $thematic_id;
$sql = "UPDATE $tbl_thematic SET active = 0
WHERE c_id = $course_id AND id = $thematic_id";
WHERE iid = $thematic_id";
$result = Database::query($sql);
$affected_rows = Database::affected_rows($result);
if (!empty($affected_rows)) {
@ -508,7 +501,6 @@ class Thematic
public static function get_number_of_thematic_advances(array $params)
{
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$course_id = api_get_course_int_id();
$thematic_id = (int) $params['thematic_id'];
$sql = "SELECT COUNT(iid) AS total_number_of_items
@ -542,7 +534,6 @@ class Thematic
$direction = 'ASC';
}
$data = [];
$course_id = api_get_course_int_id();
$thematic_id = (int) $params['thematic_id'];
if (api_is_allowed_to_edit(null, true)) {
$sql = "SELECT iid AS col0, start_date AS col1, duration AS col2, content AS col3
@ -569,9 +560,12 @@ class Thematic
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
$thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG);
$actions = '';
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
$actions .= '<a
href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
$actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('Are you sure you want to delete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
$actions .= '<a
onclick="javascript:if(!confirm(\''.get_lang('Are you sure you want to delete').'\')) return false;"
href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a></center>';
$data[] = [$i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions];
$i++;
@ -582,31 +576,6 @@ class Thematic
return $data;
}
/**
* get thematic advance data by thematic id.
*
* @param int $thematic_id
* @param string $course_code Course code (optional)
*
* @return array data
*/
public function get_thematic_advance_by_thematic_id($thematic_id, $course_code = null)
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
$repo = Container::getThematicAdvanceRepository();
$courseEntity = api_get_course_entity($course_id);
$sessionEntity = api_get_session_entity(api_get_session_id());
$qb = $repo->getResourcesByCourse($courseEntity, $sessionEntity);
$qb->andWhere($qb->expr()->eq('resource.thematic', $thematic_id));
return $qb->getQuery()->getResult();
}
public function getThematicAdvance($id): ?CThematicAdvance
{
$repo = Container::getThematicAdvanceRepository();
@ -725,52 +694,6 @@ class Thematic
return $last_id;
}
/**
* delete thematic advance.
*
* @param int $id Thematic advance id
*
* @return int Affected rows
*/
public function thematic_advance_destroy($id)
{
$repo = Container::getThematicAdvanceRepository();
$advance = $repo->find($id);
if ($advance) {
$repo->delete($advance);
}
return true;
/*$_course = api_get_course_info();
$course_id = api_get_course_int_id();
// definition database table
$table = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
// protect data
$id = intval($id);
$user_id = api_get_user_id();
$sql = "DELETE FROM $table
WHERE c_id = $course_id AND id = $id ";
$result = Database::query($sql);
$affected_rows = Database::affected_rows($result);
if ($affected_rows) {
api_item_property_update(
$_course,
'thematic_advance',
$id,
'ThematicAdvanceDeleted',
$user_id
);
}
return $affected_rows;*/
}
/**
* get thematic plan data.
*
@ -1085,7 +1008,6 @@ class Thematic
*/
public function updateDoneThematicAdvance($advanceId, $course, $session = null)
{
$repo = Container::getThematicRepository();
$em = Database::getManager();
$list = self::getThematicList($course, $session);
$ordered = [];
@ -1106,12 +1028,12 @@ class Thematic
if ($advanceId === $advance->getIid()) {
$done = false;
$advance->setDoneAdvance(true);
$repo->update($advance, false);
$em->persist($advance);
continue;
}
$advance->setDoneAdvance($done);
$repo->update($advance, false);
$em->persist($advance);
}
$em->flush();
@ -1186,12 +1108,12 @@ class Thematic
$diff = array_diff($all, $a_thematic_advance_ids);
if (!empty($diff)) {
$upd = "UPDATE $table SET done_advance = 0
WHERE c_id = $course_id AND id IN(".implode(',', $diff).') ';
WHERE iid IN(".implode(',', $diff).') ';
Database::query($upd);
}
// update item_property
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
/*$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$sql = "SELECT ref FROM $tbl_item_property
WHERE
c_id = $course_id AND
@ -1218,7 +1140,7 @@ class Thematic
session_id = $sessionId ";
Database::query($sql);
}
}
}*/
}
return $affected_rows;

@ -1057,7 +1057,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
foreach ($result as $item) {
$list = [
'Presence: '.$item->getPresence(),
'Calendar id: '.$item->getAttendanceCalendarId(),
'Calendar id: '.$item->getAttendanceCalendar()->getIid(),
];
$cAttendanceSheetList[] = implode(', ', $list);
}
@ -1088,7 +1088,7 @@ class UserRepository extends ResourceRepository implements UserLoaderInterface,
foreach ($result as $item) {
$list = [
'Score : '.$item->getScore(),
'Calendar id: '.$item->getAttendanceId(),
'Calendar id: '.$item->getAttendance()->getIid(),
];
$cAttendanceResult[] = implode(', ', $list);
}

@ -33,11 +33,9 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
protected $path;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
protected $comment;
protected ?string $comment;
/**
* @var int
@ -47,12 +45,10 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
protected $size;
/**
* @var CAnnouncement
*
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CAnnouncement", cascade={"persist"})
* @ORM\JoinColumn(name="announcement_id", referencedColumnName="iid", onDelete="CASCADE" )
*/
protected $announcement;
protected CAnnouncement $announcement;
/**
* @var string
@ -70,10 +66,8 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
* Set path.
*
* @param string $path
*
* @return CAnnouncementAttachment
*/
public function setPath($path)
public function setPath($path): self
{
$this->path = $path;
@ -173,9 +167,6 @@ class CAnnouncementAttachment extends AbstractResource implements ResourceInterf
return $this;
}
/**
* Resource identifier.
*/
public function getResourceIdentifier(): int
{
return $this->getIid();

@ -6,6 +6,7 @@ namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\ResourceInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@ -54,14 +55,12 @@ class CAttendance extends AbstractResource implements ResourceInterface
*
* @ORM\Column(name="attendance_qualify_title", type="string", length=255, nullable=true)
*/
protected $attendanceQualifyTitle;
protected ?string $attendanceQualifyTitle;
/**
* @var int
*
* @ORM\Column(name="attendance_qualify_max", type="integer", nullable=false)
*/
protected $attendanceQualifyMax;
protected int $attendanceQualifyMax;
/**
* @var float
@ -71,11 +70,18 @@ class CAttendance extends AbstractResource implements ResourceInterface
protected $attendanceWeight;
/**
* @var int
*
* @ORM\Column(name="locked", type="integer", nullable=false)
*/
protected $locked;
protected int $locked;
/**
* @var CAttendanceCalendar[]
*
* @ORM\OneToMany(
* targetEntity="CAttendanceCalendar", mappedBy="attendance", cascade={"persist", "remove"}, orphanRemoval=true
* )
*/
protected $calendars;
public function __construct()
{
@ -83,6 +89,7 @@ class CAttendance extends AbstractResource implements ResourceInterface
$this->active = 1;
$this->attendanceQualifyMax = 0;
$this->locked = 0;
$this->calendars = new ArrayCollection();
}
public function __toString(): string
@ -240,8 +247,23 @@ class CAttendance extends AbstractResource implements ResourceInterface
}
/**
* Resource identifier.
* @return CAttendanceCalendar[]|ArrayCollection
*/
public function getCalendars()
{
return $this->calendars;
}
/**
* @param CAttendanceCalendar[] $calendars
*/
public function setCalendars(array $calendars): self
{
$this->calendars = $calendars;
return $this;
}
public function getResourceIdentifier(): int
{
return $this->getIid();

@ -12,7 +12,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(
* name="c_attendance_calendar",
* indexes={
* @ORM\Index(name="attendance_id", columns={"attendance_id"}),
* @ORM\Index(name="done_attendance", columns={"done_attendance"})
* }
* )
@ -30,11 +29,10 @@ class CAttendanceCalendar
protected $iid;
/**
* @var int
*
* @ORM\Column(name="attendance_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CAttendance")
* @ORM\JoinColumn(name="attendance_id", referencedColumnName="iid")
*/
protected $attendanceId;
protected CAttendance $attendance;
/**
* @var \DateTime
@ -55,38 +53,24 @@ class CAttendanceCalendar
return $this->iid;
}
/**
* Set attendanceId.
*
* @param int $attendanceId
*
* @return CAttendanceCalendar
*/
public function setAttendanceId($attendanceId)
public function getAttendance(): CAttendance
{
$this->attendanceId = $attendanceId;
return $this;
return $this->attendance;
}
/**
* Get attendanceId.
*
* @return int
*/
public function getAttendanceId()
public function setAttendance(CAttendance $attendance): self
{
return $this->attendanceId;
$this->attendance = $attendance;
return $this;
}
/**
* Set dateTime.
*
* @param \DateTime $dateTime
*
* @return CAttendanceCalendar
*/
public function setDateTime($dateTime)
public function setDateTime($dateTime): self
{
$this->dateTime = $dateTime;

@ -12,8 +12,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(
* name="c_attendance_calendar_rel_group",
* indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="group", columns={"group_id"})
* }
* )
* @ORM\Entity
@ -30,95 +28,46 @@ class CAttendanceCalendarRelGroup
protected $iid;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
*/
protected $cId;
/**
* @var int
*
* @ORM\Column(name="group_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroup")
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid")
*/
protected $groupId;
protected CGroup $group;
/**
* @var int
*
* @ORM\Column(name="calendar_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CAttendanceCalendar")
* @ORM\JoinColumn(name="calendar_id", referencedColumnName="iid")
*/
protected $calendarId;
protected CAttendanceCalendar $attendanceCalendar;
/**
* Set cId.
*
* @param int $cId
*
* @return CAttendanceCalendarRelGroup
* @return int
*/
public function setCId($cId)
public function getIid()
{
$this->cId = $cId;
return $this;
return $this->iid;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
public function getGroup(): CGroup
{
return $this->cId;
return $this->group;
}
/**
* Set groupId.
*
* @param int $groupId
*
* @return CAttendanceCalendarRelGroup
*/
public function setGroupId($groupId)
public function setGroup(CGroup $group): self
{
$this->groupId = $groupId;
$this->group = $group;
return $this;
}
/**
* Get groupId.
*
* @return int
*/
public function getGroupId()
public function getAttendanceCalendar(): CAttendanceCalendar
{
return $this->groupId;
return $this->attendanceCalendar;
}
/**
* Set calendarId.
*
* @param int $calendarId
*
* @return CAttendanceCalendarRelGroup
*/
public function setCalendarId($calendarId)
public function setAttendanceCalendar(CAttendanceCalendar $attendanceCalendar): self
{
$this->calendarId = $calendarId;
$this->attendanceCalendar = $attendanceCalendar;
return $this;
}
/**
* Get calendarId.
*
* @return int
*/
public function getCalendarId()
{
return $this->calendarId;
}
}

@ -4,6 +4,7 @@
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
@ -12,9 +13,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(
* name="c_attendance_result",
* indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="attendance_id", columns={"attendance_id"}),
* @ORM\Index(name="user_id", columns={"user_id"})
* }
* )
* @ORM\Entity
@ -31,25 +29,16 @@ class CAttendanceResult
protected $iid;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $cId;
protected User $user;
/**
* @var int
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CAttendance")
* @ORM\JoinColumn(name="attendance_id", referencedColumnName="iid")
*/
protected $userId;
/**
* @var int
*
* @ORM\Column(name="attendance_id", type="integer", nullable=false)
*/
protected $attendanceId;
protected CAttendance $attendance;
/**
* @var int
@ -58,62 +47,39 @@ class CAttendanceResult
*/
protected $score;
public function getUser(): User
{
return $this->user;
}
/**
* Set userId.
*
* @param int $userId
*
* @return CAttendanceResult
*/
public function setUserId($userId)
public function setUser(User $user): self
{
$this->userId = $userId;
$this->user = $user;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
public function getAttendance(): CAttendance
{
return $this->userId;
return $this->attendance;
}
/**
* Set attendanceId.
*
* @param int $attendanceId
*
* @return CAttendanceResult
*/
public function setAttendanceId($attendanceId)
public function setAttendance(CAttendance $attendance): self
{
$this->attendanceId = $attendanceId;
$this->attendance = $attendance;
return $this;
}
/**
* Get attendanceId.
*
* @return int
*/
public function getAttendanceId()
{
return $this->attendanceId;
}
/**
* Set score.
*
* @param int $score
*
* @return CAttendanceResult
*/
public function setScore($score)
public function setScore($score): self
{
$this->score = $score;
@ -129,28 +95,4 @@ class CAttendanceResult
{
return $this->score;
}
/**
* Set cId.
*
* @param int $cId
*
* @return CAttendanceResult
*/
public function setCId($cId)
{
$this->cId = $cId;
return $this;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
{
return $this->cId;
}
}

@ -4,6 +4,7 @@
namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
@ -12,8 +13,6 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(
* name="c_attendance_sheet",
* indexes={
* @ORM\Index(name="course", columns={"c_id"}),
* @ORM\Index(name="user", columns={"user_id"}),
* @ORM\Index(name="presence", columns={"presence"})
* }
* )
@ -30,13 +29,6 @@ class CAttendanceSheet
*/
protected $iid;
/**
* @var int
*
* @ORM\Column(name="c_id", type="integer")
*/
protected $cId;
/**
* @var bool
*
@ -45,18 +37,16 @@ class CAttendanceSheet
protected $presence;
/**
* @var int
*
* @ORM\Column(name="user_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $userId;
protected User $user;
/**
* @var int
*
* @ORM\Column(name="attendance_calendar_id", type="integer")
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CAttendanceCalendar")
* @ORM\JoinColumn(name="attendance_calendar_id", referencedColumnName="iid")
*/
protected $attendanceCalendarId;
protected CAttendanceCalendar $attendanceCalendar;
/**
* Set presence.
@ -82,75 +72,27 @@ class CAttendanceSheet
return $this->presence;
}
/**
* Set cId.
*
* @param int $cId
*
* @return CAttendanceSheet
*/
public function setCId($cId)
public function getUser(): User
{
$this->cId = $cId;
return $this;
return $this->user;
}
/**
* Get cId.
*
* @return int
*/
public function getCId()
public function setUser(User $user): self
{
return $this->cId;
}
/**
* Set userId.
*
* @param int $userId
*
* @return CAttendanceSheet
*/
public function setUserId($userId)
{
$this->userId = $userId;
$this->user = $user;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
public function getAttendanceCalendar(): CAttendanceCalendar
{
return $this->userId;
return $this->attendanceCalendar;
}
/**
* Set attendanceCalendarId.
*
* @param int $attendanceCalendarId
*
* @return CAttendanceSheet
*/
public function setAttendanceCalendarId($attendanceCalendarId)
public function setAttendanceCalendar(CAttendanceCalendar $attendanceCalendar): self
{
$this->attendanceCalendarId = $attendanceCalendarId;
$this->attendanceCalendar = $attendanceCalendar;
return $this;
}
/**
* Get attendanceCalendarId.
*
* @return int
*/
public function getAttendanceCalendarId()
{
return $this->attendanceCalendarId;
}
}

@ -4,25 +4,60 @@
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CoreBundle\Repository\ResourceNodeRepository;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Entity\CThematicAdvance;
use Doctrine\ORM\QueryBuilder;
use Cocur\Slugify\SlugifyInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
final class CThematicAdvanceRepository extends ResourceRepository
final class CThematicAdvanceRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, CThematicAdvance::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 delete($resource)
{
$this->getEntityManager()->remove($resource);
$this->getEntityManager()->flush();
}
}

Loading…
Cancel
Save