Gitlab CSE Unil

Commit b86b247f authored by M. Chardon's avatar M. Chardon
Browse files

notification étudiant vers enseignant

parent c05b5095
......@@ -61,7 +61,7 @@ class assignaudio_eval_form extends moodleform {
$mform->addGroup($radioarray, 'remediationGroup', get_string('ask_remediation', AUDIOANNOT_MODNAME), array(' '), false);
$mform->setDefault($this::REMEDIATIONFIELD, 0);
$mform->addElement('advcheckbox', assignaudio_eval_form::NOTIFICATIONFIELD, 'Notifier l\'étudiant', ' ', null, array(0, 1));
$mform->addElement('advcheckbox', assignaudio_eval_form::NOTIFICATIONFIELD, get_string('notify_student', AUDIOANNOT_MODNAME), ' ', null, array(0, 1));
$mform->setDefault(assignaudio_eval_form::NOTIFICATIONFIELD, 0);
//action buttons
......
<?php
// 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/>.
/**
* @package mod_audioannotation\form;
* @copyright 2018 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_audioannotation\form;
require_once("$CFG->libdir/formslib.php");
use moodleform;
/**
* Form to edit feedback to an assignement
*
* @package mod_audioannotation
* @copyright 2019 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assignaudio_feedback_form extends moodleform {
const HIDDENTYPE = "hidden";
const NOTIFICATIONFIELD = "notification";
protected function definition() {
$mform = $this->_form;
$mform->_formName = "assignaudio_feedback";
$mform->addElement('advcheckbox', assignaudio_eval_form::NOTIFICATIONFIELD, get_string('notify_teacher', AUDIOANNOT_MODNAME), null, null, array(0, 1));
$mform->setDefault(assignaudio_eval_form::NOTIFICATIONFIELD, 0);
//action buttons
$this->add_action_buttons(false, get_string('sendnotification', AUDIOANNOT_MODNAME));
// Hidden params.
$mform->addElement(assignaudio_eval_form::HIDDENTYPE, 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement(assignaudio_eval_form::HIDDENTYPE, 'assignid');
$mform->setType('assignid', PARAM_INT);
$mform->addElement(assignaudio_eval_form::HIDDENTYPE, 'action', 'savestudentfeedback');
$mform->setType('action', PARAM_ALPHA);
}
}
......@@ -132,6 +132,12 @@ $string['student_notification_message'] = '{$a->coursename}
Some feedbacks have been released on your work.
You can access the assignement following this link: {$a->url}';
$string['teacher_notification_subject'] = '[Moodle] Update audio work';
$string['teacher_notification_message'] = '{$a->coursename}
Some feedbacks have been released on the assignement in {$a->activity} activity.
You can access the assignement following this link: {$a->url}';
$string['partial_delivered'] = 'Partial delivered';
$string['evaluate'] = 'Evaluate';
......@@ -178,6 +184,9 @@ $string['delete_record_question'] = 'Do you realy want to delete this record?';
$string['annot_already_here'] = 'An annotation is already here';
$string['back_help'] = 'Back few seconds before (shortcut: \'B\')';
$string['play_help'] = 'Play/Pause (shortcut: \'space\')';
$string['notify_student'] = 'Notify student';
$string['notify_teacher'] = 'Notify teachers';
$string['sendnotification'] = 'Send';
$string['audioannotation'] = 'Audio annotation';
$string['pluginadministration'] = 'Audio annotation administration';
......
......@@ -134,6 +134,12 @@ $string['student_notification_message'] = '{$a->coursename}
Des corrections à votre travail ont été apportées.
Vous pouvez accéder à votre travail en suivant ce lien : {$a->url}';
$string['teacher_notification_subject'] = '[Moodle] Mise à jour du devoir audio';
$string['teacher_notification_message'] = '{$a->coursename}
Des modifications ont été apportées au devoir dans l\'activité {$a->activity}.
Vous pouvez accéder au travail en suivant ce lien : {$a->url}';
$string['partial_delivered'] = 'Partiellement rendu';
$string['evaluate'] = 'Évaluer';
$string['ajaxsave_messageko'] = 'Erreur à l\'enregistrement';
......@@ -179,6 +185,9 @@ $string['delete_record_question'] = 'Êtes-vous sûr de vouloir supprimer cet en
$string['annot_already_here'] = 'Une annotation existe déjà à cet emplacement';
$string['back_help'] = 'Revenir quelques secondes avant (raccourci: \'B\')';
$string['play_help'] = 'Jouer/Pause (raccourci: \'espace\')';
$string['notify_student'] = 'Notifier l\'étudiant';
$string['notify_teacher'] = 'Notifier l\'équipe enseignante';
$string['sendnotification'] = 'Envoyer';
$string['audioannotation'] = 'Audio annotation';
$string['pluginadministration'] = 'Audio annotation administration';
......
......@@ -30,6 +30,7 @@ defined('MOODLE_INTERNAL') || die();
use \mod_audioannotation\form\assignaudio_form;
use \mod_audioannotation\form\annotation_form;
use \mod_audioannotation\form\assignaudio_eval_form;
use \mod_audioannotation\form\assignaudio_feedback_form;
use \mod_audioannotation\form\tags_form;
use \mod_audioannotation\form\tag_add_form;
use \mod_audioannotation\form\tag_export_form;
......@@ -108,7 +109,7 @@ class audioannotation_assignement {
$formAssign->id = "audioannotation_assign_save";
$formAssign->action = "savefeedback";
$formAssign->assignid = $devoir->id;
//$formAssign->assignid = $devoir->id;
$widget->feedbackform = $formAssign;
$widget->user = $DB->get_record('user', array('id' => $devoir->user), '*', MUST_EXIST);
......@@ -184,6 +185,29 @@ class audioannotation_assignement {
return $renderer->render_student_pairinglist($widget);
}
private function saveStudentFeedback($devoir, $formAssign) {
global $audioannotation, $USER;
$formData = $formAssign->get_data();
if ($formData->notification != '1') {
return true;
}
$urlparams = array('id' => $this->cm->id, 'assignid' => $devoir->id, 'action' => 'viewallsubmission');
$url = new moodle_url('/mod/audioannotation/view.php', $urlparams);
$course = get_course($this->course);
$teachers = get_users_by_capability($this->context, 'mod/audioannotation:seeall');
$messageParams = (object) [
'coursename' => format_string($course->shortname, true),
'activity' => $audioannotation->name,
'url' => $url->out(true)
];
$res = true;
foreach ($teachers as $teacher) {
$res &= email_to_user($teacher, $USER, get_string('teacher_notification_subject', AUDIOANNOT_MODNAME_COMPLETE),
get_string('teacher_notification_message', AUDIOANNOT_MODNAME_COMPLETE, $messageParams));
}
return $res;
}
/**
* Save in database feedback from a teacher for a given assignement
* @global $audioannotation $audioannotation
......@@ -295,10 +319,6 @@ class audioannotation_assignement {
}
if ($action == "savefeedback") {
$formAssign = new assignaudio_eval_form();
//$formAssign->_process_submission("post");
$t1 = $formAssign->is_submitted();
$t2 = $formAssign->is_validated();
$t3 = $formAssign->get_data();
if ($formAssign->is_submitted() && $formAssign->is_validated() && $formAssign->get_data()) {
$this->saveTeacherFeedback($devoir, $formAssign);
}
......@@ -797,6 +817,10 @@ class audioannotation_assignement {
if ($this->getAssignAnnotStatus()) {
$widget->canwrite = true;
}
$formFeedback = new assignaudio_feedback_form();
$formFeedback->set_data(array('id' => $this->cm->id, 'assignid' => $devoir->id));
$formFeedback->action = "savestudentfeedback";
$widget->feedbackform = $formFeedback;
return $renderer->render_student_dashboard_assigment_view($widget);
}
......@@ -830,6 +854,13 @@ class audioannotation_assignement {
return $this->getViewAccessSubmission($renderer, $widget, $devoir);
}
if ($this->getAssignViewStatus() && $action == "savestudentfeedback") {
$formAssign = new assignaudio_feedback_form();
if ($formAssign->is_submitted() && $formAssign->is_validated() && $formAssign->get_data()) {
$this->saveStudentFeedback($devoir, $formAssign);
}
}
if ($this->getAssignPairingStatus() && $action == "pairinglist") {
return $this->getViewListSubmissions($renderer, $widget, true);
}
......
......@@ -301,6 +301,9 @@
<div class="card-body feedback">
{{^eval}}
<div class="d-flex m-b-1">
<div class="w-25 m-r-3">
{{{feedbackform.render}}}
</div>
{{#grade.grade}}
<div class="m-r-3">
<h5>{{# str }} note, audioannotation {{/ str }}:</h5>
......@@ -346,7 +349,7 @@
{{/iswriting}}
{{/eval}}
</nav>
{{> mod_audioannotation/player_markup}}
......
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