Merge pull request #1822 from albertgasset/MOBILE-2915

Mobile 2915
main
Juan Leyva 2019-03-28 12:12:42 +01:00 committed by GitHub
commit ac71d3f766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 3 deletions

View File

@ -344,6 +344,7 @@
"addon.mod_assign_submission_comments.pluginname": "assignsubmission_comments",
"addon.mod_assign_submission_file.pluginname": "assignsubmission_file",
"addon.mod_assign_submission_onlinetext.pluginname": "assignsubmission_onlinetext",
"addon.mod_assign_submission_onlinetext.wordlimitexceeded": "assignsubmission_onlinetext",
"addon.mod_book.errorchapter": "book",
"addon.mod_book.modulenameplural": "book",
"addon.mod_book.toc": "book",

View File

@ -379,9 +379,13 @@ export class AddonModAssignProvider {
*
* @param {any} assign Assign.
* @param {any} attempt Attempt.
* @return {any} Submission object.
* @return {any} Submission object or null.
*/
getSubmissionObjectFromAttempt(assign: any, attempt: any): any {
if (!attempt) {
return null;
}
return assign.teamsubmission ? attempt.teamsubmission : attempt.submission;
}

View File

@ -1,3 +1,4 @@
{
"pluginname": "Online text submissions"
"pluginname": "Online text submissions",
"wordlimitexceeded": "The word limit for this assignment is {{$a.limit}} words and you are attempting to submit {{$a.count}} words. Please review your submission and try again."
}

View File

@ -14,6 +14,7 @@
// limitations under the License.
import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreSitesProvider } from '@providers/sites';
import { CoreWSProvider } from '@providers/ws';
import { CoreTextUtilsProvider } from '@providers/utils/text';
@ -31,7 +32,7 @@ export class AddonModAssignSubmissionOnlineTextHandler implements AddonModAssign
name = 'AddonModAssignSubmissionOnlineTextHandler';
type = 'onlinetext';
constructor(private sitesProvider: CoreSitesProvider, private wsProvider: CoreWSProvider,
constructor(private translate: TranslateService, private sitesProvider: CoreSitesProvider, private wsProvider: CoreWSProvider,
private textUtils: CoreTextUtilsProvider, private assignProvider: AddonModAssignProvider,
private assignOfflineProvider: AddonModAssignOfflineProvider, private assignHelper: AddonModAssignHelperProvider) { }
@ -238,6 +239,19 @@ export class AddonModAssignSubmissionOnlineTextHandler implements AddonModAssign
let text = this.getTextToSubmit(plugin, inputData);
// Check word limit.
const configs = this.assignHelper.getPluginConfig(assign, 'assignsubmission', plugin.type);
if (parseInt(configs.wordlimitenabled, 10)) {
const words = this.textUtils.countWords(text);
const wordlimit = parseInt(configs.wordlimit, 10);
if (words > wordlimit) {
const params = {$a: {count: words, limit: wordlimit}};
const message = this.translate.instant('addon.mod_assign_submission_onlinetext.wordlimitexceeded', params);
return Promise.reject(message);
}
}
// Add some HTML to the text if needed.
text = this.textUtils.formatHtmlLines(text);

View File

@ -344,6 +344,7 @@
"addon.mod_assign_submission_comments.pluginname": "Submission comments",
"addon.mod_assign_submission_file.pluginname": "File submissions",
"addon.mod_assign_submission_onlinetext.pluginname": "Online text submissions",
"addon.mod_assign_submission_onlinetext.wordlimitexceeded": "The word limit for this assignment is {{$a.limit}} words and you are attempting to submit {{$a.count}} words. Please review your submission and try again.",
"addon.mod_book.errorchapter": "Error reading chapter of book.",
"addon.mod_book.modulenameplural": "Books",
"addon.mod_book.toc": "Table of contents",