|
@@ -7,6 +7,11 @@
|
|
|
|
|
|
require_once '../inc/global.inc.php';
|
|
|
|
|
|
+use \Chamilo\CoreBundle\Entity\Session;
|
|
|
+use \Doctrine\Common\Collections\Criteria;
|
|
|
+
|
|
|
+api_block_anonymous_users(true);
|
|
|
+
|
|
|
if (api_is_student()) {
|
|
|
api_not_allowed(true);
|
|
|
exit;
|
|
@@ -15,7 +20,6 @@ if (api_is_student()) {
|
|
|
$em = Database::getManager();
|
|
|
$session = null;
|
|
|
$sessionsInfo = SessionManager::getSessionsFollowedByUser(api_get_user_id(), COURSEMANAGER);
|
|
|
-$coursesData = [];
|
|
|
|
|
|
$form = new FormValidator('work_report');
|
|
|
$selectSession = $form->addSelect('session', get_lang('Session'), [0 => get_lang('None')]);
|
|
@@ -30,60 +34,69 @@ if ($form->validate()) {
|
|
|
$session = $em->find('ChamiloCoreBundle:Session', $sessionId);
|
|
|
}
|
|
|
|
|
|
+$coursesInfo = [];
|
|
|
+$usersInfo = [];
|
|
|
+
|
|
|
if ($session) {
|
|
|
- $userSubscriptions = $session->getUsers();
|
|
|
$sessionCourses = $session->getCourses();
|
|
|
|
|
|
foreach ($sessionCourses as $sessionCourse) {
|
|
|
$course = $sessionCourse->getCourse();
|
|
|
- $userCourseSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, 0);
|
|
|
- $courseInfo = [
|
|
|
- 'title' => $course->getTitle()
|
|
|
- ];
|
|
|
-
|
|
|
- $table = new HTML_Table(['class' => 'table table-hover table-striped']);
|
|
|
- $table->setHeaderContents(0, 0, get_lang('OfficialCode'));
|
|
|
- $table->setHeaderContents(0, 1, get_lang('StudentName'));
|
|
|
- $table->setHeaderContents(0, 2, get_lang('TimeSpentOnThePlatform'));
|
|
|
- $table->setHeaderContents(0, 3, get_lang('FirstLoginInPlatform'));
|
|
|
- $table->setHeaderContents(0, 4, get_lang('LatestLoginInPlatform'));
|
|
|
- $table->setHeaderContents(0, 5, get_lang('Course'));
|
|
|
- $table->setHeaderContents(0, 6, get_lang('Progress'));
|
|
|
- $table->setHeaderContents(0, 7, get_lang('SentDate'));
|
|
|
+ $coursesInfo[$course->getId()] = $course->getCode();
|
|
|
+ $criteria = Criteria::create()->where(
|
|
|
+ Criteria::expr()->eq("status", Session::STUDENT)
|
|
|
+ );
|
|
|
+ $userCourseSubscriptions = $session
|
|
|
+ ->getUserCourseSubscriptions()
|
|
|
+ ->matching($criteria);
|
|
|
|
|
|
foreach ($userCourseSubscriptions as $userCourseSubscription) {
|
|
|
$user = $userCourseSubscription->getUser();
|
|
|
-
|
|
|
+
|
|
|
+ if (!array_key_exists($user->getId(), $usersInfo)) {
|
|
|
+ $usersInfo[$user->getId()] = [
|
|
|
+ 'code' => $user->getOfficialCode(),
|
|
|
+ 'complete_name' => $user->getCompleteName(),
|
|
|
+ 'time_in_platform' => api_time_to_hms(
|
|
|
+ Tracking::get_time_spent_on_the_platform($user->getId())
|
|
|
+ ),
|
|
|
+ 'first_connection' => Tracking::get_first_connection_date($user->getId()),
|
|
|
+ 'last_connection' => Tracking::get_last_connection_date($user->getId())
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_score'] = null;
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_progress'] = null;
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_last_sent_date'] = null;
|
|
|
+
|
|
|
+ if (!$session->hasStudentInCourse($user, $course)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_score'] = Tracking::get_avg_student_score(
|
|
|
+ $user->getId(),
|
|
|
+ $course->getCode(),
|
|
|
+ null,
|
|
|
+ $session->getId()
|
|
|
+ );
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_progress'] = Tracking::get_avg_student_progress(
|
|
|
+ $user->getId(),
|
|
|
+ $course->getCode(),
|
|
|
+ null,
|
|
|
+ $session->getId()
|
|
|
+ );
|
|
|
+
|
|
|
$lastPublication = Tracking::getLastStudentPublication($user, 'work', $course, $session);
|
|
|
- $lastPublicationFormatted = null;
|
|
|
|
|
|
- if ($lastPublication) {
|
|
|
- $lastPublicationFormatted = api_format_date(
|
|
|
- $lastPublication->getSentDate()->getTimestamp(),
|
|
|
- DATE_TIME_FORMAT_SHORT
|
|
|
- );
|
|
|
+ if (!$lastPublication) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- $data = [
|
|
|
- $user->getOfficialCode(),
|
|
|
- $user->getCompleteName(),
|
|
|
- api_time_to_hms(
|
|
|
- Tracking::get_time_spent_on_the_platform($user->getId())
|
|
|
- ),
|
|
|
- Tracking::get_first_connection_date($user->getId()),
|
|
|
- Tracking::get_last_connection_date($user->getId()),
|
|
|
- Tracking::get_avg_student_score($user->getId(), $course->getCode(), null, $session->getId()),
|
|
|
- Tracking::get_avg_student_progress($user->getId(), $course->getCode(), null, $session->getId()),
|
|
|
- $lastPublicationFormatted
|
|
|
- ];
|
|
|
-
|
|
|
- $table->addRow($data);
|
|
|
+ $usersInfo[$user->getId()][$course->getId() . '_last_sent_date'] = api_format_date(
|
|
|
+ $lastPublication->getSentDate()->getTimestamp(),
|
|
|
+ DATE_TIME_FORMAT_SHORT
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- $coursesData[] = [
|
|
|
- 'title' => $course->getTitle(),
|
|
|
- 'detail_table' => $table->toHtml()
|
|
|
- ];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -92,16 +105,20 @@ $interbreadcrumb[] = [
|
|
|
'name' => get_lang('MySpace')
|
|
|
];
|
|
|
|
|
|
-$view = new Template(get_lang('WorkReport'));
|
|
|
-$view->assign('header', get_lang('WorkReport'));
|
|
|
+$toolName = get_lang('WorkReport');
|
|
|
+
|
|
|
+$view = new Template($toolName);
|
|
|
$view->assign('form', $form->returnForm());
|
|
|
|
|
|
if ($session) {
|
|
|
$view->assign('session', ['name' => $session->getName()]);
|
|
|
- $view->assign('courses', $coursesData);
|
|
|
+ $view->assign('courses', $coursesInfo);
|
|
|
+ $view->assign('users', $usersInfo);
|
|
|
}
|
|
|
|
|
|
$template = $view->get_template('my_space/works.tpl');
|
|
|
$content = $view->fetch($template);
|
|
|
+
|
|
|
+$view->assign('header', $toolName);
|
|
|
$view->assign('content', $content);
|
|
|
$view->display_one_col_template();
|