Skip to content
Snippets Groups Projects
Commit b6908e60 authored by Myriam Delaruelle's avatar Myriam Delaruelle
Browse files

fix section_format_options

parent 7629ef7d
Branches
Tags
No related merge requests found
...@@ -63,10 +63,9 @@ ...@@ -63,10 +63,9 @@
course_create_sections_if_missing($course, 0); course_create_sections_if_missing($course, 0);
$renderer = $PAGE->get_renderer('format_iena'); $renderer = $PAGE->get_renderer('format_iena');
if (!empty($displaysection)) { if (!empty($displaysection)) {
echo "on passe là";
$renderer->print_single_section_page($course, null, null, null, null, $displaysection); $renderer->print_single_section_page($course, null, null, null, null, $displaysection);
} else { } else {
echo "on passe plutôt là, section vide";
$renderer->switch_mode($course); $renderer->switch_mode($course);
......
...@@ -81,4 +81,6 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.'; ...@@ -81,4 +81,6 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
$string['hide_section'] = 'HIDE section '; $string['hide_section'] = 'HIDE section ';
$string['show_section'] = 'SHOW section '; $string['show_section'] = 'SHOW section ';
$string['aboutcourse'] = 'About this course'; $string['aboutcourse'] = 'About this course';
$string['modalite_help'] = 'Pour avoir de l\'aide sur les modalités';
...@@ -81,4 +81,6 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.'; ...@@ -81,4 +81,6 @@ By definition an unnamed section is displayed as <strong>section [N]</strong>.';
$string['hide_section'] = 'CACHER la section '; $string['hide_section'] = 'CACHER la section ';
$string['show_section'] = 'MONTRER la section '; $string['show_section'] = 'MONTRER la section ';
$string['aboutcourse'] = 'À propos de ce cours'; $string['aboutcourse'] = 'À propos de ce cours';
$string['modalite'] = 'Modalité ?';
$string['modalite_help'] = 'Pour avoir de l\'aide sur les modalités';
...@@ -122,6 +122,10 @@ ...@@ -122,6 +122,10 @@
'daterendu'=>array( 'daterendu'=>array(
'label'=>"Date rendu", 'label'=>"Date rendu",
'type'=>PARAM_INT 'type'=>PARAM_INT
),
'daysnotif'=>array(
'label'=>"Notification",
'type'=>PARAM_INT
) )
); );
...@@ -176,34 +180,71 @@ ...@@ -176,34 +180,71 @@
if ($forsection) { if ($forsection) {
$mform->removeElement('presence', false); $mform->removeElement('presence', false);
$mform->removeElement('daterendu', false); $mform->removeElement('daterendu', false);
$mform->removeElement('daysnotif', false);
$sectionclass = new stdClass(); $sectionclass = new stdClass();
$sectionclass->id=optional_param('id', 0, PARAM_INT); $sectionclass->id=optional_param('id', 0, PARAM_INT);
$section_config=$this->get_format_options($sectionclass); $section_config=$this->get_format_options($sectionclass);
$mform->addElement('header', 'nameforyourheaderelement', 'Format hybride');
$radioarray=array(); $radioarray=array();
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Distance', 2); $radioarray[] = $mform->createElement('radio', 'presence', '', 'Distance', 2);
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Présentiel', 1); $radioarray[] = $mform->createElement('radio', 'presence', '', 'Présentiel', 1);
$radioarray[] = $mform->createElement('radio', 'presence', '', 'Aucune', 0); $radioarray[] = $mform->createElement('radio', 'presence', '', 'Aucune', 0);
$mform->addGroup($radioarray, 'Modalité', 'Modalité', array(' '), false); $mform->addGroup($radioarray, 'modalite', 'Modalité', array(' '), false);
$mform->addHelpButton('modalite', 'modalite', 'format_iena');
$datearray=array(); $datearray=array();
$datearray[] = $mform->createElement('date_time_selector', 'daterendu', ''); $datearray[] = $mform->createElement('date_time_selector', 'daterendu', '');
$datearray[] = $mform->createElement('checkbox', 'daterenducheck', 'Activer'); $datearray[] = $mform->createElement('checkbox', 'daterenducheck', 'Activer');
$mform->addGroup($datearray, 'groupdate', 'Date d\'échéance ou date du cours', array(' '), false); $mform->addGroup($datearray, 'groupdate', 'Date d\'échéance', array(' '), false);
//$mform->disabledIf('daterendu', 'daterenducheck');
$mform->disabledIf('groupdate', 'daterenducheck'); $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');
if($section_config && $section_config['presence']){ if($section_config['presence']){
$mform->setDefault('presence', $section_config['presence']); $mform->setDefault('presence', $section_config['presence']);
} }
if($section_config && $section_config['daterendu']){ if($section_config['daterendu']){
$mform->setDefault('daterendu', $section_config['daterendu']); if(isset($section_config['presence']) && $section_config['presence']==2){
$mform->setDefault('daterenducheck', "1"); $mform->setDefault('daterendu', $section_config['daterendu']);
$mform->setDefault('daterenducheck', "1");
}
else if(isset($section_config['presence'])){
$mform->setDefault('daterendu2', $section_config['daterendu']);
$mform->setDefault('daterenducheck2', "1");
}
} }
var_dump($section_config);
if(isset($section_config['daysnotif']) && $section_config['daysnotif'] > -1){
$mform->setDefault('selectdays', $section_config['daysnotif']);
$mform->setDefault('selectdayscheck', "1");
}
//$mform->addElement('html', ' </div></fieldset>');
//$mform->setType('numsections', PARAM_INT); //$mform->setType('numsections', PARAM_INT);
...@@ -211,18 +252,6 @@ ...@@ -211,18 +252,6 @@
//array_unshift($elements, $element); //array_unshift($elements, $element);
} }
// Re-order things.
/*if ($forsection) {
$mform->insertElementBefore($mform->removeElement('automaticenddate', false), 'idnumber');
$mform->disabledIf('enddate', 'automaticenddate', 'checked');
foreach ($elements as $key => $element) {
if ($element->getName() == 'automaticenddate') {
unset($elements[$key]);
}
}
$elements = array_values($elements);
}*/
return $elements; return $elements;
} }
...@@ -242,19 +271,31 @@ ...@@ -242,19 +271,31 @@
public function update_section_format_options($data) { public function update_section_format_options($data) {
global $DB; global $DB;
$data = (array)$data; $objectSection=new stdClass();
$section_config=$this->get_format_options($data['id']); $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 a date was set but we want to remove it
if(!isset($data['daterenducheck'])){ if(!isset($data['daterenducheck']) && !isset($data['daterenducheck2'])){
if(array_key_exists('daterendu', $data)){ if(array_key_exists('daterendu', $section_config) && !empty($section_config['daterendu'])){
$data['daterendu']='NULL'; $data['daterendu']=NULL;
} }
else{ else{
unset($data['daterendu']); unset($data['daterendu']);
} }
} }
unset($data['daterenducheck']); else if(isset($data['daterenducheck2'])){
$data['daterendu']=$data['daterendu2'];
}
if(!isset($data['selectdayscheck'])){
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']); return $this->update_format_options($data, $data['id']);
} }
......
...@@ -187,7 +187,7 @@ class format_iena_renderer extends format_topics_renderer{ ...@@ -187,7 +187,7 @@ class format_iena_renderer extends format_topics_renderer{
} }
} }
if (isset($param_section->daterendu)) { if (isset($param_section->daterendu) && $param_section->daterendu != 0) {
//$section->dateUp = date_create($param_section->date_rendu); //$section->dateUp = date_create($param_section->date_rendu);
$section->dateUp = new DateTime("@$param_section->daterendu"); $section->dateUp = new DateTime("@$param_section->daterendu");
......
...@@ -499,4 +499,10 @@ ul.nav.navbar-nav.ml-auto { ...@@ -499,4 +499,10 @@ ul.nav.navbar-nav.ml-auto {
#title-summary-iena #summary-collapse.collapsing { #title-summary-iena #summary-collapse.collapsing {
height: 4rem; height: 4rem;
}
#days-text{
margin:0 20px 0 5px;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment