diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ec365f6e9721e176ec76d32242a7f890d2cbef..bd93de066b9e0c9291fcb526d177855d78c97cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -286,6 +286,34 @@ NaN dans le tableau d'achèvement quand pas d'activité dans la section (divisio Le nombre d'activité est vérifié pour afficher 0 s'il n'y a pas d'activité. +[x] Solved. + +### Paramétrage d'une section (date, modalité, etc.) + +#### 15 + +Notice: Trying to get property 'date_rendu' of non-object in /Applications/MAMP/htdocs/moodle37/course/format/iena/view/view_param_section.php on line 85 + +Et autres erreur du même genre. + +Raison : pas d'enregistrement existant pour cette section, donc le formulaire est rempli sur la base d'un objet qui n'existe pas (===false). + +Des conditions sont ajoutées pour tester la présence de paramètres existants et agit en conséquence pour préremplir ou non le formulaire. + +Suppression de la partie inutilisée du formulaire qui était utilisée pour cacher la section avant une certaine date. + +[x] Solved. + +#### 16 + +Erreurs lors du post du formulaire d'enregistrement des paramètres d'une section. + + + + + + + ## Améliorations ### Suivi des étudiants diff --git a/view/view_param_section.php b/view/view_param_section.php index bd188218c95f95fca67007c5d5d5bcf92393308b..14ab4ed94726ac7602848883e43a8c3fe1d65837 100644 --- a/view/view_param_section.php +++ b/view/view_param_section.php @@ -51,7 +51,7 @@ public function get_content($course, $dataSection) { global $DB, $CFG, $PAGE; - + $mform = $this->_form; $sectionId = required_param('sectionid', PARAM_INT); $courseID = required_param('courseid', PARAM_INT); @@ -82,187 +82,163 @@ $mform->setDefault('summary', array('text' => $description)); $mform->addElement('date_time_selector', 'date_iena', 'Date'); - $dateUp = date_create($dataSection->date_rendu); + if ($dataSection == false) { + $dateUp = date_create(); + } else { + $dateUp = date_create($dataSection->date_rendu); + } $mform->setDefault('date_iena', $dateUp->getTimestamp()); - $mform->addElement('checkbox', 'date_render', get_string('form_not_defined', 'format_iena')); - if (!$dataSection->date_rendu) { - $mform->setDefault('date_render', '1'); + if ($dataSection == false) { + $mform->setDefault('date_render', true); + } else { + $mform->setDefault('date_render', false); } + //Adding elements to the form not included in moodle // <script src=\"".$CFG->wwwroot."/course/format/iena/js/param_section.js\"></script> $content = " - <h1>" . get_string('settings_section_form', 'format_iena') . " : " . $name . "</h1> - <form class=\"form-horizontal\" action=\"param_section.php?courseid=" . $courseID . "§ionid=" . $sectionId . "\" method=\"post\"> - <fieldset> - <div class=\"form-group\">"; - $temp = $mform->toHtml(); + <h1>" . get_string('settings_section_form', 'format_iena') . " : " . $name . "</h1> + <form class=\"form-horizontal\" action=\"param_section.php?courseid=" . $courseID . "§ionid=" . $sectionId . "\" method=\"post\"> + <fieldset> + <div class=\"form-group\">"; + $temp = $mform->toHtml(); //Supprime le <form> - $temp = substr($temp, (strpos($temp, '>') + 1)); - $temp = substr($temp, 0, -7); - - $content .= $temp; - - $content .= " - <div class=\"row\"> - <!-- Multiple Radios --> - <br> - <label class=\"col-md-3 control-label\" for=\"radios\">" . get_string('modalite', 'format_iena') . "</label> - <div class=\"col-md-4\"> - <div class=\"radio\"> + $temp = substr($temp, (strpos($temp, '>') + 1)); + $temp = substr($temp, 0, -7); + + $content .= $temp; + + $content .= " + <div class=\"row\"> + <!-- Multiple Radios --> + <br> + <label class=\"col-md-3 control-label\" for=\"radios\">" . get_string('modalite', 'format_iena') . "</label> + <div class=\"col-md-4\"> + <div class=\"radio\"> <label for=\"radios-0\"> - <input type=\"radio\" name=\"presence\" id=\"presence-0\" value=\"1\" "; - if ($dataSection->presence == 1) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('in_presence', 'format_iena') . " + <input type=\"radio\" name=\"presence\" id=\"presence-0\" value=\"1\" "; + if ($dataSection != false && $dataSection->presence == 1) { + $content .= "checked=\"checked\""; + } + $content .= "> + " . get_string('in_presence', 'format_iena') . " </label> </div> - <div class=\"radio\"> + <div class=\"radio\"> <label for=\"radios-1\"> - <input type=\"radio\" name=\"presence\" id=\"presence-1\" value=\"2\" "; - if ($dataSection->presence == 2) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('not_presence', 'format_iena') . " + <input type=\"radio\" name=\"presence\" id=\"presence-1\" value=\"2\" "; + if ($dataSection != false && $dataSection->presence == 2) { + $content .= "checked=\"checked\""; + } + $content .= "> + " . get_string('not_presence', 'format_iena') . " </label> </div> <div class=\"radio\"> <label for=\"radios-1\"> - <input type=\"radio\" name=\"presence\" id=\"presence-2\" value=\"0\" "; - if (!$dataSection->presence) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('form_not_defined', 'format_iena') . " + <input type=\"radio\" name=\"presence\" id=\"presence-2\" value=\"0\" "; + if ($dataSection == false) { + $content .= "checked=\"checked\""; + } + $content .= "> + " . get_string('form_not_defined', 'format_iena') . " </label> </div> - </div> - </div> - - <!-- Multiple Checkboxes --> - <div class=\"\"> + </div> + </div> + + <!-- Multiple Checkboxes --> + <div class=\"\"> <div class=\"form-group row\"> - <div class=\"col-md-3\"> - <label class=\"control-label\" for=\"checkboxes\">" . get_string('notif', 'format_iena') . "</label> - <p style=\"font-size: 12px;\">" . get_string('notif_summary', 'format_iena') . "</p> - </div> - <div class=\"col-md-6\" style=\"padding-top: 30px;\"> - <div class=\"checkbox\"> - <label for=\"day_before\"> - <input type=\"checkbox\" name=\"day_before\" id=\"day_before\" value=\"1\" "; - if ($dataSection->day_before == 1) $content .= "checked=\"checked\""; - $content .= ">" . get_string('days_before', 'format_iena') . " : - <select class=\"form-control\" style=\"width: 55px; display: inline;\" id=\"nb_days_before\" name =\"nb_days_before\"> - <option "; - if ($dataSection->nb_days_before == 1) $content .= "selected=\"selected\""; - $content .= " >1</option> - <option "; - if ($dataSection->nb_days_before == 2) $content .= "selected=\"selected\""; - $content .= " >2</option> - <option "; - if ($dataSection->nb_days_before == 3) $content .= "selected=\"selected\""; - $content .= " >3</option> - <option "; - if ($dataSection->nb_days_before == 4) $content .= "selected=\"selected\""; - $content .= " >4</option> - <option "; - if ($dataSection->nb_days_before == 5) $content .= "selected=\"selected\""; - $content .= " >5</option> - </select> " . get_string('nb_days_before', 'format_iena') . " - </label> - </div> - <div class=\"checkbox\"> - <label for=\"day_same\"> - <input type=\"checkbox\" name=\"day_same\" id=\"day_same\" value=\"1\" "; - if ($dataSection->day_same == 1) $content .= "checked=\"checked\""; - $content .= ">" . get_string('days_same', 'format_iena') . " - </label> - </div> - <div class=\"checkbox\"> - <label for=\"checkboxes-2\"> - <input type=\"checkbox\" name=\"day_after\" id=\"day_after\" value=\"1\" "; - if ($dataSection->day_after == 1) $content .= "checked=\"checked\""; - $content .= ">" . get_string('days_after', 'format_iena') . " : - <select class=\"form-control\" style=\"width: 55px; display: inline;\" id=\"nb_days_after\" name =\"nb_days_after\"> - <option "; - if ($dataSection->nb_days_after == 1) $content .= "selected=\"selected\""; - $content .= " >1</option> - <option "; - if ($dataSection->nb_days_after == 2) $content .= "selected=\"selected\""; - $content .= " >2</option> - <option "; - if ($dataSection->nb_days_after == 3) $content .= "selected=\"selected\""; - $content .= " >3</option> - <option "; - if ($dataSection->nb_days_after == 4) $content .= "selected=\"selected\""; - $content .= " >4</option> - <option "; - if ($dataSection->nb_days_after == 5) $content .= "selected=\"selected\""; - $content .= " >5</option> - </select> " . get_string('nb_days_after', 'format_iena') . " - </label> - </div> - </div> - + <div class=\"col-md-3\"> + <label class=\"control-label\" for=\"checkboxes\">" . get_string('notif', 'format_iena') . "</label> + <p style=\"font-size: 12px;\">" . get_string('notif_summary', 'format_iena') . "</p> </div> - </div> - - <!-- Multiple Radios --> - <div class=\"row\" style=\"display: none;\"> - <div class=\"form-group\"> - <div class=\"col-md-3\"> - <label class=\" control-label\" for=\"radios\">" . get_string('hide_section', 'format_iena') . "</label> - <p style=\"font-size: 12px;\">" . get_string('hide_section_summary', 'format_iena') . "</p> - </div> - <div class=\"col-md-4\"> - <div class=\"radio\"> - <label for=\"radios-0\"> - <input type=\"radio\" name=\"hide\" id=\"hide-0\" value=\"1\" "; - if ($dataSection->hide == 1 || !$dataSection->hide) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('hide_option_1', 'format_iena') . " + <div class=\"col-md-6\" style=\"padding-top: 30px;\"> + <div class=\"checkbox\"> + <label for=\"day_before\"> + <input type=\"checkbox\" name=\"day_before\" id=\"day_before\" value=\"1\" "; + if ($dataSection != false && $dataSection->day_before == 1) $content .= "checked=\"checked\""; + $content .= ">" . get_string('days_before', 'format_iena') . " : + <select class=\"form-control\" style=\"width: 55px; display: inline;\" id=\"nb_days_before\" name =\"nb_days_before\"> + <option "; + if ( ($dataSection != false && $dataSection->nb_days_before == 1) || $dataSection == false ) $content .= "selected=\"selected\""; + $content .= " >1</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_before == 2) $content .= "selected=\"selected\""; + $content .= " >2</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_before == 3) $content .= "selected=\"selected\""; + $content .= " >3</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_before == 4) $content .= "selected=\"selected\""; + $content .= " >4</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_before == 5) $content .= "selected=\"selected\""; + $content .= " >5</option> + </select> " . get_string('nb_days_before', 'format_iena') . " </label> </div> - <div class=\"radio\"> - <label for=\"radios-1\"> - <input type=\"radio\" name=\"hide\" id=\"hide-1\" value=\"2\" "; - if ($dataSection->hide == 2) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('hide_option_2', 'format_iena') . " + <div class=\"checkbox\"> + <label for=\"day_same\"> + <input type=\"checkbox\" name=\"day_same\" id=\"day_same\" value=\"1\" "; + if ($dataSection != false && $dataSection->day_same == 1) $content .= "checked=\"checked\""; + $content .= ">" . get_string('days_same', 'format_iena') . " </label> </div> - <div class=\"radio\"> - <label for=\"radios-2\"> - <input type=\"radio\" name=\"hide\" id=\"hide-2\" value=\"3\" "; - if ($dataSection->hide == 3) $content .= "checked=\"checked\""; - $content .= "> - " . get_string('hide_option_3', 'format_iena') . " + <div class=\"checkbox\"> + <label for=\"checkboxes-2\"> + <input type=\"checkbox\" name=\"day_after\" id=\"day_after\" value=\"1\" "; + if ($dataSection != false && $dataSection->day_after == 1) $content .= "checked=\"checked\""; + $content .= ">" . get_string('days_after', 'format_iena') . " : + <select class=\"form-control\" style=\"width: 55px; display: inline;\" id=\"nb_days_after\" name =\"nb_days_after\"> + <option "; + if ( ($dataSection != false && $dataSection->nb_days_after == 1) || $dataSection == false ) $content .= "selected=\"selected\""; + $content .= " >1</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_after == 2) $content .= "selected=\"selected\""; + $content .= " >2</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_after == 3) $content .= "selected=\"selected\""; + $content .= " >3</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_after == 4) $content .= "selected=\"selected\""; + $content .= " >4</option> + <option "; + if ($dataSection != false && $dataSection->nb_days_after == 5) $content .= "selected=\"selected\""; + $content .= " >5</option> + </select> " . get_string('nb_days_after', 'format_iena') . " </label> </div> - </div> - </div> - </div> - "; - $link_annuler = $CFG->wwwroot . "/course/view.php?id=" . $courseID; - $content .= '<div class=""> + </div> - <button type="submit" class="btn btn-primary">' . get_string('save', 'format_iena') . '</button> + </div> + </div> + "; + $link_annuler = $CFG->wwwroot . "/course/view.php?id=" . $courseID; + $content .= '<div class=""> + <button type="submit" class="btn btn-primary">' . get_string('save', 'format_iena') . '</button> - <a href=\' ' . $link_annuler . ' \' class=\'btn btn-secondary\'>' . get_string('cancel', 'format_iena') . '</a> - - </div> - </fieldset> - '; - $content .= "</form> - <script type=\"text/javascript\" charset=\"utf8\" src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script> - <script> - $(document).ready(function () { - $('.fdescription').hide(); - }); - </script> -"; - - return $content; - } - - } \ No newline at end of file + + <a href=\' ' . $link_annuler . ' \' class=\'btn btn-secondary\'>' . get_string('cancel', 'format_iena') . '</a> + + </div> + </fieldset> + '; + $content .= "</form> + <script type=\"text/javascript\" charset=\"utf8\" src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script> + <script> + $(document).ready(function () { + $('.fdescription').hide(); + }); + </script> + "; + + return $content; + } + + } \ No newline at end of file