Skip to content

Commit

Permalink
QA fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sokunthearithmakara committed Sep 27, 2024
1 parent 8fac5dc commit 3da472f
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 106 deletions.
2 changes: 1 addition & 1 deletion amd/build/editannotation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/editannotation.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/mod_form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/mod_form.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/report.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/report.min.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions amd/src/editannotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,24 +719,24 @@ define(['jquery',
const id = $(this).closest('.annotation').data('id');
const annotation = annotations.find(annotation => annotation.id == id);
try {
Notification.deleteCancel(
M.util.get_string('deleteinteraction', 'mod_interactivevideo'),
M.util.get_string('deleteinteractionconfirm', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo'),
function() {
ctRenderer[annotation.type].deleteAnnotation(annotations, id);
},
null
);
} catch {
Notification.deleteCancelPromise(
M.util.get_string('deleteinteraction', 'mod_interactivevideo'),
M.util.get_string('deleteinteractionconfirm', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo'),
).then(() => {
return ctRenderer[annotation.type].deleteAnnotation(annotations, id);
}).catch(() => {
return;
});
} catch {
Notification.saveCancel(
M.util.get_string('deleteinteraction', 'mod_interactivevideo'),
M.util.get_string('deleteinteractionconfirm', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo'),
function() {
return ctRenderer[annotation.type].deleteAnnotation(annotations, id);
}
);
}


Expand Down
25 changes: 13 additions & 12 deletions amd/src/mod_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,6 @@ define(['jquery', 'core/notification', 'core_form/modalform', 'core/str'], funct
{key: 'delete', component: 'mod_interactivevideo'},
]);
try {
notification.deleteCancel(
strings[0],
strings[1],
strings[2],
function() {
videoinput.val('');
videofile.val('');
videowrapper.empty().hide();
uploadfield.show();
deletefield.hide();
});
} catch {
notification.deleteCancelPromise(
strings[0],
strings[1],
Expand All @@ -353,6 +341,19 @@ define(['jquery', 'core/notification', 'core_form/modalform', 'core/str'], funct
}).catch(() => {
return;
});
} catch {
notification.saveCancel(
strings[0],
strings[1],
strings[2],
function() {
videoinput.val('');
videofile.val('');
videowrapper.empty().hide();
uploadfield.show();
deletefield.hide();
}
);
}
});

Expand Down
97 changes: 48 additions & 49 deletions amd/src/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ const init = (cmid, groupid) => {
const recordid = $(this).data('record');
let $this = $(this);
try {
Notification.deleteCancel(
M.util.get_string('deletecompletion', 'mod_interactivevideo'),
M.util.get_string('areyousureyouwanttoresetthecompletiondata', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo'),
function() {
$.ajax({
Notification.deleteCancelPromise(
M.util.get_string('deletecompletion', 'mod_interactivevideo'),
M.util.get_string('areyousureyouwanttoresetthecompletiondata', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo')
).then(() => {
return $.ajax({
url: M.cfg.wwwroot + '/mod/interactivevideo/ajax.php',
method: 'POST',
dataType: "text",
Expand Down Expand Up @@ -412,51 +412,50 @@ const init = (cmid, groupid) => {
});
}
});
},
null
);
} catch {
Notification.deleteCancelPromise(
M.util.get_string('deletecompletion', 'mod_interactivevideo'),
M.util.get_string('areyousureyouwanttoresetthecompletiondata', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo')
).then(() => {
return $.ajax({
url: M.cfg.wwwroot + '/mod/interactivevideo/ajax.php',
method: 'POST',
dataType: "text",
data: {
action: 'delete_progress_by_id',
recordid,
contextid: M.cfg.contextid,
sesskey: M.cfg.sesskey,
},
success: function(response) {
if (response == 'deleted') {
let targetdata = tabledata.row($this.closest('tr')).data();
targetdata.completionpercentage = 0;
targetdata.timecompleted = 0;
targetdata.xp = 0;
targetdata.timecreated = 0;
targetdata.completeditems = null;
targetdata.completiondetails = null;
targetdata.completionid = null;
tabledata.row($this.closest('tr')).data(targetdata).draw();
addToast(M.util.get_string('completionresetsuccess', 'mod_interactivevideo'), {
type: 'success'
});
}
},
error: function() {
addToast(M.util.get_string('completionreseterror', 'mod_interactivevideo'), {
type: 'error'
}).catch(() => {
return;
});
} catch { // Fallback for older versions of Moodle.
Notification.saveCancel(
M.util.get_string('deletecompletion', 'mod_interactivevideo'),
M.util.get_string('areyousureyouwanttoresetthecompletiondata', 'mod_interactivevideo'),
M.util.get_string('delete', 'mod_interactivevideo'),
function() {
return $.ajax({
url: M.cfg.wwwroot + '/mod/interactivevideo/ajax.php',
method: 'POST',
dataType: "text",
data: {
action: 'delete_progress_by_id',
recordid,
contextid: M.cfg.contextid,
sesskey: M.cfg.sesskey,
},
success: function(response) {
if (response == 'deleted') {
let targetdata = tabledata.row($this.closest('tr')).data();
targetdata.completionpercentage = 0;
targetdata.timecompleted = 0;
targetdata.xp = 0;
targetdata.timecreated = 0;
targetdata.completeditems = null;
targetdata.completiondetails = null;
targetdata.completionid = null;
tabledata.row($this.closest('tr')).data(targetdata).draw();
addToast(M.util.get_string('completionresetsuccess', 'mod_interactivevideo'), {
type: 'success'
});
}
},
error: function() {
addToast(M.util.get_string('completionreseterror', 'mod_interactivevideo'), {
type: 'error'
});
}
});
}
});
}).catch(() => {
return;
});
}
);
}
});

$(document).on('click', 'td .completion-detail', function() {
Expand Down
Loading

0 comments on commit 3da472f

Please sign in to comment.