Gitlab CSE Unil

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

maj du pdf par l'étudiant

parent 5abe70d6
...@@ -131,7 +131,8 @@ if ($action == 'loadallpages') { ...@@ -131,7 +131,8 @@ if ($action == 'loadallpages') {
require_capability('mod/assign:grade', $context); require_capability('mod/assign:grade', $context);
$response = new stdClass(); $response = new stdClass();
$grade = $assignment->get_user_grade($userid, true); $grade = $assignment->get_user_grade($userid, true);
$file = document_services::generate_feedback_document($assignment, $userid, $attemptnumber); $refresh = optional_param('refresh', false, PARAM_BOOL);
$file = document_services::generate_feedback_document($assignment, $userid, $attemptnumber, $refresh);
$response->url = ''; $response->url = '';
if ($file) { if ($file) {
......
...@@ -607,7 +607,7 @@ EOD; ...@@ -607,7 +607,7 @@ EOD;
* @param int $attemptnumber (-1 means latest attempt) * @param int $attemptnumber (-1 means latest attempt)
* @return stored_file * @return stored_file
*/ */
public static function generate_feedback_document($assignment, $userid, $attemptnumber) { public static function generate_feedback_document($assignment, $userid, $attemptnumber, $refresh = false) {
$assignment = self::get_assignment_from_param($assignment); $assignment = self::get_assignment_from_param($assignment);
...@@ -630,26 +630,6 @@ EOD; ...@@ -630,26 +630,6 @@ EOD;
$pdf = new pdf(); $pdf = new pdf();
/* $defaultstamps = array('twoway_h.png', 'twoway_v.png');
// Stamp file object.
$filerecord = new stdClass;
$filerecord->component = 'assignfeedback_editpdfplus';
$filerecord->contextid = context_system::instance()->id;
$filerecord->userid = get_admin()->id;
$filerecord->filearea = 'stamps';
$filerecord->filepath = '/';
$filerecord->itemid = 0;
$fs = \get_file_storage();
// Load all default stamps.
foreach ($defaultstamps as $stamp) {
$filerecord->filename = $stamp;
$fs->create_file_from_pathname($filerecord,
$CFG->dirroot . '/mod/assign/feedback/editpdfplus/pix/' . $filerecord->filename);
} */
$fs = \get_file_storage(); $fs = \get_file_storage();
$stamptmpdir = \make_temp_directory('assignfeedback_editpdfplus/stamps/' . self::hash($assignment, $userid, $attemptnumber)); $stamptmpdir = \make_temp_directory('assignfeedback_editpdfplus/stamps/' . self::hash($assignment, $userid, $attemptnumber));
$grade = $assignment->get_user_grade($userid, true, $attemptnumber); $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
...@@ -664,7 +644,9 @@ EOD; ...@@ -664,7 +644,9 @@ EOD;
$pagecount = $pdf->set_pdf($combined); $pagecount = $pdf->set_pdf($combined);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber); $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
page_editor::release_drafts($grade->id); if (!$refresh) {
page_editor::release_drafts($grade->id);
}
$annotation_index = []; $annotation_index = [];
$compteur = 1; $compteur = 1;
...@@ -700,10 +682,16 @@ EOD; ...@@ -700,10 +682,16 @@ EOD;
$pdf->Write(5, $index . " : ", '', false, 'L', false); $pdf->Write(5, $index . " : ", '', false, 'L', false);
if ($annot->answerrequested) { if ($annot->answerrequested) {
$pdf->SetTextColor(255, 0, 0); $pdf->SetTextColor(255, 0, 0);
$pdf->Write(5, "[réponse attendue] ", '', false, 'L', true); $pdf->Write(5, "[question] ", '', false, 'L', true);
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
} }
$pdf->Write(5, $annot->textannot, '', false, 'L', true); $pdf->Write(5, $annot->textannot, '', false, 'L', true);
if ($annot->studentanswer) {
$pdf->SetTextColor(0, 0, 255);
$pdf->Write(5, "[réponse]", '', false, 'L', true);
$pdf->Write(5, $annot->studentanswer, '', false, 'L', true);
$pdf->SetTextColor(0, 0, 0);
}
$pdf->Write(0, "", '', false, 'L', true); $pdf->Write(0, "", '', false, 'L', true);
} }
} }
......
...@@ -250,15 +250,18 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -250,15 +250,18 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
} }
$toolbarCostumdiv.= $axischoice; $toolbarCostumdiv.= $axischoice;
} else { } else {
$toolbaraxis = "<div class='navigation' style='padding-left:10px;margin-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>"; $toolbaraxis = "<div class='navigation' style='padding-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>";
$axis = $widget->axis; $axis = $widget->axis;
foreach ($axis as $ax) { foreach ($axis as $ax) {
$toolbaraxis .= $this->render_toolbar_axis($ax); $toolbaraxis .= $this->render_toolbar_axis($ax);
$toolbaraxis .= "</div><div style='display:inline;margin-left:5px;margin-right:5px;text-align:left;'>"; $toolbaraxis .= "</div><div style='display:inline;margin-left:5px;text-align:left;'>";
} }
$toolbaraxis .= "</div></div>"; $toolbaraxis .= "</div></div>";
$axischoice = html_writer::div(html_writer::select(["Tous","Non traité", "OK","non OK"], 'statutselection', 0, FALSE), 'toolbar ', array('role' => 'toolbar')); $axischoice = html_writer::select(["Tous", "Non traité", "OK", "non OK"], 'statutselection', 0, FALSE);
$toolbaraxis .= $axischoice; //$toolbaraxis .= $axischoice;
$validatebutton = html_writer::tag('button', 'Valider feedback', array('class' => 'button', 'id' => 'student_valide_button'));
$toolbaraxis .= html_writer::div($validatebutton, 'toolbar ', array('role' => 'toolbar'));
$toolbaraxis .= html_writer::div($axischoice, 'toolbar ', array('role' => 'toolbar'));
} }
// Toobars written in reverse order because they are floated right. // Toobars written in reverse order because they are floated right.
...@@ -286,7 +289,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -286,7 +289,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
)); ));
$changesmessage = html_writer::div($changesmessage, 'unsaved-changes'); $changesmessage = html_writer::div($changesmessage, 'unsaved-changes');
$canvas .= $changesmessage; $canvas .= $changesmessage;
$changesmessage2 = html_writer::tag('div', get_string('nodraftchangessaved', 'assignfeedback_editpdfplus'), array( $changesmessage2 = html_writer::tag('div', get_string('nodraftchangessaved', 'assignfeedback_editpdfplus'), array(
'class' => 'assignfeedback_editpdfplus_unsavedchanges_edit warning label label-info' 'class' => 'assignfeedback_editpdfplus_unsavedchanges_edit warning label label-info'
)); ));
......
...@@ -50,7 +50,8 @@ SELECTOR = { ...@@ -50,7 +50,8 @@ SELECTOR = {
CUSTOMTOOLBARS: '.customtoolbar', CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection', AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton', CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
STATUTSELECTOR: '#menustatutselection' STATUTSELECTOR: '#menustatutselection',
STUDENTVALIDATION: '#student_valide_button'
}, },
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)', SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)', SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)',
...@@ -6031,6 +6032,9 @@ EDITOR.prototype = { ...@@ -6031,6 +6032,9 @@ EDITOR.prototype = {
var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR); var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR);
statutselector.on('change', this.update_visu_annotation, this); statutselector.on('change', this.update_visu_annotation, this);
var studentvalidation = this.get_dialogue_element(SELECTOR.STUDENTVALIDATION);
studentvalidation.on('click', this.update_student_feedback, this);
return; return;
} }
...@@ -6074,6 +6078,9 @@ EDITOR.prototype = { ...@@ -6074,6 +6078,9 @@ EDITOR.prototype = {
context: this context: this
}); });
}, },
update_student_feedback: function (){
this.refresh_pdf();
},
update_visu_annotation: function () { update_visu_annotation: function () {
var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked'); var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked');
var statusid = parseInt(statusselector.get('value')) - 1; var statusid = parseInt(statusselector.get('value')) - 1;
...@@ -6535,6 +6542,53 @@ EDITOR.prototype = { ...@@ -6535,6 +6542,53 @@ EDITOR.prototype = {
} }
return false; return false;
}, },
refresh_pdf: function () {
var ajaxurl = AJAXBASE,
config;
config = {
method: 'post',
context: this,
sync: false,
data: {
'sesskey': M.cfg.sesskey,
'action': 'generatepdf',
'userid': this.get('userid'),
'attemptnumber': this.get('attemptnumber'),
'assignmentid': this.get('assignmentid'),
'refresh': true
},
on: {
success: function (tid, response) {
var jsondata;
try {
jsondata = Y.JSON.parse(response.responseText);
if (jsondata.error) {
return new M.core.ajaxException(jsondata);
}
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
duration: 1,
delay: 2,
opacity: 0
}, function () {
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
});
} catch (e) {
return new M.core.exception(e);
}
},
failure: function (tid, response) {
return new M.core.exception(response.responseText);
}
}
};
Y.io(ajaxurl, config);
},
/** /**
* Save all the annotations and comments for the current page. * Save all the annotations and comments for the current page.
* @protected * @protected
......
...@@ -50,7 +50,8 @@ SELECTOR = { ...@@ -50,7 +50,8 @@ SELECTOR = {
CUSTOMTOOLBARS: '.customtoolbar', CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection', AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton', CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
STATUTSELECTOR: '#menustatutselection' STATUTSELECTOR: '#menustatutselection',
STUDENTVALIDATION: '#student_valide_button'
}, },
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)', SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)', SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)',
...@@ -6025,6 +6026,9 @@ EDITOR.prototype = { ...@@ -6025,6 +6026,9 @@ EDITOR.prototype = {
var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR); var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR);
statutselector.on('change', this.update_visu_annotation, this); statutselector.on('change', this.update_visu_annotation, this);
var studentvalidation = this.get_dialogue_element(SELECTOR.STUDENTVALIDATION);
studentvalidation.on('click', this.update_student_feedback, this);
return; return;
} }
...@@ -6068,6 +6072,9 @@ EDITOR.prototype = { ...@@ -6068,6 +6072,9 @@ EDITOR.prototype = {
context: this context: this
}); });
}, },
update_student_feedback: function (){
this.refresh_pdf();
},
update_visu_annotation: function () { update_visu_annotation: function () {
var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked'); var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked');
var statusid = parseInt(statusselector.get('value')) - 1; var statusid = parseInt(statusselector.get('value')) - 1;
...@@ -6526,6 +6533,53 @@ EDITOR.prototype = { ...@@ -6526,6 +6533,53 @@ EDITOR.prototype = {
} }
return false; return false;
}, },
refresh_pdf: function () {
var ajaxurl = AJAXBASE,
config;
config = {
method: 'post',
context: this,
sync: false,
data: {
'sesskey': M.cfg.sesskey,
'action': 'generatepdf',
'userid': this.get('userid'),
'attemptnumber': this.get('attemptnumber'),
'assignmentid': this.get('assignmentid'),
'refresh': true
},
on: {
success: function (tid, response) {
var jsondata;
try {
jsondata = Y.JSON.parse(response.responseText);
if (jsondata.error) {
return new M.core.ajaxException(jsondata);
}
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
duration: 1,
delay: 2,
opacity: 0
}, function () {
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
});
} catch (e) {
return new M.core.exception(e);
}
},
failure: function (tid, response) {
return new M.core.exception(response.responseText);
}
}
};
Y.io(ajaxurl, config);
},
/** /**
* Save all the annotations and comments for the current page. * Save all the annotations and comments for the current page.
* @protected * @protected
......
...@@ -607,6 +607,9 @@ EDITOR.prototype = { ...@@ -607,6 +607,9 @@ EDITOR.prototype = {
var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR); var statutselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR);
statutselector.on('change', this.update_visu_annotation, this); statutselector.on('change', this.update_visu_annotation, this);
var studentvalidation = this.get_dialogue_element(SELECTOR.STUDENTVALIDATION);
studentvalidation.on('click', this.update_student_feedback, this);
return; return;
} }
...@@ -650,6 +653,9 @@ EDITOR.prototype = { ...@@ -650,6 +653,9 @@ EDITOR.prototype = {
context: this context: this
}); });
}, },
update_student_feedback: function (){
this.refresh_pdf();
},
update_visu_annotation: function () { update_visu_annotation: function () {
var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked'); var statusselector = this.get_dialogue_element(SELECTOR.STATUTSELECTOR + ' option:checked');
var statusid = parseInt(statusselector.get('value')) - 1; var statusid = parseInt(statusselector.get('value')) - 1;
...@@ -1111,6 +1117,53 @@ EDITOR.prototype = { ...@@ -1111,6 +1117,53 @@ EDITOR.prototype = {
} }
return false; return false;
}, },
refresh_pdf: function () {
var ajaxurl = AJAXBASE,
config;
config = {
method: 'post',
context: this,
sync: false,
data: {
'sesskey': M.cfg.sesskey,
'action': 'generatepdf',
'userid': this.get('userid'),
'attemptnumber': this.get('attemptnumber'),
'assignmentid': this.get('assignmentid'),
'refresh': true
},
on: {
success: function (tid, response) {
var jsondata;
try {
jsondata = Y.JSON.parse(response.responseText);
if (jsondata.error) {
return new M.core.ajaxException(jsondata);
}
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
duration: 1,
delay: 2,
opacity: 0
}, function () {
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
});
} catch (e) {
return new M.core.exception(e);
}
},
failure: function (tid, response) {
return new M.core.exception(response.responseText);
}
}
};
Y.io(ajaxurl, config);
},
/** /**
* Save all the annotations and comments for the current page. * Save all the annotations and comments for the current page.
* @protected * @protected
......
...@@ -48,7 +48,8 @@ SELECTOR = { ...@@ -48,7 +48,8 @@ SELECTOR = {
CUSTOMTOOLBARS: '.customtoolbar', CUSTOMTOOLBARS: '.customtoolbar',
AXISCUSTOMTOOLBAR: '.menuaxisselection', AXISCUSTOMTOOLBAR: '.menuaxisselection',
CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton', CUSTOMTOOLBARBUTTONS: '.costumtoolbarbutton',
STATUTSELECTOR: '#menustatutselection' STATUTSELECTOR: '#menustatutselection',
STUDENTVALIDATION: '#student_valide_button'
}, },
SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)', SELECTEDBORDERCOLOUR = 'rgba(200, 200, 255, 0.9)',
SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)', SELECTEDFILLCOLOUR = 'rgba(200, 200, 255, 0.5)',
......
Supports Markdown
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