Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1-bobologie-1
  • 2-bobologie-2
  • 3-permutation-de-sections
  • activity-filter
  • clean_tracking_table
  • dev
  • devm4
  • devm42
  • ergonomie_tableau
  • fix_cpts
  • groupes_select
  • interface_admin
  • m4-bugfix-retractable
  • master
  • moodle4.2
  • moodle4.3
  • moodle4.4
  • optimizing
  • pastilles_cliquables
  • refonte_format
  • search_student
  • v3.x
  • v3.11.01
  • v3.11.02
  • v3.5.4plus.01
  • v3.7.01
  • v3.7.02
  • v4.0
  • v4.2
  • v4.2.01
  • v4.3
  • v4.4
32 results

Target

Select target project
  • iena/course-format
1 result
Select Git revision
  • 1-bobologie-1
  • 2-bobologie-2
  • 3-permutation-de-sections
  • activity-filter
  • clean_tracking_table
  • dev
  • devm4
  • devm42
  • ergonomie_tableau
  • fix_cpts
  • groupes_select
  • interface_admin
  • m4-bugfix-retractable
  • master
  • moodle4.2
  • moodle4.3
  • moodle4.4
  • optimizing
  • pastilles_cliquables
  • refonte_format
  • search_student
  • v3.x
  • v3.11.01
  • v3.11.02
  • v3.5.4plus.01
  • v3.7.01
  • v3.7.02
  • v4.0
  • v4.2
  • v4.2.01
  • v4.3
  • v4.4
