From eb1789410352d1fefd4ddc18bcff4368b194e16b Mon Sep 17 00:00:00 2001 From: Myriam Delaruelle <Myriam Delaruelle@bdn-un-mdelarue.ad.univ-lorraine.fr> Date: Tue, 14 Sep 2021 10:52:37 +0200 Subject: [PATCH] deleted unused cron task --- db/tasks.php | 10 +--- entity/course_format_iena_cron_action.php | 73 +---------------------- renderer.php | 3 + save_sync_task_iena_hide.php | 61 ------------------- 4 files changed, 5 insertions(+), 142 deletions(-) delete mode 100644 save_sync_task_iena_hide.php diff --git a/db/tasks.php b/db/tasks.php index 9435163..5d9bca3 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -37,15 +37,7 @@ $tasks = array( - // array( - // 'classname' => 'format_iena\task\sync_task_iena_hide', - // 'blocking' => 0, - // 'minute' => '*/5', - // 'hour' => '*', - // 'day' => '*', - // 'month' => '*', - // 'dayofweek' => '*' - // ), + array( 'classname' => 'format_iena\task\sync_task_iena_message', 'blocking' => 0, diff --git a/entity/course_format_iena_cron_action.php b/entity/course_format_iena_cron_action.php index e6c6150..59e7c83 100644 --- a/entity/course_format_iena_cron_action.php +++ b/entity/course_format_iena_cron_action.php @@ -41,79 +41,8 @@ class course_format_iena_cron_action { - /** - * @param $requete - * @param $nbJours - * @throws coding_exception - */ - private function hide_section($requete, $nbJours) - { - if ($nbJours < 0) { - set_section_visible($requete->course, $requete->section, 0); - //Log for task - echo get_string('hide_section', 'format_iena') . $requete->name; - } else { - set_section_visible($requete->course, $requete->section, 1); - //Log for task - echo get_string('show_section', 'format_iena') . $requete->name; - } - } - - /** - * @param $date - * @return float|int - */ - private function calcul_nb_jours($date) - { - $date_now = date_create(date("Y-m-d H:i:s"))->getTimestamp(); - $nbJoursTimestamp = $date_now - $date; - // Calcul number of day - $nbJours = $nbJoursTimestamp / 86400; - return $nbJours; - } - - /** - * @throws dml_exception - */ - public function cron_hide_section() - { - global $DB; - - $sections = $DB->get_records('format_iena'); - - foreach ($sections as $section) { - $requete = $DB->get_record('course_sections', array('id' => $section->id_section)); - - if ($section->hide == 1) { - set_section_visible($requete->course, $requete->section, 1); - echo get_string('show_section', 'format_iena') . $requete->name; - } - - if ($section->hide == 2) { - $date_rendu = date_create($section->date_rendu); - //We calcul date with timeStamp - $date_rendu = $date_rendu->getTimestamp(); - $this->hide_section($requete, $this->calcul_nb_jours($date_rendu)); - - } else if ($section->hide == 3) { - if ($section->day_before && $section->nb_days_before) { - $date_before = date('Y-m-d H:i:s', strtotime($section->date_rendu . " - " . $section->nb_days_before . " days")); - $date_before = date_create($date_before)->getTimestamp(); - $this->hide_section($requete, $this->calcul_nb_jours($date_before)); - } else if ($section->day_same) { - $date_rendu = date_create($section->date_rendu); - $date_rendu = $date_rendu->getTimestamp(); - $this->hide_section($requete, $this->calcul_nb_jours($date_rendu)); - } else if ($section->day_after && $section->nb_days_after) { - $date_after = date('Y-m-d H:i:s', strtotime($section->date_rendu . " + " . $section->nb_days_after . " days")); - $date_after = date_create($date_after)->getTimestamp(); - $this->hide_section($requete, $this->calcul_nb_jours($date_after)); - } - } - - } - } + /** * Récupère le nombre de jours avant le rendu/présence pour envoyer une notification * @return type diff --git a/renderer.php b/renderer.php index 5351435..093b7ea 100644 --- a/renderer.php +++ b/renderer.php @@ -187,6 +187,9 @@ class format_iena_renderer extends format_topics_renderer{ $section->presence = "À distance"; $string_date_presence="Pour le "; } + else{ + $string_date_presence="Le "; + } } if (isset($param_section->daterendu) && $param_section->daterendu != 0) { diff --git a/save_sync_task_iena_hide.php b/save_sync_task_iena_hide.php deleted file mode 100644 index 4271d18..0000000 --- a/save_sync_task_iena_hide.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - /** - * Created by PhpStorm. - * User: softia - * Date: 15/03/18 - * Time: 16:22 - */ - -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see <http://www.gnu.org/licenses/>. - - /** - * - * sync_task_iena_message lunch cron_hide_section() - * - * @package format_iena - * @category format - * @copyright 2018 Softia/Université lorraine - * @author vrignaud camille - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - - namespace format_iena\task; - - class sync_task_iena_hide extends \core\task\scheduled_task - { - /** - * Get a descriptive name for this task (shown to admins). - * - * @return string - */ - - public function get_name() - { - return "task_iena_hide_section"; - } - - - public function execute() - { - global $CFG; - require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_cron_action.php'); - $cron_test = new \course_format_iena_cron_action(); - echo 'cron_hide_section start'; - $cron_test->cron_hide_section(); - echo 'cron_hide_section stop'; - } - - } \ No newline at end of file -- GitLab