示例#1
0
 /**
  * Test course_searched event.
  */
 public function test_course_searched()
 {
     // Setup test data.
     $course = $this->getDataGenerator()->create_course();
     $coursectx = context_course::instance($course->id);
     $searchterm = 'testing123';
     $params = array('context' => $coursectx, 'other' => array('searchterm' => $searchterm));
     // Create event.
     $event = \mod_twf\event\course_searched::create($params);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $this->assertCount(1, $events);
     $event = reset($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_twf\\event\\course_searched', $event);
     $this->assertEquals($coursectx, $event->get_context());
     $expected = array($course->id, 'twf', 'search', "search.php?id={$course->id}&search={$searchterm}", $searchterm);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     $this->assertNotEmpty($event->get_name());
 }
示例#2
0
    if (!empty($dateto)) {
        $search .= ' dateto:' . $dateto;
    }
    $individualparams = true;
} else {
    $individualparams = false;
}
if ($search) {
    $search = twf_clean_search_terms($search);
}
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('invalidcourseid');
}
require_course_login($course);
$params = array('context' => $PAGE->context, 'other' => array('searchterm' => $search));
$event = \mod_twf\event\course_searched::create($params);
$event->trigger();
$strtwfs = get_string("modulenameplural", "twf");
$strsearch = get_string("search", "twf");
$strsearchresults = get_string("searchresults", "twf");
$strpage = get_string("page");
if (!$search || $showform) {
    $PAGE->navbar->add($strtwfs, new moodle_url('/mod/twf/index.php', array('id' => $course->id)));
    $PAGE->navbar->add(get_string('advancedsearch', 'twf'));
    $PAGE->set_title($strsearch);
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    twf_print_big_search_form($course);
    echo $OUTPUT->footer();
    exit;
}