| Línea 39... |
Línea 39... |
| 39 |
* @param stdClass $course course instance
|
39 |
* @param stdClass $course course instance
|
| 40 |
* @param int|stdClass $user id/object of the user whose logs are needed
|
40 |
* @param int|stdClass $user id/object of the user whose logs are needed
|
| 41 |
* @param string $typeormode type of logs graph needed (usercourse.png/userday.png) or the mode (today, all).
|
41 |
* @param string $typeormode type of logs graph needed (usercourse.png/userday.png) or the mode (today, all).
|
| 42 |
* @param int $date timestamp in GMT (seconds since epoch)
|
42 |
* @param int $date timestamp in GMT (seconds since epoch)
|
| 43 |
* @param string $logreader Log reader.
|
43 |
* @param string $logreader Log reader.
|
| - |
|
44 |
* @param int $sitecoursefilter use a course filter in site context.
|
| 44 |
* @return void
|
45 |
* @return void
|
| 45 |
*/
|
46 |
*/
|
| 46 |
function report_log_print_graph($course, $user, $typeormode, $date=0, $logreader='') {
|
47 |
function report_log_print_graph($course, $user, $typeormode, $date=0, $logreader='', $sitecoursefilter = 0) {
|
| 47 |
global $CFG, $OUTPUT;
|
48 |
global $CFG, $OUTPUT;
|
| Línea 48... |
Línea 49... |
| 48 |
|
49 |
|
| 49 |
if (!is_object($user)) {
|
50 |
if (!is_object($user)) {
|
| 50 |
$user = core_user::get_user($user);
|
51 |
$user = core_user::get_user($user);
|
| Línea 67... |
Línea 68... |
| 67 |
$a = new stdClass();
|
68 |
$a = new stdClass();
|
| 68 |
$a->coursename = format_string($course->shortname, true, array('context' => $coursecontext));
|
69 |
$a->coursename = format_string($course->shortname, true, array('context' => $coursecontext));
|
| 69 |
$a->username = fullname($user, true);
|
70 |
$a->username = fullname($user, true);
|
| Línea 70... |
Línea 71... |
| 70 |
|
71 |
|
| 71 |
if ($typeormode == 'today' || $typeormode == 'userday.png') {
|
72 |
if ($typeormode == 'today' || $typeormode == 'userday.png') {
|
| 72 |
$logs = report_log_usertoday_data($course, $user, $date, $logreader);
|
73 |
$logs = report_log_usertoday_data($course, $user, $date, $logreader, $sitecoursefilter);
|
| 73 |
$title = get_string("hitsoncoursetoday", "", $a);
|
74 |
$title = get_string("hitsoncoursetoday", "", $a);
|
| 74 |
} else if ($typeormode == 'all' || $typeormode == 'usercourse.png') {
|
75 |
} else if ($typeormode == 'all' || $typeormode == 'usercourse.png') {
|
| 75 |
$logs = report_log_userall_data($course, $user, $logreader);
|
76 |
$logs = report_log_userall_data($course, $user, $logreader, $sitecoursefilter);
|
| 76 |
$title = get_string("hitsoncourse", "", $a);
|
77 |
$title = get_string("hitsoncourse", "", $a);
|
| Línea 77... |
Línea 78... |
| 77 |
}
|
78 |
}
|
| 78 |
|
79 |
|
| Línea 525... |
Línea 526... |
| 525 |
* Fetch logs since the start of the courses and structure in series and labels to be sent to Chart API.
|
526 |
* Fetch logs since the start of the courses and structure in series and labels to be sent to Chart API.
|
| 526 |
*
|
527 |
*
|
| 527 |
* @param stdClass $course the course object
|
528 |
* @param stdClass $course the course object
|
| 528 |
* @param stdClass $user user object
|
529 |
* @param stdClass $user user object
|
| 529 |
* @param string $logreader the log reader where the logs are.
|
530 |
* @param string $logreader the log reader where the logs are.
|
| - |
|
531 |
* @param int $sitecoursefilter use a course filter in site context.
|
| 530 |
* @return array structured array to be sent to chart API, split in two indexes (series and labels).
|
532 |
* @return array structured array to be sent to chart API, split in two indexes (series and labels).
|
| 531 |
*/
|
533 |
*/
|
| 532 |
function report_log_userall_data($course, $user, $logreader) {
|
534 |
function report_log_userall_data($course, $user, $logreader, $sitecoursefilter = 0) {
|
| 533 |
global $CFG;
|
535 |
global $CFG;
|
| 534 |
$site = get_site();
|
536 |
$site = get_site();
|
| 535 |
$timenow = time();
|
537 |
$timenow = time();
|
| 536 |
$logs = [];
|
538 |
$logs = [];
|
| 537 |
if ($course->id == $site->id) {
|
539 |
if ($course->id == $site->id) {
|
| 538 |
$courseselect = 0;
|
540 |
$courseselect = $sitecoursefilter;
|
| 539 |
} else {
|
541 |
} else {
|
| 540 |
$courseselect = $course->id;
|
542 |
$courseselect = $course->id;
|
| 541 |
}
|
543 |
}
|
| Línea 542... |
Línea 544... |
| 542 |
|
544 |
|
| Línea 580... |
Línea 582... |
| 580 |
*
|
582 |
*
|
| 581 |
* @param stdClass $course the course object
|
583 |
* @param stdClass $course the course object
|
| 582 |
* @param stdClass $user user object
|
584 |
* @param stdClass $user user object
|
| 583 |
* @param int $date A time of a day (in GMT).
|
585 |
* @param int $date A time of a day (in GMT).
|
| 584 |
* @param string $logreader the log reader where the logs are.
|
586 |
* @param string $logreader the log reader where the logs are.
|
| - |
|
587 |
* @param int $sitecoursefilter use a course filter in site context.
|
| 585 |
* @return array $logs structured array to be sent to chart API, split in two indexes (series and labels).
|
588 |
* @return array $logs structured array to be sent to chart API, split in two indexes (series and labels).
|
| 586 |
*/
|
589 |
*/
|
| 587 |
function report_log_usertoday_data($course, $user, $date, $logreader) {
|
590 |
function report_log_usertoday_data($course, $user, $date, $logreader, $sitecoursefilter = 0) {
|
| 588 |
$site = get_site();
|
591 |
$site = get_site();
|
| 589 |
$logs = [];
|
592 |
$logs = [];
|
| Línea 590... |
Línea 593... |
| 590 |
|
593 |
|
| 591 |
if ($course->id == $site->id) {
|
594 |
if ($course->id == $site->id) {
|
| 592 |
$courseselect = 0;
|
595 |
$courseselect = $sitecoursefilter;
|
| 593 |
} else {
|
596 |
} else {
|
| 594 |
$courseselect = $course->id;
|
597 |
$courseselect = $course->id;
|
| Línea 595... |
Línea 598... |
| 595 |
}
|
598 |
}
|