Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOBILE-4147 core,folder: Restore access to inline folders #3318

Draft
wants to merge 11 commits into
base: v4.1.x
Choose a base branch
from
Draft
6 changes: 3 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="40100" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.0.1.0" version="4.0.1" versionCode="40100" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="40200" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.0.2.0" version="4.0.2" versionCode="40200" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Moodle</name>
<description>Moodle official app</description>
<author email="mobile@moodle.com" href="http://moodle.com">Moodle Mobile team</author>
Expand Down Expand Up @@ -27,7 +27,7 @@
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="AppendUserAgent" value="MoodleMobile 4.0.1 (40100)" />
<preference name="AppendUserAgent" value="MoodleMobile 4.0.2 (40200)" />
<preference name="BackupWebStorage" value="none" />
<preference name="ScrollEnabled" value="false" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
Expand Down Expand Up @@ -251,7 +251,7 @@
<true />
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="CFBundleShortVersionString">
<string>4.0.1</string>
<string>4.0.2</string>
</edit-config>
<edit-config file="*-Info.plist" mode="overwrite" target="CFBundleLocalizations">
<array>
Expand Down
4 changes: 2 additions & 2 deletions moodle.config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app_id": "com.moodle.moodlemobile",
"appname": "Moodle Mobile",
"versioncode": 40100,
"versionname": "4.0.1",
"versioncode": 40200,
"versionname": "4.0.2",
"cache_update_frequency_usually": 420000,
"cache_update_frequency_often": 1200000,
"cache_update_frequency_sometimes": 3600000,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moodlemobile",
"version": "4.0.1",
"version": "4.0.2",
"description": "The official app for Moodle.",
"author": {
"name": "Moodle Pty Ltd.",
Expand Down
25 changes: 24 additions & 1 deletion src/addons/mod/folder/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import { CoreConstants, ModPurpose } from '@/core/constants';
import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { AddonModFolderIndexComponent } from '../../components/index';
import { AddonModFolder } from '../folder';

/**
* Handler to support folder modules.
Expand All @@ -33,6 +35,7 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im

supportedFeatures = {
[CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE,
[CoreConstants.FEATURE_HAS_HIDDEN_VIEW]: true,
[CoreConstants.FEATURE_GROUPS]: false,
[CoreConstants.FEATURE_GROUPINGS]: false,
[CoreConstants.FEATURE_MOD_INTRO]: true,
Expand All @@ -44,6 +47,26 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
[CoreConstants.FEATURE_MOD_PURPOSE]: ModPurpose.MOD_PURPOSE_CONTENT,
};

/**
* @inheritdoc
*/
async getData(
module: CoreCourseModuleData,
courseId: number,
sectionId?: number,
forCoursePage?: boolean,
): Promise<CoreCourseModuleHandlerData> {
const data = await super.getData(module, courseId, sectionId, forCoursePage);
if (module.description) {
const folderInstance = await AddonModFolder.getFolder(courseId, module.id);
if (folderInstance && module.description) {
module.description = folderInstance.intro;
}
}

return data;
}

/**
* @inheritdoc
*/
Expand Down
11 changes: 6 additions & 5 deletions src/addons/mod/forum/services/forum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,6 @@ export class AddonModForumProvider {
forumId: number,
options: AddonModForumGetDiscussionsInPagesOptions = {},
): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> {
options.page = options.page || 0;

const result = {
discussions: [] as AddonModForumDiscussion[],
error: false,
Expand All @@ -824,7 +822,10 @@ export class AddonModForumProvider {

const getPage = (page: number): Promise<{ discussions: AddonModForumDiscussion[]; error: boolean }> =>
// Get page discussions.
this.getDiscussions(forumId, options).then((response) => {
this.getDiscussions(forumId, {
...options,
page,
}).then((response) => {
result.discussions = result.discussions.concat(response.discussions);
numPages--;

Expand All @@ -841,7 +842,7 @@ export class AddonModForumProvider {
})
;

return getPage(options.page);
return getPage(options.page ?? 0);
}

/**
Expand Down Expand Up @@ -881,7 +882,7 @@ export class AddonModForumProvider {
.getDiscussionsInPages(forum.id, {
cmId: forum.cmid,
sortOrder: sortOrder.value,
readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE,
readingStrategy: CoreSitesReadingStrategy.ONLY_CACHE,
})
.then((response) => {
// Now invalidate the WS calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h3 class="{{module.handlerData!.class}} addon-storagemanager-module-size">
<core-download-refresh *ngIf="downloadEnabled && module.handlerData?.showDownloadButton &&
module.downloadStatus != statusDownloaded" [status]="module.downloadStatus" [enabled]="true"
[canTrustDownload]="true" [loading]="module.spinner || module.handlerData.spinner"
(action)="prefetchModule(module, section)">
(action)="prefetchModule(module, $event)">
</core-download-refresh>
<ion-button fill="clear" (click)="deleteForModule(module, section)"
*ngIf="!module.calculatingSize && module.totalSize > 0" color="danger">
Expand Down
2 changes: 1 addition & 1 deletion src/core/classes/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class CoreSite {
'3.9': 2020061500,
'3.10': 2020110900,
'3.11': 2021051700,
'4.0': 2021100300, // @todo [4.0] replace with right value when released. Using a tmp value to be able to test new things.
'4.0': 2022041900,
};

// Possible cache update frequencies.
Expand Down
1 change: 1 addition & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export class CoreConstants {
static readonly FEATURE_COMPLETION_TRACKS_VIEWS = 'completion_tracks_views'; // True if module tracks whether somebody viewed it.
static readonly FEATURE_COMPLETION_HAS_RULES = 'completion_has_rules'; // True if module has custom completion rules.
static readonly FEATURE_NO_VIEW_LINK = 'viewlink'; // True if module has no 'view' page (like label).
static readonly FEATURE_HAS_HIDDEN_VIEW = 'hiddenview'; // True if module has a hidden 'view' page (like inline folder).
static readonly FEATURE_IDNUMBER = 'idnumber'; // True if module wants support for setting the ID number for grade calculation purposes.
static readonly FEATURE_GROUPS = 'groups'; // True if module supports groups.
static readonly FEATURE_GROUPINGS = 'groupings'; // True if module supports groupings.
Expand Down
4 changes: 3 additions & 1 deletion src/core/features/block/services/block-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ export class CoreBlockDelegateService extends CoreDelegate<CoreBlockHandler> {
* @return Whether is enabled or disabled in site.
*/
protected isFeatureDisabled(handler: CoreBlockHandler, site: CoreSite): boolean {
return this.areBlocksDisabledInSite(site) || super.isFeatureDisabled(handler, site);
// Allow displaying my overview even if all blocks are disabled, to avoid having an empty My Courses.
return (this.areBlocksDisabledInSite(site) && handler.blockName !== 'myoverview') ||
super.isFeatureDisabled(handler, site);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
displayGrades: true,
}, this.displayOptions);

this.displayOptions.displayOpenInBrowser = this.displayOptions.displayOpenInBrowser &&
(!!this.module?.url ||
!CoreCourseModuleDelegate.supportsFeature(this.module.modname, CoreConstants.FEATURE_HAS_HIDDEN_VIEW, false));

this.displayOptions.displayGrades = this.displayOptions.displayGrades &&
CoreCourseModuleDelegate.supportsFeature(this.module.modname, CoreConstants.FEATURE_GRADE_HAS_GRADE, true);

Expand Down
3 changes: 3 additions & 0 deletions src/core/features/course/services/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,9 @@ export class CoreCourseProvider {
CoreCourseModuleDelegate.supportsFeature(module.modname, CoreConstants.FEATURE_NO_VIEW_LINK, false)) {
return false;
}
if (CoreCourseModuleDelegate.supportsFeature(module.modname, CoreConstants.FEATURE_HAS_HIDDEN_VIEW, false)){
return true;
}
}

return !!module.url;
Expand Down
20 changes: 16 additions & 4 deletions src/core/features/courses/pages/my/my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { AddonBlockMyOverviewComponent } from '@addons/block/myoverview/components/myoverview/myoverview';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { CoreBlockComponent } from '@features/block/components/block/block';
import { CoreBlockDelegate } from '@features/block/services/block-delegate';
import { CoreCourseBlock } from '@features/course/services/course';
import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/courses/services/dashboard';
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
Expand Down Expand Up @@ -80,28 +81,39 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
const available = await CoreCoursesDashboard.isAvailable();
const disabled = await CoreCourses.isMyCoursesDisabled();

const supportsMyParam = !!CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('4.0');

if (available && !disabled) {
try {
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myPageCourses);
const blocks = await CoreCoursesDashboard.getDashboardBlocks(
undefined,
undefined,
supportsMyParam ? this.myPageCourses : undefined,
);

// My overview block should always be in main blocks, but check side blocks too just in case.
this.loadedBlock = blocks.mainBlocks.concat(blocks.sideBlocks).find((block) => block.name == 'myoverview');
this.hasSideBlocks = blocks.sideBlocks.length > 0;
this.hasSideBlocks = supportsMyParam && CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks);

await CoreUtils.nextTicks(2);

this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent;

if (!this.loadedBlock && !supportsMyParam) {
// In old sites, display the block even if not found in Dashboard.
// This is because the "My courses" page doesn't exist in the site so it can't be configured.
this.loadFallbackBlock();
}
} catch (error) {
CoreDomUtils.showErrorModal(error);

// Cannot get the blocks, just show the block if needed.
this.loadFallbackBlock();
}
} else if (!available) {
// WS not available, or my courses page not available. show fallback block.
// WS not available, show fallback block.
this.loadFallbackBlock();
} else {
// Disabled.
this.loadedBlock = undefined;
}

Expand Down