Merge pull request #2608 from dpalou/MOBILE-2272
MOBILE-2272 essay: Fix issues with attachments in essaymain
commit
1664b3a793
|
@ -1577,8 +1577,7 @@ export class AddonModQuizProvider {
|
||||||
const question = result.questions[i];
|
const question = result.questions[i];
|
||||||
|
|
||||||
if (!question.settings) {
|
if (!question.settings) {
|
||||||
// Site doesn't return settings, stop.
|
continue;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
question.settings = this.textUtils.parseJSON(question.settings, null);
|
question.settings = this.textUtils.parseJSON(question.settings, null);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<!-- Draft files not supported. -->
|
<!-- Draft files not supported. -->
|
||||||
<ng-container *ngIf="question.textarea && question.hasDraftFiles && !uploadFilesSupported">
|
<ng-container *ngIf="question.textarea && question.hasDraftFiles && !uploadFilesSupported">
|
||||||
<ion-item text-wrap class="core-danger-item">
|
<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>
|
||||||
<ion-item text-wrap>
|
<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>
|
<p><core-format-text [component]="component" [componentId]="componentId" [text]="question.textarea.text" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId"></core-format-text></p>
|
||||||
|
|
|
@ -130,7 +130,7 @@ export class AddonQtypeEssayHandler implements CoreQuestionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uploadFilesSupported && this.questionHelper.hasDraftFileUrls(element.innerHTML)) {
|
if (!uploadFilesSupported && this.questionHelper.hasDraftFileUrls(element.innerHTML)) {
|
||||||
return 'core.question.errorinlinefilesnotsupportedinsite';
|
return 'core.question.errorembeddedfilesnotsupportedinsite';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ export class CoreAttachmentsComponent implements OnInit {
|
||||||
const siteInfo = currentSite && currentSite.getInfo();
|
const siteInfo = currentSite && currentSite.getInfo();
|
||||||
|
|
||||||
if (siteInfo && siteInfo.usermaxuploadfilesize) {
|
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 {
|
} else {
|
||||||
this.maxSizeReadable = this.translate.instant('core.unknown');
|
this.maxSizeReadable = this.translate.instant('core.unknown');
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||||
import { CoreUtilsProvider, PromiseDefer } from '@providers/utils/utils';
|
import { CoreUtilsProvider, PromiseDefer } from '@providers/utils/utils';
|
||||||
import { CoreFileUploaderProvider, CoreFileUploaderOptions } from './fileuploader';
|
import { CoreFileUploaderProvider, CoreFileUploaderOptions } from './fileuploader';
|
||||||
import { CoreFileUploaderDelegate } from './delegate';
|
import { CoreFileUploaderDelegate } from './delegate';
|
||||||
|
import { CoreSites } from '@providers/sites';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper service to upload files.
|
* Helper service to upload files.
|
||||||
|
@ -697,6 +698,15 @@ export class CoreFileUploaderHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
async uploadFileObject(file: any, maxSize?: number, upload?: boolean, allowOffline?: boolean, name?: string): Promise<any> {
|
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) {
|
if (maxSize != -1 && file.size > maxSize) {
|
||||||
return this.errorMaxBytes(maxSize, file.name);
|
return this.errorMaxBytes(maxSize, file.name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue