Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent c3c6e89540
commit 646cf62a0b
  1. 38
      main/admin/teachers_time_by_session_report.php

@ -1,9 +1,9 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use \Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use \Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use \Chamilo\CourseBundle\Entity\Repository\CStudentPublicationRepository; use Chamilo\CourseBundle\Entity\Repository\CStudentPublicationRepository;
/** /**
* Generate a teacher time report in platform by session only * Generate a teacher time report in platform by session only
@ -28,7 +28,11 @@ $sessionsInfo = api_is_platform_admin()
$session = null; $session = null;
$form = new FormValidator('teacher_time_report_by_session', 'GET'); $form = new FormValidator('teacher_time_report_by_session', 'GET');
$selectSession = $form->addSelect('session', get_lang('Session'), [0 => get_lang('None')]); $selectSession = $form->addSelect(
'session',
get_lang('Session'),
[0 => get_lang('None')]
);
$form->addButtonFilter(get_lang('Filter')); $form->addButtonFilter(get_lang('Filter'));
foreach ($sessionsInfo as $sessionInfo) { foreach ($sessionsInfo as $sessionInfo) {
@ -37,7 +41,6 @@ foreach ($sessionsInfo as $sessionInfo) {
if (isset($_GET['session']) && intval($_GET['session'])) { if (isset($_GET['session']) && intval($_GET['session'])) {
$form->setDefaults(['session' => intval($_GET['session'])]); $form->setDefaults(['session' => intval($_GET['session'])]);
$session = $em->find('ChamiloCoreBundle:Session', intval($_GET['session'])); $session = $em->find('ChamiloCoreBundle:Session', intval($_GET['session']));
} }
@ -52,7 +55,7 @@ if ($session) {
$course = $sessionCourse->getCourse(); $course = $sessionCourse->getCourse();
$coursesInfo[$course->getId()] = $course->getCode(); $coursesInfo[$course->getId()] = $course->getCode();
$criteria = Criteria::create()->where( $criteria = Criteria::create()->where(
Criteria::expr()->eq("status", Session::COACH) Criteria::expr()->eq('status', Session::COACH)
); );
$userCourseSubscriptions = $session $userCourseSubscriptions = $session
->getUserCourseSubscriptions() ->getUserCourseSubscriptions()
@ -73,22 +76,22 @@ if ($session) {
]; ];
} }
$usersInfo[$user->getId()][$course->getId() . '_number_of_students'] = null; $usersInfo[$user->getId()][$course->getId().'_number_of_students'] = null;
$usersInfo[$user->getId()][$course->getId() . '_number_of_works'] = null; $usersInfo[$user->getId()][$course->getId().'_number_of_works'] = null;
$usersInfo[$user->getId()][$course->getId() . '_last_work'] = null; $usersInfo[$user->getId()][$course->getId().'_last_work'] = null;
$usersInfo[$user->getId()][$course->getId() . '_time_spent_of_course'] = null; $usersInfo[$user->getId()][$course->getId().'_time_spent_of_course'] = null;
if (!$session->hasCoachInCourseWithStatus($user, $course)) { if (!$session->hasCoachInCourseWithStatus($user, $course)) {
continue; continue;
} }
/** @var \Chamilo\CourseBundle\Entity\Repository\CStudentPublicationRepository $studentPubRepo */ /** @var CStudentPublicationRepository $studentPubRepo */
$studentPubRepo = $em->getRepository('ChamiloCourseBundle:CStudentPublication'); $studentPubRepo = $em->getRepository('ChamiloCourseBundle:CStudentPublication');
$works = $studentPubRepo->findWorksByTeacher($user, $course, $session); $works = $studentPubRepo->findWorksByTeacher($user, $course, $session);
$usersInfo[$user->getId()][$course->getId() . '_number_of_students'] = $sessionCourse->getNbrUsers(); $usersInfo[$user->getId()][$course->getId().'_number_of_students'] = $sessionCourse->getNbrUsers();
$usersInfo[$user->getId()][$course->getId() . '_number_of_works'] = count($works); $usersInfo[$user->getId()][$course->getId().'_number_of_works'] = count($works);
$usersInfo[$user->getId()][$course->getId() . '_time_spent_of_course'] = api_time_to_hms( $usersInfo[$user->getId()][$course->getId().'_time_spent_of_course'] = api_time_to_hms(
Tracking::get_time_spent_on_the_course($user->getId(), $course->getId(), $session->getId()) Tracking::get_time_spent_on_the_course($user->getId(), $course->getId(), $session->getId())
); );
@ -98,9 +101,7 @@ if ($session) {
continue; continue;
} }
$lastFormattedDate = api_format_date($lastWork->getSentDate()->getTimestamp(), DATE_TIME_FORMAT_SHORT); $usersInfo[$user->getId()][$course->getId().'_last_work'] = api_format_date(
$usersInfo[$user->getId()][$course->getId() . '_last_work'] = api_format_date(
$lastWork->getSentDate()->getTimestamp(), $lastWork->getSentDate()->getTimestamp(),
DATE_TIME_FORMAT_SHORT DATE_TIME_FORMAT_SHORT
); );
@ -109,7 +110,7 @@ if ($session) {
} }
if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) { if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
$fileName = get_lang('TeacherTimeReport') . ' ' . api_get_local_time(); $fileName = get_lang('TeacherTimeReport').' '.api_get_local_time();
$dataToExport = []; $dataToExport = [];
$dataToExport[] = [$toolName, $session->getName()]; $dataToExport[] = [$toolName, $session->getName()];
@ -153,7 +154,6 @@ if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
} }
$dataToExport[] = [get_lang('Session'), $session->getName()]; $dataToExport[] = [get_lang('Session'), $session->getName()];
$dataToExport[] = $headers; $dataToExport[] = $headers;
$dataToExport[] = $contents; $dataToExport[] = $contents;
} }

Loading…
Cancel
Save