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 namespace tool_brickfield; 18 19 use tool_brickfield\task\process_analysis_requests; 20 21 /** 22 * Analysis and deployment class. 23 * 24 * @package tool_brickfield 25 * @copyright 2020 Brickfield Education Labs https://www.brickfield.ie 26 * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 class analysis { 29 30 /** 31 * Indicates that analysis of content has been enabled. 32 */ 33 const ANALYSISDISABLED = '0'; 34 35 /** 36 * Indicates that analysis is enabled and using request method. 37 */ 38 const ANALYSISBYREQUEST = '1'; 39 40 /** 41 * Return the type of analysis being used (currently only request). 42 * 43 * @return false|mixed|object|string|null 44 * @throws \dml_exception 45 */ 46 public static function get_type() { 47 // Moodle caches these calls, so it's not expensive. 48 return get_config(manager::PLUGINNAME, 'analysistype'); 49 } 50 51 /** 52 * Return true is analysis has been enabled. 53 * 54 * @return bool 55 * @throws \dml_exception 56 */ 57 public static function is_enabled(): bool { 58 $analysistype = static::get_type(); 59 return ($analysistype !== false) && ($analysistype !== self::ANALYSISDISABLED); 60 } 61 62 /** 63 * Return true if analysis is by request method. 64 * 65 * @return bool 66 * @throws \dml_exception 67 */ 68 public static function type_is_byrequest(): bool { 69 return static::get_type() === self::ANALYSISBYREQUEST; 70 } 71 72 /** 73 * Return true if the course has been analyzed. 74 * 75 * @param int $courseid 76 * @return bool 77 * @throws \dml_exception 78 */ 79 public static function is_course_analyzed(int $courseid): bool { 80 return scheduler::is_course_analyzed($courseid); 81 } 82 83 /** 84 * Return a redirect message with the earliest time expected for analysis to complete. 85 * @return \lang_string|string 86 * @throws \coding_exception 87 */ 88 public static function redirect_message() { 89 $epoch = new process_analysis_requests; 90 $time = userdate($epoch->get_next_scheduled_time(), get_string('strftimetime', 'core_langconfig')); 91 $message = get_string('confirmationmessage', manager::PLUGINNAME, $time); 92 93 return $message; 94 } 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body