32 results
Show changes
Commits on Source (39)
Showing
with 1149 additions and 191 deletions
// 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/>.
/**
* Handle add/remove competency links.
*
* @module format_iena/suivi
* @package format_iena
* @copyright 2021 Myriam Delaruelle
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/ajax', 'core/str'],
function($, ajax, str) {
return{
registerHeader:function(){
$("#button-collapse").click(function(){
if($("#summary-wrapper").hasClass('collapsed')){
$("#summary-wrapper").animate({ "max-height": '7rem' }, "slow" );
var message=str.get_string('displayInfos', 'format_iena');
$.when(message).done(function(localizedEditString) {
$("#button-collapse").text(localizedEditString);
});
}
else{
var height= $("#summary-collapse").css("height");
$("#summary-wrapper").animate({ "max-height": height }, "slow" );
var message=str.get_string('hideInfos', 'format_iena');
$.when(message).done(function(localizedEditString) {
$("#button-collapse").text(localizedEditString);
});
}
$("#summary-wrapper").toggleClass("collapsed");
})
}
}
});
// 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/>.
/**
* Handle add/remove competency links.
*
* @module format_iena/suivi-table
* @package format_iena
* @copyright 2021 Myriam Delaruelle
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery'],
function($) {
var all_selected=false;
return{
registerSelectAll:function(){
all_selected=false;
$('#iena-select-all').on('click', function(e){
select_all_studs(e);
});
}
}
function select_all_studs(e) {
all_selected=!all_selected;
var counter = 0;
var checks = document.querySelectorAll("#table-body tr");
for (var i = 0; i < checks.length; i++) {
if ( checks[i].style.display != "none" || all_selected ) {
var box = checks[i].querySelector("input[type='checkbox']");
box.checked = all_selected;
counter++;
}
}
}
});
// 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/>.
/**
* Handle add/remove competency links.
*
* @module format_iena/suivi
* @package format_iena
* @copyright 2021 Myriam Delaruelle
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
function($, ajax, templates, str) {
var all_selected=false;
var data=[];
return{
registerFilters:function(){
$("#group-select").on('change', function(e){
changeGroup();
});
},
registerSubmit:function(infos){
data=infos;
$("#id_submit_iena").on('click', function(e){
triggerAction(e);
});
$("#section-select").on('change', function(){
changeSection();
});
$("#filter-select").on('change', function(){
changeCompletion();
});
$("#symbol-select").on('change', function(){
changeCompletion();
});
changeSection();
/*calcPercentage(data);
changeCompletion();*/
}
}
function initHeaders(){
var nb_counts=$(".th-rotate").length;
$(".th-rotate").each(function(index, element){
$( element ).css("zIndex",nb_counts-index);
})
}
function getCompleteUrl(){
url=window.location.search;
urlParams = new URLSearchParams(url);
courseid=urlParams.get('courseid');
groupid=$("#group-select").val();
sectionid=$("#section-select").val();
filter=$("#symbol-select").val() + $("#filter-select").val();
completeUrl='suivi_unit.php?courseid='+courseid;
if(sectionid){
completeUrl+='&sectionid='+sectionid;
}
if(groupid){
completeUrl+="&groupid="+groupid;
}
if(filter){
completeUrl+="&filter="+filter;
}
return completeUrl;
}
function changeGroup(){
completeUrl=getCompleteUrl();
loadMessage("loading");
$.ajax({ url: completeUrl,
data: {action: 'test'},
type: 'post',
success: function(request) {
console.log(JSON.parse(request));
data=calcPercentage(JSON.parse(request));
changeCompletion();
//reloadTable(JSON.parse(request));
}
});
}
function changeCompletion(){
symbol=$("#symbol-select").val();
filter=$("#filter-select").val();
data.count_results=0;
for(var i=0; i<data.students.length; i++){
if(symbol=="<"){
if(data.students[i].percentage <= filter){
data.count_results++;
data.students[i].visible=true;
}
else{
data.students[i].visible=false;
}
}
else if(symbol==">"){
if(data.students[i].percentage >= filter){
data.count_results++;
data.students[i].visible=true;
}
else{
data.students[i].visible=false;
}
}
else{
if(data.students[i].percentage == filter){
data.count_results++;
data.students[i].visible=true;
}
else{
data.students[i].visible=false;
}
}
}
reloadTable(data);
}
//on va devoir calculer le pourcentage, check la completion et reload la table à chaque fois
function changeSection(){
loadMessage("loading");
sectionid=$("#section-select").val();
data.count_results=0;
for(var i = 0; i<data.modules.length; i++){
if(data.modules[i].section == sectionid || sectionid == 0){
data.modules[i].visible=true;
data.count_results++;
for(var j = 0; j<data.students.length; j++){
var prog=data.students[j].progress.find(progress => progress.idmodule === data.modules[i].id);
prog.visible=true;
}
}
else{
data.modules[i].visible=false;
for(var j = 0; j<data.students.length; j++){
data.students[j].progress.find(progress => progress.idmodule === data.modules[i].id).visible=false;
}
}
}
if(data.count_results==0){
reloadTable(data);
}
else{
data=calcPercentage(data);
changeCompletion();
//reloadTable(data);
}
//reloadTable(data);
}
function loadMessage(type){
console.log("on load");
if(type=="loading"){
var message = str.get_string('loadingResults', 'format_iena');
}
else if(type=="error"){
var message = str.get_string('errorLoadingResults', 'format_iena');
}
$.when(message).done(function(localizedEditString) {
$("#partial-table").html("<div class='alert alert-primary' role='alert'>"+localizedEditString+"</div>");
});
}
function reloadTable(params){
console.log(params);
url=getCompleteUrl();
templates.render('format_iena/suivi-table', params)
.done(function(html, js){
console.log("done done");
$("#partial-table").html(html);
templates.runTemplateJS(js);
window.history.pushState('suivi',"", url);
initHeaders();
})
.fail(function(){
loadMessage("error");
});
}
function getSelectedStudents(){
var selectedChecks=$("#table-body input:checked");
var students=[];
for(var i=0; i < selectedChecks.length; i++){
students.push(selectedChecks[i].value);
}
return students;
}
//Si on veut envoyer un message à tout le monde on ajoute deux champs cachés :
//La liste des étudiants (array d'id)
//L'url de retour pour revenir sur le tableau de suivi
function triggerAction(e){
value=$("#select-actions-suivi-iena").val();
if(value=="msg"){
url=window.location.search;
urlParams = new URLSearchParams(url);
courseid=urlParams.get('courseid');
students=getSelectedStudents();
var form=$("#form_send_message_iena");
form.attr("action", "send_message.php?courseid="+courseid);
var field=$("<input></input>");
field.attr("type", "hidden");
field.attr("name", "students");
field.attr("value", students.toString());
form.append(field);
var fieldUrl=$("<input></input>");
fieldUrl.attr("type", "hidden");
fieldUrl.attr("name", "back_url");
fieldUrl.attr("value", url);
form.append(fieldUrl);
$(document.body).append(form);
form.submit();
}
else if(value=="download"){
table_download(data);
}
}
function slug_it(str) {
return str.toString().toLowerCase().trim()
.replace(/\s+/g, '-') /* Replace spaces with - */
.replace(/&/g, '-and-') /* Replace & with 'and' */
.replace(/[^\w\-]+/g, '') /* Remove all non-word chars */
.replace(/\-\-+/g, '-'); /* Replace multiple - with single - */
}
function padLeft(date){
return String(date).length > 1? date : '0'+date ;
}
function table_download() {
var students=getSelectedStudents();
var csvContent = "data:text/csv;charset=utf-8,";
var head = ['Moodle_id', 'Prénom', 'Nom', 'Groupe', 'Complétion (en %)'];
data.active_section_id=$("#section-select").val();
for ( var m = 0; m < data.modules.length; m++ ) {
if ( data.active_section_id != data.modules[m].section && data.active_section_id != 0 ) {
continue;
}
head.push('"'+data.modules[m].displayname.replace(',', '')+'"');
}
csvContent += head.join(",");
csvContent += "\n";
/* Pour chaque étudiant */
for ( var s = 0; s < data.students.length; s++ ) {
if(students.includes(data.students[s].id)){
var arr_cpl = [];
/* Pour chaque activité du cours */
var activities_nbr = 0;
var done_activities_nbr = 0;
for ( var mod = 0; mod < data.modules.length; mod++ ) {
/* Si le module n'est pas dans la section actuellement filtrée */
if ( data.active_section_id != data.modules[mod].section && data.active_section_id != 0 ) {
continue;
}
var stud_progress = data.students[s].progress
/* Si l'étudiant n'a pas de progres*/
if ( stud_progress.length == 0 ) {
arr_cpl.push(0);
} else {
// var prog = 0;
/* Pour chaque trace d'achèvement */
var cpl = 0;
for (var i =0; i<stud_progress.length; i++) {
/* Quand l'index de progression correspond à l'id du module */
if ( data.modules[mod].id == stud_progress[i].idmodule ) {
cpl = stud_progress[i].completionstate;
if (cpl == 3) {
cpl = 0.5;
cpl = '"' + cpl.toLocaleString() + '"';
}
}
}
if (cpl == 1 || cpl == 2) {
done_activities_nbr++;
}
arr_cpl.push(cpl);
}
activities_nbr++;
}
var perc = Math.round(100 * 100 * done_activities_nbr / activities_nbr) / 100;
var groups = '"';
active_group_id=$('#group-select').val();
data.active_group_name=$('#group-select').find('option:selected').html()
if ( data.active_group_name != "" && active_group_id != 0 ) {
groups += data.active_group_name.replace('"', '');
} else {
groups += data.students[s].groups.replace('"', '');
}
groups += '"';
var arr = [
data.students[s].id,
data.students[s].firstname,
data.students[s].lastname,
groups,
'"'+perc.toLocaleString()+'"',
arr_cpl
];
var dataString = arr.join(",");
csvContent += dataString + "\n";
}
}
var encodedUri = encodeURI(csvContent);
var section_name = data.active_section_id;
if ( section_name == 0 ) {
section_name = "cours-complet";
} else {
section_name = slug_it($('#section-select').find('option:selected').html()).substring(0, 20);
}
var d = new Date;
month = d.getMonth()+1;
date = d.getFullYear() +"."+ padLeft(month) +"."+ padLeft(d.getDate()) +"-"+ padLeft(d.getHours()) +"."+ padLeft(d.getMinutes()) +"."+ padLeft(d.getSeconds());
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "report-"+section_name+"-"+ date +".csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
//Pour chaque module non caché, on va regarder pour chaque étudiant
function calcPercentage(data){
console.log(data);
for (var i = 0; i < data.students.length; i++) {
data.students[i].percentage=0;
var done=0;
var nb_modules=0;
for(var j=0; j < data.students[i].progress.length;j++){
if(data.modules.find(module => module.id === data.students[i].progress[j].idmodule).visible){
nb_modules++;
if(data.students[i].progress[j].completionstate == 1 || data.students[i].progress[j].completionstate ==2){
done++;
}
}
}
data.students[i].percentage=Math.floor(100 * done / nb_modules);
}
return data;
//reloadTable(data);
}
});
......@@ -51,10 +51,13 @@
public function execute()
{
global $CFG;
mtrace("IENA notifications task started");
require_once($CFG->dirroot . '/course/format/iena/entity/course_format_iena_cron_action.php');
$cron_test = new \course_format_iena_cron_action();
// echo 'send message start';
$cron_test->cron_message();
mtrace("IENA notifications task completed");
// echo 'send message stop';
}
......
......@@ -212,4 +212,3 @@
......@@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<!--<TABLES>
<TABLE NAME="format_iena" COMMENT="Default comment for format_iena, please edit me">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
......@@ -21,5 +21,5 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</TABLES>-->
</XMLDB>
\ No newline at end of file
......@@ -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,
......
<?php
function xmldb_format_iena_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = TRUE;
if ($oldversion < 2021220900) {
//Support for old versions: we copy format options to the course_format_options table
try {
$sections= $DB->get_records_sql('select * FROM {format_iena}');
}
catch (dml_exception $e) {
echo "Aucun cours avec le format hybride dans la base";
}
if(count($sections) > 0){
foreach ($sections as $section) {
try {
$courseid = $DB->get_record_sql('select course FROM {course_sections} WHERE id=?', array($section->id_section));
$section_data = new stdClass();
$section_data->courseid = $courseid->course;
$section_data->format = "iena";
$section_data->sectionid = $section->id_section;
//On va faire pour présence, daterendu et daysnotif
$section_data->name = "presence";
$section_data->value = $section->presence;
$exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="presence"', array($section->id_section));
if(!$exists){
$resultat = $DB->insert_record('course_format_options', $section_data, true);
}
$exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="daterendu"', array($section->id_section));
if(!$exists){
if(isset($section->date_rendu)){
$section_data->name = "daterendu";
$section_data->value = strtotime($section->date_rendu);
$resultat = $DB->insert_record('course_format_options', $section_data, true);
}
}
$exists = $DB->get_record_sql('select * FROM {course_format_options} WHERE sectionid=? AND name="daysnotif"', array($section->id_section));
if(!$exists){
if(!empty($section->day_before)){
$section_data->name = "daysnotif";
$section_data->value = $section->nb_days_before;
$resultat = $DB->insert_record('course_format_options', $section_data, true);
}
}
}
catch (dml_exception $e) {
}
}
}
// Format_iena savepoint reached.
upgrade_plugin_savepoint(true, 2021070600,'format', 'iena');
}
return $result;
}
?>
\ No newline at end of file
......@@ -27,6 +27,12 @@
*/
class course_format_iena_completion {
/**
* Get completion by sections
* @param array $section_names
* @param array $idSection
* @return type
*/
public static function get_completion_by_section($section_names, $idSection) {
global $COURSE, $USER, $DB, $CFG;
......@@ -36,18 +42,6 @@ class course_format_iena_completion {
return false;
}
// $modules = $DB->get_records_sql('SELECT cmc.id, cmc.coursemoduleid, cmc.userid, cmc.completionstate, cm.section
// FROM {course_modules_completion} as cmc
// inner join {course_modules} as cm on cm.id = cmc.coursemoduleid
// inner join {user} as u on u.id = cmc.userid
// inner join {modules} as m on m.id = cm.module
// where cm.course = ? and cm.deletioninprogress = 0
// and cmc.userid = ?
// order by section, coursemoduleid asc', array($course->id, $USER->id));
// echo "<pre>";
// var_dump($modules);
// echo "</pre>";
$sections = [];
......@@ -55,11 +49,14 @@ class course_format_iena_completion {
$modinfos_cms = $fast_modinfo->get_cms();
$modules = [];
//Il récupère les modules qui ne sont pas en cours de suppression, qui ont l'achèvement d'activité, et qui sont visibles pour l'user
foreach ($modinfos_cms as $cm) {
$module = $completion->get_data($cm, true, $USER->id, $fast_modinfo);
$module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
$module->section = $cm->section;
if ( $cm->deletioninprogress == 0 && $cm->completion != 0 ) {
if ( $cm->deletioninprogress == 0 && $cm->completion != 0 && $cm->uservisible) {
$module->name = $cm->name;
$module->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
$modules[] = $module;
}
}
......@@ -75,19 +72,15 @@ class course_format_iena_completion {
$inner_modules = [];
$inner_completed = 0;
foreach ($modules as $module) {
if ( $module->section == $section_id ) {
if ( $module->section == $section_id) {
$mod = new StdClass();
$mod->coursemoduleid = $module->coursemoduleid;
$mod->completion = $module->completionstate;
$mod->name = $module->name;
$mod->url = $module->url;
if ( $mod->completion == 1 || $mod->completion == 2 ) {
$inner_completed++;
}
foreach ($modinfos_cms as $cm) {
if ( $cm->id == $mod->coursemoduleid ) {
$mod->name = $cm->name;
$mod->url = "$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id";
}
}
$inner_modules[] = $mod;
}
}
......@@ -105,11 +98,6 @@ class course_format_iena_completion {
$progress = new StdClass();
$progress->total = number_format( 100 * $total_completed / $total_modules, 0);
$progress->sections = $sections;
// echo "<pre>";
// var_dump($progress);
// echo "</pre>";
return $progress;
}
......
......@@ -41,130 +41,42 @@
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));
}
}
}
}
/**
* @throws dml_exception
* @throws coding_exception
* Récupère le nombre de jours avant le rendu/présence pour envoyer une notification
* @return type
*/
public function cron_message()
{
global $DB, $USER, $CFG;
$sections = $DB->get_records('format_iena');
$sections = $DB->get_records_sql("SELECT fo1.sectionid, fo1.value daysnotif, fo2.value daterendu, fo3.value presence FROM {course_format_options} fo1 LEFT JOIN {course_format_options} fo2 ON fo1.sectionid = fo2.sectionid LEFT JOIN {course_format_options} fo3 ON fo1.sectionid = fo3.sectionid WHERE fo1.format='iena' AND fo1.name ='daysnotif' AND (fo1.value IS NOT NULL) AND fo1.value != -1 AND fo2.name='daterendu' AND fo3.name='presence'");
foreach ($sections as $section) {
if ($section->day_before || $section->day_same || $section->day_after) {
$requete = $DB->get_record('course_sections', array('id' => $section->id_section));
$date_notif = $this->is_notif($section);
if ($date_notif == false) {
continue;
}
$this->iena_send_message($requete, $section);
} else {
$requete = $DB->get_record('course_sections', array('id' => $section->sectionid));
$date_notif = $this->is_notif($section);
if ($date_notif == false) {
continue;
}
$this->iena_send_message($requete, $section);
}
}
/**
* Check if it's time to send a notif by comparing the date withe the numbers of days before sending one in the db
* @param $section
* @return bool
* @return bool true if it's time to send a notif
*/
private function is_notif($section)
{
$date_notif = null;
$date_now = date_create(date("Y-m-d"));
if ($section->day_before && $section->nb_days_before) {
$date_notif = date('Y-m-d', strtotime($section->date_rendu . " - " . $section->nb_days_before . " days"));
$date_notif = date_create($date_notif);
if ($date_notif == $date_now) {
return true;
}
}
if ($section->day_same) {
$date_notif = date_create(date('Y-m-d', strtotime($section->date_rendu)));
if ($date_notif == $date_now) {
return true;
}
//On compare la date d'aujourd'hui avec le timestamp - daysnotifs
$date_now=date('Ymd');
$timenotif=strtotime('-'.$section->daysnotif.' days', $section->daterendu);
$date_notif=date('Ymd', $timenotif);
if($date_notif==$date_now){
return true;
}
if ($section->day_after && $section->nb_days_after) {
$date_notif = date('Y-m-d', strtotime($section->date_rendu . " + " . $section->nb_days_after . " days"));
$date_notif = date_create($date_notif);
if ($date_notif == $date_now) {
return true;
}
}
return false;
}
......@@ -177,8 +89,12 @@
private function iena_send_message($requete, $section)
{
global $DB, $CFG, $USER;
$course_ctx = context_course::instance($requete->course);
//À vérifier : on récupère tous les utilisateurs, même les invités
//2. $students = get_role_users(5 , $context) (the 5 represents the role-id with role.shortname = 'student')
//
$students = get_enrolled_users($course_ctx);
$course = $DB->get_record('course', array('id' => $requete->course), '*', MUST_EXIST);
......@@ -187,8 +103,8 @@
$messageContent .= "<h1>Rappel</h1>";
$messageContent .= "<h2>$course->fullname</h2>";
$date_jour = date('d/m', strtotime($section->date_rendu));
$date_heure = date('H:i', strtotime($section->date_rendu));
$date_jour = date('d/m', $section->daterendu);
$date_heure = date('H:i', $section->daterendu);
// 0 : NC
// 1 : work in the classroom
......
......@@ -2,8 +2,8 @@
/**
* Created by PhpStorm.
* User: softia
* Date: 15/03/18
* Time: 16:22
* Date: 13/03/18
* Time: 11:26
*/
// This file is part of Moodle - http://moodle.org/
......@@ -23,39 +23,42 @@
/**
*
* sync_task_iena_message lunch cron_hide_section()
* course_format_iena_sections
*
* @package format_iena
* @category format
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille
* @copyright 2021 Softia/Université lorraine
* @author Delaruelle Myriam
* @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
require_once("{$CFG->libdir}/formslib.php");
class course_format_iena_message extends moodleform
{
/**
* Get a descriptive name for this task (shown to admins).
*
* @return string
*/
public function get_name()
public function definition()
{
return "task_iena_hide_section";
}
// TODO: Implement definition() method.
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';
$mform = $this->_form; // Don't forget the underscore!
$description = "";
$mform->addElement('editor', 'summary', get_string('summary', 'format_iena'));
$mform->setType('summary', PARAM_RAW);
$mform->addRule('summary', get_string('error'), 'required', null, null, false, false);
$mform->setDefault('summary', array('text' => $description));
$mform->addElement('hidden', 'back_url', '');
$mform->setType('back_url', PARAM_TEXT);
$mform->setDefault('back_url', $this->_customdata['back_url']);
$mform->addElement('hidden', 'students', '');
$mform->setType('students', PARAM_TEXT);
$mform->setDefault('students', $this->_customdata['students']);
$this->add_action_buttons(true, "Envoyer");
}
}
\ No newline at end of file
......@@ -124,21 +124,6 @@
AND visibleoncoursepage = 1
AND completion != 0', array($id_section));
}
// if ($course->restrictedbreadcrum == 1) {
// // ne requête que les sections qui possèdent des activités suivies dans le suivi de progression pour la barre de progression
// $requete = $DB->get_records_sql('SELECT cm.id FROM {course_modules} as cm
// INNER JOIN {format_iena_settings} as iena on cm.id = iena.cmid
// WHERE cm.section = ?
// AND cm.visible = 1
// AND iena.hide = 1
// AND cm.deletioninprogress = 0
// AND cm.completion != 0', array($id_section));
// } else {
// $requete = $DB->get_records_sql('SELECT id FROM {course_modules} WHERE section = ? AND deletioninprogress = 0
// AND visible = 1
// AND completion != 0', array($id_section));
// }
$ressources = array();
$i = 0;
......
......@@ -33,8 +33,13 @@
public $name;
/** @var int id of course */
public $id_course;
/** @var block_career_ressources array<Ressource> ressources */
public $ressources;
/** @var block_career_resources array<Ressource> resources */
public $resources;
/** @var date */
public $date;
/** @var string availability */
public $availability;
public $visibility;
/**
......@@ -125,4 +130,156 @@
return $requete;
}
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*
* @return self
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getIdCourse()
{
return $this->id_course;
}
/**
* @param mixed $id_course
*
* @return self
*/
public function setIdCourse($id_course)
{
$this->id_course = $id_course;
return $this;
}
/**
* @return mixed
*/
public function getResources()
{
return $this->resources;
}
/**
* @param mixed $resources
*
* @return self
*/
public function setResources($resources)
{
$this->resources = $resources;
return $this;
}
/**
* @return mixed
*/
public function getDate()
{
return $this->date;
}
/**
* @param mixed $date
*
* @return self
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* @return mixed
*/
public function getAvailability()
{
return $this->availability;
}
/**
* @param mixed $availability
*
* @return self
*/
public function setAvailability($availability)
{
$this->availability = $availability;
return $this;
}
/**
* @return mixed
*/
public function getVisibility()
{
return $this->visibility;
}
/**
* @param mixed $visibility
*
* @return self
*/
public function setVisibility($visibility)
{
$this->visibility = $visibility;
return $this;
}
public function toArray(){
$vars = [];
foreach($this as $varName => $varValue) {
$vars[$varName] = $varValue;
}
return $vars;
}
}
......@@ -76,7 +76,7 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
$('.section').find('a[href="#"].voir-plus').on('click', function (e) {
e.preventDefault();
this.expand = !this.expand;
$(this).text(this.expand?"Réduire la description":"Voir la description compléte");
$(this).text(this.expand?"Réduire la description":"Voir la description complète");
$(this).closest('.section').find('.small, .big').toggleClass('small big');
});
}(jQuery));
\ No newline at end of file
......@@ -22,6 +22,8 @@
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* Point d'entrée du plugin
*/
defined('MOODLE_INTERNAL') || die();
......@@ -33,10 +35,7 @@
require_once('entity/course_format_iena_groups.php');
require_once('entity/course_format_iena_attendance.php');
/*$cron_test = new course_format_iena_cron_action();
$cron_test->cron_hide_section();
$cron_test->cron_message();*/
//use core_completion\progress;
require_once($CFG->dirroot . '/blocks/myoverview/lib.php');
require_once($CFG->dirroot . '/completion/classes/progress.php');
......@@ -61,9 +60,14 @@
course_create_sections_if_missing($course, 0);
$renderer = $PAGE->get_renderer('format_iena');
if (!empty($displaysection)) {
$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
} else {
$renderer->print_iena_section_pages($course);
$renderer->switch_mode($course);
//$renderer->print_iena_section_pages($course);
}
// $PAGE->requires->js('/course/format/iena/js/jquery.min.js');
// $PAGE->requires->js('/course/format/iena/format.js');
......@@ -47,6 +47,7 @@
})
function set_indicateur_displays() {
console.log("display indicateur")
$('.nb_pers').hide();
$('.' + $('#select-group').val()).show();
}
......
(function() {
// inclus nul part.
})()
\ No newline at end of file
......@@ -80,4 +80,20 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
$string['section'] = 'Section';
$string['hide_section'] = 'HIDE section ';
$string['show_section'] = 'SHOW section ';
$string['aboutcourse'] = 'About this course';
$string['modalite_help'] = 'To get help on modalities';
$string['loadingResults'] = "Loading results...";
$string['errorLoadingResults'] = "Students could not be retrieved, please contact an administrator";
$string['caption']="Caption";
$string['status0']="Activity not completed";
$string['status1']="Activity completed";
$string['status2']="Activity completed and passed";
$string['status3']="Activity completed but not passed";
$string["send_message_title"]="Sending a message to {{nb_results}} people";
$string['display_course_infos']="Show/hide course information";
$string['my_progress']="My progress in the course: ";
$string['table_progress']="Tracking";
$string['displayInfos']="Display course informations";
$string['hideInfos']="Hide course informations";
......@@ -31,7 +31,7 @@
$string['editsection'] = 'Modifier section';
$string['deletesection'] = 'Supprimer section';
$string['sectionname'] = 'Section';
$string['section0name'] = 'General';
$string['section0name'] = 'Général';
$string['hidefromothers'] = 'Cacher section';
$string['showfromothers'] = 'Voir section';
$string['showdefaultsectionname'] = 'Show the default sections name';
......@@ -47,7 +47,7 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
$string['notif'] = 'Notification';
$string['notif_summary'] = 'Une notification peut être envoyée à l étudiant par mail. Elle lui rapplera de consulter la section et contiendra diverses informations (nom du cours, lien vers le cours, nom de la section, date le la section et modalité';
$string['in_presence'] = 'En présence';
$string['not_presence'] = 'A distance';
$string['not_presence'] = 'À distance';
$string['days_before'] = 'Un certain nombre de jours avant la séance';
$string['days_after'] = 'Un certain nombre de jours après la séance';
$string['days_same'] = 'Le jour même';
......@@ -80,4 +80,20 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
$string['section'] = 'Section';
$string['hide_section'] = 'CACHER la section ';
$string['show_section'] = 'MONTRER la section ';
$string['aboutcourse'] = 'À propos de ce cours';
$string['modalite_help'] = 'Pour avoir de l\'aide sur les modalités';
$string['loadingResults'] = "Chargement des résultats...";
$string['errorLoadingResults'] = "Les étudiants n'ont pas pu être chargés, veuillez contacter un administrateur.";
$string['caption']="Légende";
$string['status0']="Activité non complétée";
$string['status1']="Activité complétée";
$string['status2']="Activité complétée et validée";
$string['status3']="Activité complétée non validée";
$string["send_message_title"]="Envoi d'un message à {{nb_results}} personnes";
$string['display_course_infos']="Afficher/Masquer les informations du cours";
$string['my_progress']="Ma progression dans le cours : ";
$string['table_progress']="Suivi des étudiants";
$string['displayInfos']="Afficher les infos du cours";
$string['hideInfos']="Masquer les infos du cours";
......@@ -51,20 +51,6 @@
);
}
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
// $courseconfig = get_config('moodlecourse');
// $max = $courseconfig->maxsections;
// if (!isset($max) || !is_numeric($max)) {
// $max = 52;
// }
// $sectionmenu = array();
// for ($i = 0; $i <= $max; $i++) {
// $sectionmenu[$i] = "$i";
// }
// $courseformatoptionsedit['numsections'] = array(
// 'label' => new lang_string('numberweeks'),
// 'element_type' => 'select',
// 'element_attributes' => array($sectionmenu),
// );
$choiceTab = array();
$choiceTab['1'] = get_string('yes', 'format_iena');
$choiceTab['0'] = get_string('no', 'format_iena');
......@@ -82,6 +68,214 @@
}
return $courseformatoptions;
}
/**
* Definitions of the additional options that this course format uses for section
*
* See {@link format_base::course_format_options()} for return array definition.
*
* Additionally section format options may have property 'cache' set to true
* if this option needs to be cached in {@link get_fast_modinfo()}. The 'cache' property
* is recommended to be set only for fields used in {@link format_base::get_section_name()},
* {@link format_base::extend_course_navigation()} and {@link format_base::get_view_url()}
*
* For better performance cached options are recommended to have 'cachedefault' property
* Unlike 'default', 'cachedefault' should be static and not access get_config().
*
* Regardless of value of 'cache' all options are accessed in the code as
* $sectioninfo->OPTIONNAME
* where $sectioninfo is instance of section_info, returned by
* get_fast_modinfo($course)->get_section_info($sectionnum)
* or get_fast_modinfo($course)->get_section_info_all()
*
* All format options for particular section are returned by calling:
* $this->get_format_options($section);
*
* @param bool $foreditform
* @return array
*/
public function section_format_options($foreditform = false) {
global $CFG;
static $courseformatoptions = false;
if ($courseformatoptions === false) {
$courseformatoptions = array(
'presence'=>array(
'label'=>"Présence",
'type'=>PARAM_INT
),
'daterendu'=>array(
'label'=>"Date rendu",
'type'=>PARAM_INT
),
'daysnotif'=>array(
'label'=>"Notification",
'type'=>PARAM_INT
)
);
}
return $courseformatoptions;
}
/**
* Adds format options elements to the course/section edit form.
*
* This function is called from {@link course_edit_form::definition_after_data()}.
*
* @param MoodleQuickForm $mform form the elements are added to.
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
* @return array array of references to the added form elements.
*/
public function create_edit_form_elements(&$mform, $forsection = false) {
global $COURSE;
global $PAGE;
$elements = parent::create_edit_form_elements($mform, $forsection);
if ($forsection) {
$mform->removeElement('presence', false);
$mform->removeElement('daterendu', false);
$mform->removeElement('daysnotif', false);
$sectionclass = new stdClass();
$sectionclass->id=optional_param('id', 0, PARAM_INT);
$section_config=$this->get_format_options($sectionclass);
$mform->addElement('header', 'nameforyourheaderelement', 'Format hybride');
$radioarray=array();
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Distance', 2);
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Présentiel', 1);
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Aucune', 0);
$mform->addGroup($radioarray, 'modalite', 'Modalité', array(' '), false);
$mform->addHelpButton('modalite', 'modalite', 'format_iena');
$datearray=array();
$datearray[] = $mform->createElement('date_time_selector', 'daterendu', '');
$datearray[] = $mform->createElement('checkbox', 'daterenducheck', 'Activer');
$mform->addGroup($datearray, 'groupdate', 'Date d\'échéance', array(' '), false);
$mform->disabledIf('groupdate', 'daterenducheck');
//On montre le groupe seulement si à distance
$mform->hideIf('groupdate', 'presence', 'neq', 2);
//$mform->hideIf('groupdate', 'id_presence_2', 'notchecked');
$datearray=array();
$datearray[] = $mform->createElement('date_time_selector', 'daterendu2', '');
$datearray[] = $mform->createElement('checkbox', 'daterenducheck2', 'Activer');
$mform->addGroup($datearray, 'groupdate2', 'Date du cours', array(' '), false);
$mform->disabledIf('groupdate2', 'daterenducheck2');
//On montre le groupe si pas distance
$mform->hideIf('groupdate2', 'presence', 'eq', 2);
$daysarray=array();
$days=array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
$daysarray[] = $mform->createElement('select', 'daysnotif', "jours avant la séance", $days);
$daysarray[]=$mform->createElement('html', ' <span id="days-text">jours avant la séance</span>');
$daysarray[] = $mform->createElement('checkbox', 'selectdayscheck', 'Activer');
$mform->addGroup($daysarray, 'groupdays', 'Notification', array(' '), false);
$mform->disabledIf('groupdays', 'selectdayscheck');
$mform->disabledIf('groupdays', 'daterenducheck');
$mform->hideIf('groupdays', 'presence', 'neq', 2);
$daysarray=array();
$daysarray[] = $mform->createElement('select', 'daysnotif2', "jours avant le rendu", $days);
$daysarray[]=$mform->createElement('html', ' <span id="days-text">jours avant le rendu</span>');
$daysarray[] = $mform->createElement('checkbox', 'selectdayscheck2', 'Activer');
$mform->addGroup($daysarray, 'groupdays2', 'Notification', array(' '), false);
$mform->disabledIf('groupdays2', 'selectdayscheck2');
$mform->disabledIf('groupdays2', 'daterenducheck2');
$mform->hideIf('groupdays2', 'presence', 'eq', 2);
//on ne peut pas activer des notifs s'il n'y a pas de date de rendu/date de cours
if($section_config['presence']){
$mform->setDefault('presence', $section_config['presence']);
}
if($section_config['daterendu']){
if(isset($section_config['presence']) && $section_config['presence']==2){
error_log("on passe là");
$mform->setDefault('daterendu', $section_config['daterendu']);
$mform->setDefault('daterenducheck', "1");
}
else if(isset($section_config['presence'])){
error_log("non on passe là");
$mform->setDefault('daterendu2', $section_config['daterendu']);
$mform->setDefault('daterenducheck2', "1");
}
}
if(isset($section_config['daysnotif']) && $section_config['daysnotif'] > -1){
$mform->setDefault('selectdays', $section_config['daysnotif']);
$mform->setDefault('selectdayscheck', "1");
}
}
return $elements;
}
/**
* Updates format options for a course
*
* In case if course format was changed to 'periods', we try to copy options
* 'coursedisplay', 'numsections' and 'hiddensections' from the previous format.
* If previous course format did not have 'numsections' option, we populate it with the
* current number of sections
*
* @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
* @param stdClass $oldcourse if this function is called from {@link update_course()}
* this object contains information about the course before update
* @return bool whether there were any changes to the options values
*/
public function update_section_format_options($data) {
global $DB;
$objectSection=new stdClass();
$objectSection->id=$data["id"];
$section_config=$this->get_format_options($objectSection);
//$data = (array)$data;
//if a date was set but we want to remove it
if(!isset($data['daterenducheck']) && !isset($data['daterenducheck2'])){
if(array_key_exists('daterendu', $section_config) && !empty($section_config['daterendu'])){
$data['daterendu']=NULL;
}
else{
unset($data['daterendu']);
}
}
else if(isset($data['daterenducheck2'])){
$data['daterendu']=$data['daterendu2'];
}
if(!isset($data['selectdayscheck'])){
if(isset($data['daysnotif2'])){
$data['daysnotif']=$data["daysnotif2"];
}
if(array_key_exists('daysnotif', $section_config) && $section_config['daysnotif']>-1){
$data['daysnotif']=-1;
}
else{
unset($data['daysnotif']);
}
}
return $this->update_format_options($data, $data['id']);
}
/**
* get_view_url
......@@ -150,3 +344,24 @@
return course_get_format($section->course)->inplace_editable_update_section_name($section, $itemtype, $newvalue);
}
}
/**
* Extends the course administration navigation with the Badges page
*
* @param navigation_node $coursenode
* @param object $course
*/
function iena_add_course_navigation(navigation_node $coursenode, stdClass $course) {
echo "<br><br>br>";
echo "ien add course";
}
function format_iena_add_course_navigation(navigation_node $coursenode, stdClass $course) {
echo "<br><br>br>";
echo "formatien add course";
}