@@ -53,6 +53,27 @@ angular.module('mm.addons.mod_assign')
5353 updatePromises = { } ,
5454 lastUpdateHandlersStart ;
5555
56+ /**
57+ * Check if the plugin can be edited in offline for existing submissions.
58+ * In general, this should return false if the plugin uses Moodle filters. The reason is that the app only prefetches
59+ * filtered data, and the user should edit unfiltered data.
60+ *
61+ * @module mm.addons.mod_assign
62+ * @ngdoc method
63+ * @name $mmaModAssignSubmissionDelegate#canPluginEditOffline
64+ * @param {Object } assign Assignment.
65+ * @param {Object } submission Submission.
66+ * @param {Object } plugin Plugin.
67+ * @return {Boolean } Whether the plugin can be edited in offline for existing submissions.
68+ */
69+ self . canPluginEditOffline = function ( assign , submission , plugin ) {
70+ var handler = self . getPluginHandler ( plugin . type ) ;
71+ if ( handler && handler . canEditOffline ) {
72+ return handler . canEditOffline ( assign , submission , plugin ) ;
73+ }
74+ return false ;
75+ } ;
76+
5677 /**
5778 * Clear some temporary data because a submission was cancelled.
5879 *
@@ -381,40 +402,44 @@ angular.module('mm.addons.mod_assign')
381402 * @param {String|Object|Function } handler Must be resolved to an object defining the following properties. Or to a function
382403 * returning an object defining these properties. See {@link $mmUtil#resolveObject}.
383404 * - isEnabled (Boolean|Promise) Whether or not the handler is enabled on a site level.
384- * When using a promise, it should return a boolean.
405+ * When using a promise, it should return a boolean.
385406 * - isEnabledForEdit (Boolean|Promise) Whether or not the handler is enabled for edit on a site
386- * level. When using a promise, it should return a boolean.
387- * This should return true if the plugin has no submission component.
407+ * level. When using a promise, it should return a boolean.
408+ * This should return true if the plugin has no submission component.
388409 * - getDirectiveName(plugin, edit) (String) Optional. Returns the name of the directive to render
389- * the plugin.
410+ * the plugin.
390411 * - prepareSubmissionData(assign, submission, plugin, inputData, pluginData, offline, userId, siteId).
391- * Should prepare and add to pluginData the data to send to server
392- * based in the input. Return promise if async.
412+ * Should prepare and add to pluginData the data to send to server based in the
413+ * input. Return promise if async.
393414 * - copySubmissionData(assign, plugin, pluginData). Function meant to copy a submission. Should
394- * add to pluginData the data to send to server based in the data
395- * in plugin (previous attempt).
415+ * add to pluginData the data to send to server based in the data in plugin
416+ * (previous attempt).
396417 * - hasDataChanged(assign, submission, plugin, inputData) (Promise|Boolean) Check if the
397- * submission data has changed for this plugin.
418+ * submission data has changed for this plugin.
398419 * - clearTmpData(assign, submission, plugin, inputData). Optional. Should clear temporary data
399- * for a cancelled submission.
420+ * for a cancelled submission.
400421 * - getSizeForCopy(assign, plugin). Optional. Get the size of data (in bytes) this plugin will
401- * send to copy a previous attempt.
422+ * send to copy a previous attempt.
402423 * - getSizeForEdit(assign, submission, plugin, inputData). Optional. Get the size of data (in
403- * bytes) this plugin will send to add or edit a submission.
424+ * bytes) this plugin will send to add or edit a submission.
404425 * - getPluginFiles(assign, submission, plugin, siteId). Optional. Get files used by this plugin.
405- * The files returned by this function will be prefetched when the
406- * user prefetches the assign.
426+ * The files returned by this function will be prefetched when the user
427+ * prefetches the assign.
407428 * - prefetch(assign, submission, plugin, siteId). Optional. Prefetch any required data for the
408- * plugin. This should NOT prefetch files. Files to be prefetched
409- * should be returned by the getPluginFiles function.
429+ * plugin. This should NOT prefetch files. Files to be prefetched should be
430+ * returned by the getPluginFiles function.
410431 * - deleteOfflineData(assign, submission, plugin, offlineData, siteId). Optional. Delete any
411- * stored data for the plugin and submission.
432+ * stored data for the plugin and submission.
412433 * - prepareSyncData(assign, submission, plugin, offlineData, pluginData, siteId). Optional. Should
413- * prepare and add to pluginData the data to send to server based in
414- * the offline data stored. This is to perform a synchronziation.
434+ * prepare and add to pluginData the data to send to server based in the offline
435+ * data stored. This is to perform a synchronziation.
415436 * - getPluginName(plugin). Optional. Should return a human readable String. If not present, default
416- * translation will be applied, if translation not found, optional
417- * name will be used.
437+ * translation will be applied. If translation not found, optional name will
438+ * be used.
439+ * - canEditOffline(assign, submission, plugin). Optional. True if the plugin can be edited in
440+ * offline for existing submissions. In general, this should return false if the
441+ * plugin uses Moodle filters. The reason is that the app only prefetches filtered
442+ * data, and the user should edit unfiltered data. Defaults to false.
418443 */
419444 self . registerHandler = function ( addon , pluginType , handler ) {
420445 if ( typeof handlers [ pluginType ] !== 'undefined' ) {
0 commit comments