Gitlab CSE Unil

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

visu étudiant manipulation statut ok

parent adf905b3
...@@ -95,9 +95,9 @@ if ($action == 'loadallpages') { ...@@ -95,9 +95,9 @@ if ($action == 'loadallpages') {
array_push($response->pages, $page); array_push($response->pages, $page);
} }
$tools = page_editor::get_tools(); $tools = page_editor::get_tools(null);
$typetools = page_editor::get_typetools(); $typetools = page_editor::get_typetools(null);
$axis = page_editor::get_axis(); $axis = page_editor::get_axis(null);
$response->tools = $tools; $response->tools = $tools;
$response->typetools = $typetools; $response->typetools = $typetools;
$response->axis = $axis; $response->axis = $axis;
...@@ -187,5 +187,23 @@ if ($action == 'loadallpages') { ...@@ -187,5 +187,23 @@ if ($action == 'loadallpages') {
$result = $result && page_editor::unrelease_drafts($grade->id); $result = $result && page_editor::unrelease_drafts($grade->id);
echo json_encode($result); echo json_encode($result);
die(); die();
} else if ($action == 'updatestudentview') {
require_capability('mod/assign:grade', $context);
$response = new stdClass();
$response->errors = array();
$grade = $assignment->get_user_grade($userid, true);
$pagejson = required_param('page', PARAM_RAW);
$page = json_decode($pagejson);
$index = required_param('index', PARAM_INT);
$added = page_editor::update_annotations_status($grade->id, $page->annotations);
if ($added != count($page->annotations)) {
array_push($response->errors, get_string('couldnotsavepage', 'assignfeedback_editpdfplus', $index + 1));
}
echo json_encode($response);
die();
} }
...@@ -78,9 +78,14 @@ class annotation { ...@@ -78,9 +78,14 @@ class annotation {
/** @var string borderstyle */ /** @var string borderstyle */
public $borderstyle = ''; public $borderstyle = '';
/** @var int $parent_annot */ /** @var int parent_annot */
public $parent_annot = 0; public $parent_annot = 0;
/** @var int answerrequested */
public $answerrequested = 0; public $answerrequested = 0;
/** @var int studentstatus */
public $studentstatus = 0;
/** /**
* Convert a compatible stdClass into an instance of this class. * Convert a compatible stdClass into an instance of this class.
......
...@@ -295,6 +295,21 @@ class page_editor { ...@@ -295,6 +295,21 @@ class page_editor {
return $added; return $added;
} }
public static function update_annotations_status($gradeid, $annotations) {
global $DB;
$added = 0;
foreach ($annotations as $recordtmp) {
$record = page_editor::get_annotation($recordtmp->id);
$old = $record->studentstatus;
$record->studentstatus = $recordtmp->studentstatus;
$DB->update_record('assignfeedback_editpp_annot', $record);
$added++;
debugging($recordtmp->id . ' - ' . $record->id . ' - ' .$old. ' - ' . $recordtmp->studentstatus . ' - ' . $record->studentstatus);
}
return $added;
}
/** /**
* Get a single annotation by id. * Get a single annotation by id.
* @param int $annotationid * @param int $annotationid
......
...@@ -283,9 +283,14 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -283,9 +283,14 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$changesmessage = html_writer::tag('div', get_string('draftchangessaved', 'assignfeedback_editpdfplus'), array( $changesmessage = html_writer::tag('div', get_string('draftchangessaved', 'assignfeedback_editpdfplus'), array(
'class' => 'assignfeedback_editpdfplus_unsavedchanges warning label label-info' 'class' => 'assignfeedback_editpdfplus_unsavedchanges warning label label-info'
)); ));
$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(
'class' => 'assignfeedback_editpdfplus_unsavedchanges_edit warning label label-info'
));
$changesmessage2 = html_writer::div($changesmessage2, 'unsaved-changes');
$canvas .= $changesmessage2;
$body .= $canvas; $body .= $canvas;
......
...@@ -101,4 +101,5 @@ $string['white'] = 'White'; ...@@ -101,4 +101,5 @@ $string['white'] = 'White';
$string['yellow'] = 'Yellow'; $string['yellow'] = 'Yellow';
$string['yellowlemon'] = 'Lemon yellow'; $string['yellowlemon'] = 'Lemon yellow';
$string['draftchangessaved'] = 'Draft annotations saved'; $string['draftchangessaved'] = 'Draft annotations saved';
$string['nodraftchangessaved'] = 'Changes saved';
$string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation'; $string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation';
...@@ -58,16 +58,19 @@ ...@@ -58,16 +58,19 @@
padding: 0px; padding: 0px;
} }
.assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges.haschanges{ .assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges.haschanges,
.assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges_edit.haschanges{
display: inline-block; display: inline-block;
} }
.assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges { .assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges,
.assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges_edit{
display: none; display: none;
position: absolute; position: absolute;
left: 20px; left: 20px;
top: 60px; top: 60px;
} }
.dir-rtl .assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges { .dir-rtl .assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges,
.dir-rtl .assignfeedback_editpdfplus_widget .assignfeedback_editpdfplus_unsavedchanges_edit{
float: right; float: right;
} }
.yui3-colourpicker-hidden, .yui3-colourpicker-hidden,
...@@ -449,4 +452,14 @@ ul.assignfeedback_editpdfplus_menu { ...@@ -449,4 +452,14 @@ ul.assignfeedback_editpdfplus_menu {
font-size:12px; font-size:12px;
color:inherit; color:inherit;
cursor:default; cursor:default;
}
.radio-inline {
cursor: pointer;
display: inline-block;
font-weight: 400;
margin-bottom: 0;
position: relative;
vertical-align: middle;
font-size: 12px;
} }
\ No newline at end of file
...@@ -43,6 +43,7 @@ SELECTOR = { ...@@ -43,6 +43,7 @@ SELECTOR = {
DELETEANNOTATIONBUTTON: '.deleteannotationbutton', DELETEANNOTATIONBUTTON: '.deleteannotationbutton',
UNSAVEDCHANGESDIV: '.assignfeedback_editpdfplus_unsavedchanges', UNSAVEDCHANGESDIV: '.assignfeedback_editpdfplus_unsavedchanges',
UNSAVEDCHANGESINPUT: 'input[name="assignfeedback_editpdfplus_haschanges"]', UNSAVEDCHANGESINPUT: 'input[name="assignfeedback_editpdfplus_haschanges"]',
UNSAVEDCHANGESDIVEDIT: '.assignfeedback_editpdfplus_unsavedchanges_edit',
STAMPSBUTTON: '.currentstampbutton', STAMPSBUTTON: '.currentstampbutton',
DIALOGUE: '.' + CSS.DIALOGUE, DIALOGUE: '.' + CSS.DIALOGUE,
CUSTOMTOOLBARID: '#toolbaraxis', CUSTOMTOOLBARID: '#toolbaraxis',
...@@ -572,10 +573,8 @@ M.assignfeedback_editpdfplus.drawable = DRAWABLE; ...@@ -572,10 +573,8 @@ M.assignfeedback_editpdfplus.drawable = DRAWABLE;
var ANNOTATION = function (config) { var ANNOTATION = function (config) {
ANNOTATION.superclass.constructor.apply(this, [config]); ANNOTATION.superclass.constructor.apply(this, [config]);
}; };
ANNOTATION.NAME = "annotation"; ANNOTATION.NAME = "annotation";
ANNOTATION.ATTRS = {}; ANNOTATION.ATTRS = {};
Y.extend(ANNOTATION, Y.Base, { Y.extend(ANNOTATION, Y.Base, {
/** /**
* Reference to M.assignfeedback_editpdfplus.editor. * Reference to M.assignfeedback_editpdfplus.editor.
...@@ -668,6 +667,7 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -668,6 +667,7 @@ Y.extend(ANNOTATION, Y.Base, {
cartridgex: 0, cartridgex: 0,
cartridgey: 0, cartridgey: 0,
answerrequested: 0, answerrequested: 0,
studentstatus: 0,
/** /**
* Initialise the annotation. * Initialise the annotation.
* *
...@@ -719,6 +719,7 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -719,6 +719,7 @@ Y.extend(ANNOTATION, Y.Base, {
this.parent_annot = config.parent_annot; this.parent_annot = config.parent_annot;
this.id = config.id; this.id = config.id;
this.answerrequested = parseInt(config.answerrequested, 10) || 0; this.answerrequested = parseInt(config.answerrequested, 10) || 0;
this.studentstatus = parseInt(config.studentstatus, 10) || 0;
} }
this.tooltypefamille = this.editor.typetools[this.tooltype.type]; this.tooltypefamille = this.editor.typetools[this.tooltype.type];
}, },
...@@ -770,9 +771,82 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -770,9 +771,82 @@ Y.extend(ANNOTATION, Y.Base, {
parent_annot: this.parent_annot, parent_annot: this.parent_annot,
divcartridge: this.divcartridge, divcartridge: this.divcartridge,
parent_annot_div: '', parent_annot_div: '',
answerrequested: parseInt(this.answerrequested) answerrequested: parseInt(this.answerrequested),
studentstatus: parseInt(this.studentstatus)
};
},
light_clean: function () {
return {
id: this.id,
studentstatus: parseInt(this.studentstatus)
}; };
}, },
/**
* Draw a selection around this annotation if it is selected.
* @public
* @method draw_highlight
* @return M.assignfeedback_editpdfplus.drawable
*/
draw_highlight: function () {
var bounds,
drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
offsetcanvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS).getXY(),
shape;
if (this.editor.currentannotation === this) {
// Draw a highlight around the annotation.
bounds = new M.assignfeedback_editpdfplus.rect();
bounds.bound([new M.assignfeedback_editpdfplus.point(this.x - 10, this.y - 10),
new M.assignfeedback_editpdfplus.point(this.endx + 10, this.endy + 10)]);
shape = this.editor.graphic.addShape({
type: Y.Rect,
width: bounds.width,
height: bounds.height,
stroke: {
weight: STROKEWEIGHT,
color: SELECTEDBORDERCOLOUR
},
fill: {
color: SELECTEDFILLCOLOUR
},
x: bounds.x,
y: bounds.y
});
this.drawable.shapes.push(shape);
shape.editor = this.editor;
shape.on('clickoutside', Y.rbind(this.editor.redraw_annotation, this.editor));
// Add a delete X to the annotation.
var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'),
deletelink = Y.Node.create('<a href="#" role="button"></a>');
deleteicon.setAttrs({
'alt': M.util.get_string('deleteannotation', 'assignfeedback_editpdfplus')
});
deleteicon.setStyles({
'backgroundColor': 'white'
});
deletelink.addClass('deleteannotationbutton');
deletelink.append(deleteicon);
drawingregion.append(deletelink);
deletelink.setData('annotation', this);
deletelink.setStyle('zIndex', '200');
deletelink.on('click', this.remove, this);
deletelink.on('key', this.remove, 'space,enter', this);
deletelink.setX(offsetcanvas[0] + bounds.x + bounds.width - 18);
deletelink.setY(offsetcanvas[1] + bounds.y + bounds.height - 18);
this.drawable.nodes.push(deletelink);
}
return this.drawable;
},
/**
* Draw an annotation
* @public
* @method draw
* @return M.assignfeedback_editpdfplus.drawable|false
*/
draw: function () {
// Should be overridden by the subclass.
this.draw_highlight();
return this.drawable;
},
get_color: function () { get_color: function () {
var color = ANNOTATIONCOLOUR[this.colour]; var color = ANNOTATIONCOLOUR[this.colour];
if (!color) { if (!color) {
...@@ -899,7 +973,6 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -899,7 +973,6 @@ Y.extend(ANNOTATION, Y.Base, {
divconteneurdisplay.append(inputvalref); divconteneurdisplay.append(inputvalref);
divconteneurdisplay.append(inputonof); divconteneurdisplay.append(inputonof);
divconteneurdisplay.append(this.get_input_question()); divconteneurdisplay.append(this.get_input_question());
var readonly = this.editor.get('readonly'); var readonly = this.editor.get('readonly');
if (!readonly) { if (!readonly) {
divconteneurdisplay.append(this.get_button_visibility_left()); divconteneurdisplay.append(this.get_button_visibility_left());
...@@ -910,10 +983,30 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -910,10 +983,30 @@ Y.extend(ANNOTATION, Y.Base, {
divconteneurdisplay.append(this.get_button_question()); divconteneurdisplay.append(this.get_button_question());
} }
divconteneurdisplay.append(this.get_button_remove()); divconteneurdisplay.append(this.get_button_remove());
} else {
divconteneurdisplay.append(this.get_button_student_status());
} }
return divconteneurdisplay; return divconteneurdisplay;
}, },
get_button_student_status: function () {
var buttonstatus1 = '<label style="padding-left:20px;" class="radio-inline"><input type="radio" name="' + this.divcartridge + '_status" value=0 >non traité</label>';
var buttonstatus2 = '<label class="radio-inline"><input type="radio" name="' + this.divcartridge + '_status" value=1 ><img style="width:15px;" src=\'' + M.util.image_url('tick', 'assignfeedback_editpdfplus') + '\' /></label>';
var buttonstatus3 = '<label class="radio-inline"><input type="radio" name="' + this.divcartridge + '_status" value=2 ><img style="width:15px;" src=\'' + M.util.image_url('cross', 'assignfeedback_editpdfplus') + '\' /></label> ';
var buttonstatus1display = Y.Node.create(buttonstatus1);
var buttonstatus2display = Y.Node.create(buttonstatus2);
var buttonstatus3display = Y.Node.create(buttonstatus3);
buttonstatus1display.on('click', this.change_status, this, 0);
buttonstatus2display.on('click', this.change_status, this, 1);
buttonstatus3display.on('click', this.change_status, this, 2);
var buttonstatusdisplay = Y.Node.create("<div id='" + this.divcartridge + "_radioContainer' style='display:inline;'></div>");
buttonstatusdisplay.append(buttonstatus1display);
buttonstatusdisplay.append(buttonstatus2display);
buttonstatusdisplay.append(buttonstatus3display);
return buttonstatusdisplay;
},
get_button_visibility_right: function () { get_button_visibility_right: function () {
var buttonvisibility = "<button id='" + this.divcartridge + "_buttonedit_right' "; var buttonvisibility = "<button id='" + this.divcartridge + "_buttonedit_right' ";
buttonvisibility += "><img src='"; buttonvisibility += "><img src='";
...@@ -978,6 +1071,7 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -978,6 +1071,7 @@ Y.extend(ANNOTATION, Y.Base, {
//var valref = this.editor.get_dialogue_element('#' + this.divcartridge + "_valref").get('value'); //var valref = this.editor.get_dialogue_element('#' + this.divcartridge + "_valref").get('value');
var buttonplusr = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonedit_right"); var buttonplusr = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonedit_right");
var buttonplusl = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonedit_left"); var buttonplusl = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonedit_left");
var buttonstatus = this.editor.get_dialogue_element('#' + this.divcartridge + "_radioContainer");
if (interrupt) { if (interrupt) {
if (interrupt.get('value') === '1') { if (interrupt.get('value') === '1') {
if (buttonplusr) { if (buttonplusr) {
...@@ -1009,6 +1103,9 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1009,6 +1103,9 @@ Y.extend(ANNOTATION, Y.Base, {
buttonplusr.hide(); buttonplusr.hide();
buttonplusl.hide(); buttonplusl.hide();
} }
if (buttonstatus) {
buttonstatus.hide();
}
this.apply_question_status(); this.apply_question_status();
}, },
get_text_to_diplay_in_cartridge: function () { get_text_to_diplay_in_cartridge: function () {
...@@ -1055,6 +1152,11 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1055,6 +1152,11 @@ Y.extend(ANNOTATION, Y.Base, {
this.apply_question_status(); this.apply_question_status();
this.editor.save_current_page(); this.editor.save_current_page();
}, },
change_status: function (e, idclick) {
this.studentstatus = idclick;
this.editor.save_current_page_edited();
this.hide_edit();
},
apply_question_status: function () { apply_question_status: function () {
var buttonquestion = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonquestion"); var buttonquestion = this.editor.get_dialogue_element('#' + this.divcartridge + "_buttonquestion");
var questionvalue = this.editor.get_dialogue_element('#' + this.divcartridge + "_question"); var questionvalue = this.editor.get_dialogue_element('#' + this.divcartridge + "_question");
...@@ -1073,93 +1175,16 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1073,93 +1175,16 @@ Y.extend(ANNOTATION, Y.Base, {
}, },
move_cartridge_begin: function (e) { move_cartridge_begin: function (e) {
e.preventDefault(); e.preventDefault();
var canvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS), var canvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
clientpoint = new M.assignfeedback_editpdfplus.point(e.clientX + canvas.get('docScrollX'), clientpoint = new M.assignfeedback_editpdfplus.point(e.clientX + canvas.get('docScrollX'),
e.clientY + canvas.get('docScrollY')), e.clientY + canvas.get('docScrollY')),
point = this.editor.get_canvas_coordinates(clientpoint); point = this.editor.get_canvas_coordinates(clientpoint);
this.oldx = point.x; this.oldx = point.x;
this.oldy = point.y; this.oldy = point.y;
var divcartridge = this.editor.get_dialogue_element('#' + this.divcartridge + "_cartridge"); var divcartridge = this.editor.get_dialogue_element('#' + this.divcartridge + "_cartridge");
divcartridge.on('mousemove', this.move_cartridge_continue, this); divcartridge.on('mousemove', this.move_cartridge_continue, this);
divcartridge.on('mouseup', this.move_cartridge_stop, this); divcartridge.on('mouseup', this.move_cartridge_stop, this);
}, },
/**
* Draw a selection around this annotation if it is selected.
* @public
* @method draw_highlight
* @return M.assignfeedback_editpdfplus.drawable
*/
draw_highlight: function () {
var bounds,
drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
offsetcanvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS).getXY(),
shape;
if (this.editor.currentannotation === this) {
// Draw a highlight around the annotation.
bounds = new M.assignfeedback_editpdfplus.rect();
bounds.bound([new M.assignfeedback_editpdfplus.point(this.x - 10, this.y - 10),
new M.assignfeedback_editpdfplus.point(this.endx + 10, this.endy + 10)]);
shape = this.editor.graphic.addShape({
type: Y.Rect,
width: bounds.width,
height: bounds.height,
stroke: {
weight: STROKEWEIGHT,
color: SELECTEDBORDERCOLOUR
},
fill: {
color: SELECTEDFILLCOLOUR
},
x: bounds.x,
y: bounds.y
});
this.drawable.shapes.push(shape);
shape.editor = this.editor;
shape.on('clickoutside', Y.rbind(this.editor.redraw_annotation, this.editor));
// Add a delete X to the annotation.
var deleteicon = Y.Node.create('<img src="' + M.util.image_url('trash', 'assignfeedback_editpdfplus') + '"/>'),
deletelink = Y.Node.create('<a href="#" role="button"></a>');
deleteicon.setAttrs({
'alt': M.util.get_string('deleteannotation', 'assignfeedback_editpdfplus')
});
deleteicon.setStyles({
'backgroundColor': 'white'
});
deletelink.addClass('deleteannotationbutton');
deletelink.append(deleteicon);
drawingregion.append(deletelink);
deletelink.setData('annotation', this);
deletelink.setStyle('zIndex', '200');
deletelink.on('click', this.remove, this);
deletelink.on('key', this.remove, 'space,enter', this);
deletelink.setX(offsetcanvas[0] + bounds.x + bounds.width - 18);
deletelink.setY(offsetcanvas[1] + bounds.y + bounds.height - 18);
this.drawable.nodes.push(deletelink);
}
return this.drawable;
},
/**
* Draw an annotation
* @public
* @method draw
* @return M.assignfeedback_editpdfplus.drawable|false
*/
draw: function () {
// Should be overridden by the subclass.
this.draw_highlight();
return this.drawable;
},
draw_catridge: function (edit) { draw_catridge: function (edit) {
return true; return true;
}, },
...@@ -1168,10 +1193,21 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1168,10 +1193,21 @@ Y.extend(ANNOTATION, Y.Base, {
var divprincipale = this.editor.get_dialogue_element('#' + this.divcartridge); var divprincipale = this.editor.get_dialogue_element('#' + this.divcartridge);
var divdisplay = this.editor.get_dialogue_element('#' + this.divcartridge + "_display"); var divdisplay = this.editor.get_dialogue_element('#' + this.divcartridge + "_display");
var divvisu = this.editor.get_dialogue_element('#' + this.divcartridge + "_visu"); var divvisu = this.editor.get_dialogue_element('#' + this.divcartridge + "_visu");
var buttonstatus = this.editor.get_dialogue_element('#' + this.divcartridge + "_radioContainer");
var studentstatusinput = Y.all("[name=" + this.divcartridge + "_status]");
divdisplay.hide(); divdisplay.hide();
divvisu.show(); divvisu.show();
for (var i = 0; i < studentstatusinput.size(); i++) {
var tmp = studentstatusinput.item(i);
if (parseInt(tmp.get('value')) === this.studentstatus) {
tmp.set('checked', true);
} else {
tmp.set('checked', false);
}
}
buttonstatus.show();
buttonstatus.set('style', 'display:inline;color:' + this.get_color_cartridge() + ';');
divprincipale.setStyle('z-index', 1000); divprincipale.setStyle('z-index', 1000);
this.disabled_canvas_event(); this.disabled_canvas_event();
divprincipale.on('clickoutside', this.hide_edit, this); divprincipale.on('clickoutside', this.hide_edit, this);
} }
...@@ -1208,7 +1244,6 @@ Y.extend(ANNOTATION, Y.Base, { ...@@ -1208,7 +1244,6 @@ Y.extend(ANNOTATION, Y.Base, {
buttonremove.show(); buttonremove.show();
divprincipale.setStyle('z-index', 1000); divprincipale.