MOBILE-2272 essay: Fix issues with attachments in essay

main
Dani Palou 2020-11-16 12:44:01 +01:00
parent 5977cab51a
commit a35cc807e1
5 changed files with 15 additions and 5 deletions

View File

@ -1577,8 +1577,7 @@ export class AddonModQuizProvider {
const question = result.questions[i];
if (!question.settings) {
// Site doesn't return settings, stop.
break;
continue;
}
question.settings = this.textUtils.parseJSON(question.settings, null);

View File

@ -18,7 +18,7 @@
<!-- Draft files not supported. -->
<ng-container *ngIf="question.textarea && question.hasDraftFiles && !uploadFilesSupported">
<ion-item text-wrap class="core-danger-item">
<p class="core-question-warning">{{ 'core.question.errorinlinefilesnotsupportedinsite' | translate }}</p>
<p class="core-question-warning">{{ 'core.question.errorembeddedfilesnotsupportedinsite' | translate }}</p>
</ion-item>
<ion-item text-wrap>
<p><core-format-text [component]="component" [componentId]="componentId" [text]="question.textarea.text" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId"></core-format-text></p>

View File

@ -130,7 +130,7 @@ export class AddonQtypeEssayHandler implements CoreQuestionHandler {
}
if (!uploadFilesSupported && this.questionHelper.hasDraftFileUrls(element.innerHTML)) {
return 'core.question.errorinlinefilesnotsupportedinsite';
return 'core.question.errorembeddedfilesnotsupportedinsite';
}
}

View File

@ -69,7 +69,8 @@ export class CoreAttachmentsComponent implements OnInit {
const siteInfo = currentSite && currentSite.getInfo();
if (siteInfo && siteInfo.usermaxuploadfilesize) {
this.maxSizeReadable = this.textUtils.bytesToSize(siteInfo.usermaxuploadfilesize, 2);
this.maxSize = siteInfo.usermaxuploadfilesize;
this.maxSizeReadable = this.textUtils.bytesToSize(this.maxSize, 2);
} else {
this.maxSizeReadable = this.translate.instant('core.unknown');
}

View File

@ -27,6 +27,7 @@ import { CoreTextUtilsProvider } from '@providers/utils/text';
import { CoreUtilsProvider, PromiseDefer } from '@providers/utils/utils';
import { CoreFileUploaderProvider, CoreFileUploaderOptions } from './fileuploader';
import { CoreFileUploaderDelegate } from './delegate';
import { CoreSites } from '@providers/sites';
/**
* Helper service to upload files.
@ -697,6 +698,15 @@ export class CoreFileUploaderHelperProvider {
* @return Promise resolved when done.
*/
async uploadFileObject(file: any, maxSize?: number, upload?: boolean, allowOffline?: boolean, name?: string): Promise<any> {
if (maxSize === 0) {
const currentSite = CoreSites.instance.getCurrentSite();
const siteInfo = currentSite && currentSite.getInfo();
if (siteInfo && siteInfo.usermaxuploadfilesize) {
maxSize = siteInfo.usermaxuploadfilesize;
}
}
if (maxSize != -1 && file.size > maxSize) {
return this.errorMaxBytes(maxSize, file.name);
}