Skip to content
Snippets Groups Projects
Commit 95ff8685 authored by anisa kusumadewi's avatar anisa kusumadewi
Browse files

Fixed Problems:

hiding voteIcon
parent 6e4196d4
No related branches found
No related tags found
No related merge requests found
...@@ -343,12 +343,10 @@ if ($action === 'addComment') { ...@@ -343,12 +343,10 @@ if ($action === 'addComment') {
$visibility = required_param('visibility', PARAM_ALPHA); $visibility = required_param('visibility', PARAM_ALPHA);
$isquestion = required_param('isquestion', PARAM_INT); $isquestion = required_param('isquestion', PARAM_INT);
$pattern = '/<img/'; $imgcounter = substr_count($extracted_content, '<img');
$imgcounter = substr_count($extracted_content, $pattern);
if($imgcounter > get_config('mod_pdfannotator', 'maxfiles')) { if($imgcounter > get_config('mod_pdfannotator', 'maxfiles')) {
throw new \moodle_exception('error:maximalfilenumber', 'pdfannotator'); echo json_encode(['status' => 'error', 'type' => "maxfile"]);
} } else {
// Insert the comment into the mdl_pdfannotator_comments table and get its record id. // Insert the comment into the mdl_pdfannotator_comments table and get its record id.
$comment = pdfannotator_comment::create($documentid, $annotationid, $extracted_content, $visibility, $isquestion, $cm, $context); $comment = pdfannotator_comment::create($documentid, $annotationid, $extracted_content, $visibility, $isquestion, $cm, $context);
$commentid = $comment->uuid; $commentid = $comment->uuid;
...@@ -369,6 +367,8 @@ if ($action === 'addComment') { ...@@ -369,6 +367,8 @@ if ($action === 'addComment') {
} }
} }
}
/* * ******************************* Retrieve information about a specific annotation from db ******************************* */ /* * ******************************* Retrieve information about a specific annotation from db ******************************* */
if ($action === 'getInformation') { // This concerns only textbox and drawing. if ($action === 'getInformation') { // This concerns only textbox and drawing.
...@@ -446,19 +446,19 @@ if ($action === 'editComment') { ...@@ -446,19 +446,19 @@ if ($action === 'editComment') {
$commentid = required_param('commentId', PARAM_INT); $commentid = required_param('commentId', PARAM_INT);
$content = required_param('content', PARAM_RAW); $content = required_param('content', PARAM_RAW);
$regex = "/?time=[0-9]*/"; $regex = ["/?time=[0-9]*|/", '"'];
$extracted_content = str_replace($regex, "", $content); $extracted_content = str_replace($regex, "", $content);
$pattern = '/<img/'; $imgcounter = substr_count($extracted_content, "<img");
$imgcounter = substr_count($extracted_content, $pattern);
if($imgcounter > get_config('mod_pdfannotator', 'maxfiles')) { if($imgcounter > get_config('mod_pdfannotator', 'maxfiles')) {
throw new \moodle_exception('error:maximalfilenumber', 'pdfannotator'); echo json_encode(['status' => 'error:maxfile']);
} } else {
$data = pdfannotator_comment::update($commentid, $extracted_content, $editanypost, $context); $data = pdfannotator_comment::update($commentid, $extracted_content, $editanypost, $context);
echo json_encode($data); echo json_encode($data);
} }
}
/* * ****************************************** Vote for a comment ****************************************** */ /* * ****************************************** Vote for a comment ****************************************** */
if ($action === 'voteComment') { if ($action === 'voteComment') {
......
...@@ -293,6 +293,12 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -293,6 +293,12 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
if(data.status == -1){ if(data.status == -1){
notification.alert(M.util.get_string('error','pdfannotator'),M.util.get_string('missingAnnotation','pdfannotator'),'ok'); notification.alert(M.util.get_string('error','pdfannotator'),M.util.get_string('missingAnnotation','pdfannotator'),'ok');
return false; return false;
} else if (data.status === "error" && data.type === "maxfile") {
notification.addNotification({
message: M.util.get_string('error:maximalfilenumber','pdfannotator'),
type: "error"
});
return false;
} }
return data; return data;
}); });
...@@ -1558,6 +1564,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1558,6 +1564,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
} }
(function(templates, data) { (function(templates, data) {
if(data.comments[0] !== false) {
templates.render('mod_pdfannotator/comment', data) templates.render('mod_pdfannotator/comment', data)
.then(function(html,js){ .then(function(html,js){
if(data.comments.length === 1 && !data.comments[0].isquestion) { if(data.comments.length === 1 && !data.comments[0].isquestion) {
...@@ -1606,6 +1613,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1606,6 +1613,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
} }
}); // add a catch }); // add a catch
}
})(templates, comments); })(templates, comments);
} }
...@@ -1802,6 +1810,11 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to ...@@ -1802,6 +1810,11 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
message: M.util.get_string('successfullyEdited', 'pdfannotator'), message: M.util.get_string('successfullyEdited', 'pdfannotator'),
type: "success" type: "success"
}); });
} else if (data.status === "error:maxfile") {
notification.addNotification({
message: M.util.get_string('error:maximalfilenumber','pdfannotator'),
type: "error"
});
} else { } else {
notification.addNotification({ notification.addNotification({
message: M.util.get_string('error:editComment','pdfannotator'), message: M.util.get_string('error:editComment','pdfannotator'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment