Commit eb178941 authored by Myriam Delaruelle's avatar Myriam Delaruelle
Browse files

deleted unused cron task

parent cf2452a3
......@@ -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,
......
......@@ -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
......
......@@ -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) {
......
<?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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment