MOBILE-3833 course: Make last access coherent with recent block
parent
525218a4a0
commit
2f39512552
|
@ -212,7 +212,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
|||
this.logAfterFetch = false;
|
||||
await CoreUtils.ignoreErrors(AddonModData.logView(this.database.id, this.database.name));
|
||||
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
// Store module viewed because this page also updates recent accessed items block.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.moduleId);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
@ -16,7 +16,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
|||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -50,7 +49,6 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
|||
loaded = false;
|
||||
|
||||
protected attemptId: number;
|
||||
protected fetchSuccess = false;
|
||||
|
||||
constructor() {
|
||||
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||
|
@ -132,12 +130,6 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
|||
|
||||
return attemptItem;
|
||||
}).filter((itemData) => itemData); // Filter items with errors.
|
||||
|
||||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (message) {
|
||||
// Some call failed on fetch, go back.
|
||||
CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true);
|
||||
|
|
|
@ -25,7 +25,6 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonModFeedbackAttemptItem, AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source';
|
||||
import { AddonModFeedbackWSAnonAttempt, AddonModFeedbackWSAttempt } from '../../services/feedback';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
|
||||
/**
|
||||
* Page that displays feedback attempts.
|
||||
|
@ -187,13 +186,4 @@ export class AddonModFeedbackAttemptsPage implements AfterViewInit, OnDestroy {
|
|||
* Attempts manager.
|
||||
*/
|
||||
class AddonModFeedbackAttemptsManager extends CoreListItemsManager<AddonModFeedbackAttemptItem, AddonModFeedbackAttemptsSource> {
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected async logActivity(): Promise<void> {
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.getSource().COURSE_ID, this.getSource().CM_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
@ -35,7 +34,6 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit {
|
|||
protected courseId!: number;
|
||||
protected feedback?: AddonModFeedbackWSFeedback;
|
||||
protected page = 0;
|
||||
protected fetchSuccess = false;
|
||||
|
||||
selectedGroup!: number;
|
||||
groupInfo?: CoreGroupInfo;
|
||||
|
@ -83,12 +81,6 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit {
|
|||
this.selectedGroup = CoreGroups.validateGroupId(this.selectedGroup, this.groupInfo);
|
||||
|
||||
await this.loadGroupUsers(this.selectedGroup);
|
||||
|
||||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (message) {
|
||||
CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import { Component, OnDestroy, ViewChild, OnInit, AfterViewInit, ElementRef, Opt
|
|||
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||
import { CoreRatingInfo, CoreRatingProvider } from '@features/rating/services/rating';
|
||||
import { CoreRatingOffline } from '@features/rating/services/rating-offline';
|
||||
|
@ -120,7 +119,6 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
protected ratingOfflineObserver?: CoreEventObserver;
|
||||
protected ratingSyncObserver?: CoreEventObserver;
|
||||
protected changeDiscObserver?: CoreEventObserver;
|
||||
protected fetchSuccess = false;
|
||||
|
||||
constructor(
|
||||
@Optional() protected splitView: CoreSplitViewComponent,
|
||||
|
@ -547,12 +545,6 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
|||
|
||||
this.hasOfflineRatings =
|
||||
await CoreRatingOffline.hasRatings('mod_forum', 'post', ContextLevel.MODULE, this.cmId, this.discussionId);
|
||||
|
||||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
this.courseId && this.cmId && CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModal(error);
|
||||
} finally {
|
||||
|
|
|
@ -17,7 +17,6 @@ import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
|||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CoreCommentsCommentsComponent } from '@features/comments/components/comments/comments';
|
||||
import { CoreComments } from '@features/comments/services/comments';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreRatingInfo } from '@features/rating/services/rating';
|
||||
import { CoreTag } from '@features/tag/services/tag';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
|
@ -59,7 +58,6 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
cmId?: number;
|
||||
|
||||
protected entryId!: number;
|
||||
protected fetchSuccess = false;
|
||||
|
||||
constructor(protected route: ActivatedRoute) {}
|
||||
|
||||
|
@ -148,12 +146,6 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
|||
this.entry = result.entry;
|
||||
this.ratingInfo = result.ratinginfo;
|
||||
|
||||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
this.cmId && CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
|
||||
if (this.glossary) {
|
||||
// Glossary already loaded, nothing else to load.
|
||||
return;
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
AddonModH5PActivityData,
|
||||
AddonModH5PActivityAttemptResults,
|
||||
} from '../../services/h5pactivity';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
|
||||
/**
|
||||
* Page that displays results of an attempt.
|
||||
|
@ -100,9 +99,6 @@ export class AddonModH5PActivityAttemptResultsPage implements OnInit {
|
|||
this.h5pActivity.name,
|
||||
{ attemptId: this.attemptId },
|
||||
));
|
||||
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error loading attempt.');
|
||||
|
|
|
@ -26,7 +26,6 @@ import {
|
|||
AddonModH5PActivityData,
|
||||
AddonModH5PActivityUserAttempts,
|
||||
} from '../../services/h5pactivity';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
|
||||
/**
|
||||
* Page that displays user attempts of a certain user.
|
||||
|
@ -102,9 +101,6 @@ export class AddonModH5PActivityUserAttemptsPage implements OnInit {
|
|||
this.h5pActivity.name,
|
||||
{ userId: this.userId },
|
||||
));
|
||||
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error loading attempts.');
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
|
||||
|
@ -93,9 +92,6 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit {
|
|||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
CoreUtils.ignoreErrors(AddonModH5PActivity.logViewReport(this.h5pActivity.id, this.h5pActivity.name));
|
||||
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error loading attempts.');
|
||||
|
|
|
@ -34,7 +34,6 @@ import {
|
|||
AddonModLessonUserAttemptAnswerPageWSData,
|
||||
} from '../../services/lesson';
|
||||
import { AddonModLessonAnswerData, AddonModLessonHelper } from '../../services/lesson-helper';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreTime } from '@singletons/time';
|
||||
|
||||
/**
|
||||
|
@ -60,7 +59,6 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
protected userId?: number; // User ID to see the retakes.
|
||||
protected retakeNumber?: number; // Number of the initial retake to see.
|
||||
protected previousSelectedRetake?: number; // To be able to detect the previous selected retake when it has changed.
|
||||
protected fetchSuccess = false;
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
|
@ -162,12 +160,6 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
|||
this.student.profileimageurl = user?.profileimageurl;
|
||||
|
||||
await this.setRetake(this.selectedRetake);
|
||||
|
||||
if (!this.fetchSuccess) {
|
||||
this.fetchSuccess = true;
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error getting data.', true);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { CoreQuestionQuestionParsed } from '@features/question/services/question';
|
||||
import { CoreQuestionHelper } from '@features/question/services/question-helper';
|
||||
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||
|
@ -162,9 +161,6 @@ export class AddonModQuizReviewPage implements OnInit {
|
|||
CoreUtils.ignoreErrors(
|
||||
AddonModQuiz.logViewAttemptReview(this.attemptId, this.quiz.id, this.quiz.name),
|
||||
);
|
||||
|
||||
// Store module viewed. It's done in this page because it can be reached using a link.
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.cmId);
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquiz', true);
|
||||
|
|
|
@ -447,6 +447,16 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected async storeModuleViewed(): Promise<void> {
|
||||
// Only store module viewed when viewing the main page.
|
||||
if (!this.pageId) {
|
||||
await super.storeModuleViewed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to the wiki home view. If cannot determine or it's current view, return undefined.
|
||||
*
|
||||
|
|
|
@ -442,7 +442,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
|||
}
|
||||
|
||||
this.fetchSuccess = true;
|
||||
CoreCourse.storeModuleViewed(this.courseId, this.module.id, { sectionId: this.module.section });
|
||||
this.storeModuleViewed();
|
||||
|
||||
// Log activity now.
|
||||
try {
|
||||
|
@ -456,6 +456,15 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store module as viewed.
|
||||
*
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected async storeModuleViewed(): Promise<void> {
|
||||
await CoreCourse.storeModuleViewed(this.courseId, this.module.id, { sectionId: this.module.section });
|
||||
}
|
||||
|
||||
/**
|
||||
* Log activity.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue