1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Custom behat functions 19 * 20 * @package report_outline 21 * @copyright 2017 Davo Smith, Synergy Learning 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require_once (__DIR__ . '/../../../../lib/behat/behat_base.php'); 26 27 /** 28 * Class behat_report_outline custom Behat steps for report_outline. 29 */ 30 class behat_report_outline extends behat_base { 31 /** 32 * This is a horrible, horrible hack, but it is not clear how else a range of log entries can be produced to test the 33 * filtering of the log entries. 34 * 35 * @Given /^the log timestamp for "(?P<username>(?:[^"]|\\")*)" and "(?P<activity_idnumber>(?:[^"]|\\")*)" is set to "(?P<date>(?:[^"]|\\")*)"$/ 36 * @param string $username 37 * @param string $activityidnumber 38 * @param string $date 39 */ 40 public function the_log_timestamp_for_and_is_set_to($username, $activityidnumber, $date) { 41 global $DB; 42 43 // Get the name of the log table. 44 $lm = get_log_manager(); 45 $readers = $lm->get_readers('\\core\\log\\sql_internal_table_reader'); 46 $reader = reset($readers); 47 $table = $reader->get_internal_log_table_name(); 48 49 // Find the log entry. 50 $cmrec = $DB->get_record('course_modules', ['idnumber' => $activityidnumber], '*', MUST_EXIST); 51 $modname = $DB->get_field('modules', 'name', ['id' => $cmrec->module], MUST_EXIST); 52 $userid = $DB->get_field('user', 'id', ['username' => $username], MUST_EXIST); 53 54 $cond = [ 55 'userid' => $userid, 56 'component' => 'mod_'.$modname, 57 'target' => 'course_module', 58 'action' => 'viewed', 59 'contextinstanceid' => $cmrec->id, 60 ]; 61 $logentries = $DB->get_records($table, $cond, 'timecreated DESC', 'id', 0, 1); 62 $logentry = reset($logentries); 63 64 // Update the timecreated for the entry. 65 $timestamp = strtotime($date); 66 $DB->set_field($table, 'timecreated', $timestamp, ['id' => $logentry->id]); 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body