Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iena-course-format
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iena
iena-course-format
Commits
eb178941
Commit
eb178941
authored
3 years ago
by
Myriam Delaruelle
Browse files
Options
Downloads
Patches
Plain Diff
deleted unused cron task
parent
cf2452a3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
db/tasks.php
+1
-9
1 addition, 9 deletions
db/tasks.php
entity/course_format_iena_cron_action.php
+1
-72
1 addition, 72 deletions
entity/course_format_iena_cron_action.php
renderer.php
+3
-0
3 additions, 0 deletions
renderer.php
save_sync_task_iena_hide.php
+0
-61
0 additions, 61 deletions
save_sync_task_iena_hide.php
with
5 additions
and
142 deletions
db/tasks.php
+
1
−
9
View file @
eb178941
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
entity/course_format_iena_cron_action.php
+
1
−
72
View file @
eb178941
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
renderer.php
+
3
−
0
View file @
eb178941
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
save_sync_task_iena_hide.php
deleted
100644 → 0
+
0
−
61
View file @
cf2452a3
<?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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment