Exemple #1
0
 /**
  * Test the user report viewed event.
  *
  * It's not possible to use the moodle API to simulate the viewing of log report, so here we
  * simply create the event and trigger it.
  */
 public function test_user_report_viewed()
 {
     $course = $this->getDataGenerator()->create_course();
     $context = context_course::instance($course->id);
     // Trigger event for completion report viewed.
     $event = \report_completion\event\user_report_viewed::create(array('context' => $context, 'relateduserid' => 3));
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\report_completion\\event\\user_report_viewed', $event);
     $this->assertEquals($context, $event->get_context());
     $this->assertEquals(3, $event->relateduserid);
     $this->assertEquals(new moodle_url('/report/completion/user.php', array('id' => 3, 'course' => $course->id)), $event->get_url());
     $expected = array($course->id, 'course', 'report completion', "report/completion/user.php?id=3&course={$course->id}", $course->id);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }
Exemple #2
0
                        echo get_string('complete');
                        break;
                    case 'No':
                        echo get_string('incomplete', 'report_completion');
                        break;
                    default:
                        echo $row['status'];
                }
                // Display link on first row
                echo '</td><td class="c3">';
                if ($first_row) {
                    echo '<a href="' . $CFG->wwwroot . '/blocks/completionstatus/details.php?course=' . $c_course->id . '&user='******'">' . get_string('detailedview', 'report_completion') . '</a>';
                }
                echo '</td>';
                // Display completion date for completed courses on first row
                if ($type === 'complete' && $first_row) {
                    $params = array('userid' => $user->id, 'course' => $c_course->id);
                    $ccompletion = new completion_completion($params);
                    echo '<td class="c4">' . userdate($ccompletion->timecompleted, '%e %B %G') . '</td>';
                }
                $first_row = false;
                echo '</tr>';
            }
        }
        echo '</table>';
    }
}
echo $OUTPUT->footer();
// Trigger a user report viewed event.
$event = \report_completion\event\user_report_viewed::create(array('context' => $coursecontext, 'relateduserid' => $userid));
$event->trigger();