MOBILE-2842 core: Use site schemas for all modules
parent
9602746c9a
commit
95326d4da0
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
|
@ -23,7 +23,6 @@ import { CoreConstants } from '@core/constants';
|
|||
import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
||||
import { CoreConfigProvider } from '@providers/config';
|
||||
import { ILocalNotification } from '@ionic-native/local-notifications';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle calendar events.
|
||||
|
@ -39,7 +38,10 @@ export class AddonCalendarProvider {
|
|||
|
||||
// Variables for database.
|
||||
static EVENTS_TABLE = 'addon_calendar_events';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonCalendarProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonCalendarProvider.EVENTS_TABLE,
|
||||
columns: [
|
||||
|
@ -127,7 +129,8 @@ export class AddonCalendarProvider {
|
|||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
protected logger;
|
||||
|
||||
|
@ -135,7 +138,7 @@ export class AddonCalendarProvider {
|
|||
private coursesProvider: CoreCoursesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private localNotificationsProvider: CoreLocalNotificationsProvider, private configProvider: CoreConfigProvider) {
|
||||
this.logger = logger.getInstance('AddonCalendarProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle Offline messages.
|
||||
|
@ -30,7 +29,10 @@ export class AddonMessagesOfflineProvider {
|
|||
// Variables for database.
|
||||
static MESSAGES_TABLE = 'addon_messages_offline_messages'; // When group messaging isn't available or a new conversation starts.
|
||||
static CONVERSATION_MESSAGES_TABLE = 'addon_messages_offline_conversation_messages'; // Conversation messages.
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonMessagesOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonMessagesOfflineProvider.MESSAGES_TABLE,
|
||||
columns: [
|
||||
|
@ -83,12 +85,13 @@ export class AddonMessagesOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['conversationid', 'text', 'timecreated']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private appProvider: CoreAppProvider,
|
||||
private textUtils: CoreTextUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonMessagesOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline assign.
|
||||
|
@ -31,7 +30,10 @@ export class AddonModAssignOfflineProvider {
|
|||
// Variables for database.
|
||||
static SUBMISSIONS_TABLE = 'addon_mod_assign_submissions';
|
||||
static SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModAssignOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModAssignOfflineProvider.SUBMISSIONS_TABLE,
|
||||
columns: [
|
||||
|
@ -124,12 +126,13 @@ export class AddonModAssignOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['assignid', 'userid']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private fileProvider: CoreFileProvider, private timeUtils: CoreTimeUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonModAssignOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
|
||||
/**
|
||||
* Service to handle offline choices.
|
||||
|
@ -24,7 +23,11 @@ export class AddonModChoiceOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static CHOICE_TABLE = 'addon_mod_choice_responses';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModChoiceOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModChoiceOfflineProvider.CHOICE_TABLE,
|
||||
columns: [
|
||||
|
@ -59,10 +62,11 @@ export class AddonModChoiceOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['choiceid', 'userid']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private sitesProvider: CoreSitesProvider) {
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle Offline feedback.
|
||||
|
@ -29,7 +28,10 @@ export class AddonModFeedbackOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static FEEDBACK_TABLE = 'addon_mod_feedback_answers';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModFeedbackOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModFeedbackOfflineProvider.FEEDBACK_TABLE,
|
||||
columns: [
|
||||
|
@ -56,12 +58,13 @@ export class AddonModFeedbackOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['feedbackid', 'page']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider,
|
||||
private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonModFeedbackOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline forum.
|
||||
|
@ -28,7 +27,10 @@ export class AddonModForumOfflineProvider {
|
|||
static DISCUSSIONS_TABLE = 'addon_mod_forum_discussions';
|
||||
static REPLIES_TABLE = 'addon_mod_forum_replies';
|
||||
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModForumOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModForumOfflineProvider.DISCUSSIONS_TABLE,
|
||||
columns: [
|
||||
|
@ -117,12 +119,13 @@ export class AddonModForumOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['postid', 'userid']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private fileProvider: CoreFileProvider,
|
||||
private sitesProvider: CoreSitesProvider,
|
||||
private textUtils: CoreTextUtilsProvider) {
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline glossary.
|
||||
|
@ -28,7 +27,10 @@ export class AddonModGlossaryOfflineProvider {
|
|||
// Variables for database.
|
||||
static ENTRIES_TABLE = 'addon_mod_glossary_entrues';
|
||||
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModGlossaryOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModGlossaryOfflineProvider.ENTRIES_TABLE,
|
||||
columns: [
|
||||
|
@ -71,13 +73,14 @@ export class AddonModGlossaryOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['glossaryid', 'concept', 'timecreated']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private fileProvider: CoreFileProvider,
|
||||
private sitesProvider: CoreSitesProvider,
|
||||
private textUtils: CoreTextUtilsProvider,
|
||||
private utils: CoreUtilsProvider) {
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { AddonModLessonProvider } from './lesson';
|
||||
|
||||
/**
|
||||
|
@ -32,7 +31,10 @@ export class AddonModLessonOfflineProvider {
|
|||
// Variables for database. We use lowercase in the names to match the WS responses.
|
||||
static RETAKES_TABLE = 'addon_mod_lesson_retakes';
|
||||
static PAGE_ATTEMPTS_TABLE = 'addon_mod_lesson_page_attempts';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModLessonOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModLessonOfflineProvider.RETAKES_TABLE,
|
||||
columns: [
|
||||
|
@ -120,15 +122,17 @@ export class AddonModLessonOfflineProvider {
|
|||
type: 'TEXT'
|
||||
},
|
||||
],
|
||||
primaryKeys: ['lessonid', 'retake', 'pageid', 'timemodified'] // A user can attempt several times per page and retake.
|
||||
// A user can attempt several times per page and retake.
|
||||
primaryKeys: ['lessonid', 'retake', 'pageid', 'timemodified']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private textUtils: CoreTextUtilsProvider, private utils: CoreUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonModLessonOfflineProvider');
|
||||
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ import { TranslateService } from '@ngx-translate/core';
|
|||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreSyncProvider } from '@providers/sync';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
|
@ -25,7 +25,6 @@ import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
|||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreSyncBaseProvider } from '@classes/base-sync';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { AddonModLessonProvider } from './lesson';
|
||||
import { AddonModLessonOfflineProvider } from './lesson-offline';
|
||||
import { AddonModLessonPrefetchHandler } from './prefetch-handler';
|
||||
|
@ -59,7 +58,11 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
// Variables for database.
|
||||
static RETAKES_FINISHED_TABLE = 'addon_mod_lesson_retakes_finished_sync';
|
||||
protected tablesSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModLessonSyncProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModLessonSyncProvider.RETAKES_FINISHED_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -80,6 +83,8 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider {
|
|||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
constructor(loggerProvider: CoreLoggerProvider, sitesProvider: CoreSitesProvider, appProvider: CoreAppProvider,
|
||||
|
@ -94,7 +99,7 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
this.componentTranslate = courseProvider.translateModuleName('lesson');
|
||||
|
||||
this.sitesProvider.createTableFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreGradesProvider } from '@core/grades/providers/grades';
|
||||
import { CoreSiteWSPreSets } from '@classes/site';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { AddonModLessonOfflineProvider } from './lesson-offline';
|
||||
|
||||
/**
|
||||
|
@ -156,7 +155,11 @@ export class AddonModLessonProvider {
|
|||
|
||||
// Variables for database.
|
||||
static PASSWORD_TABLE = 'addon_mod_lesson_password';
|
||||
protected tablesSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModLessonProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModLessonProvider.PASSWORD_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -173,6 +176,8 @@ export class AddonModLessonProvider {
|
|||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
protected ROOT_CACHE_KEY = 'mmaModLesson:';
|
||||
|
@ -183,7 +188,7 @@ export class AddonModLessonProvider {
|
|||
private lessonOfflineProvider: AddonModLessonOfflineProvider) {
|
||||
this.logger = logger.getInstance('AddonModLessonProvider');
|
||||
|
||||
this.sitesProvider.createTableFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { AddonModQuizAccessRuleHandler } from '../../../providers/access-rules-delegate';
|
||||
import { AddonModQuizAccessPasswordComponent } from '../component/password';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Handler to support password access rule.
|
||||
|
@ -26,7 +25,11 @@ import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
|||
export class AddonModQuizAccessPasswordHandler implements AddonModQuizAccessRuleHandler {
|
||||
// Variables for database.
|
||||
static PASSWORD_TABLE = 'addon_mod_quiz_access_password';
|
||||
protected tableSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModQuizAccessPasswordHandler',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModQuizAccessPasswordHandler.PASSWORD_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -43,13 +46,15 @@ export class AddonModQuizAccessPasswordHandler implements AddonModQuizAccessRule
|
|||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
name = 'AddonModQuizAccessPassword';
|
||||
ruleName = 'quizaccess_password';
|
||||
|
||||
constructor(private sitesProvider: CoreSitesProvider) {
|
||||
this.sitesProvider.createTableFromSchema(this.tableSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreQuestionProvider } from '@core/question/providers/question';
|
||||
import { CoreQuestionBehaviourDelegate } from '@core/question/providers/behaviour-delegate';
|
||||
import { AddonModQuizProvider } from './quiz';
|
||||
import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { SQLiteDB } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline quiz.
|
||||
|
@ -33,7 +33,10 @@ export class AddonModQuizOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static ATTEMPTS_TABLE = 'addon_mod_quiz_attempts';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModQuizOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModQuizOfflineProvider.ATTEMPTS_TABLE,
|
||||
columns: [
|
||||
|
@ -76,14 +79,15 @@ export class AddonModQuizOfflineProvider {
|
|||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private questionProvider: CoreQuestionProvider, private translate: TranslateService, private utils: CoreUtilsProvider,
|
||||
private behaviourDelegate: CoreQuestionBehaviourDelegate) {
|
||||
this.logger = logger.getInstance('AddonModQuizOfflineProvider');
|
||||
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreSyncProvider } from '@providers/sync';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreUserProvider } from '@core/user/providers/user';
|
||||
import { AddonModScormProvider } from './scorm';
|
||||
import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { SQLiteDB } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline SCORM.
|
||||
|
@ -34,7 +34,10 @@ export class AddonModScormOfflineProvider {
|
|||
// Variables for database.
|
||||
static ATTEMPTS_TABLE = 'addon_mod_scorm_offline_attempts';
|
||||
static TRACKS_TABLE = 'addon_mod_scorm_offline_scos_tracks';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModScormOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModScormOfflineProvider.ATTEMPTS_TABLE,
|
||||
columns: [
|
||||
|
@ -115,14 +118,15 @@ export class AddonModScormOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['scormid', 'userid', 'attempt', 'scoid', 'element']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private syncProvider: CoreSyncProvider, private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private userProvider: CoreUserProvider) {
|
||||
this.logger = logger.getInstance('AddonModScormOfflineProvider');
|
||||
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle Offline survey.
|
||||
|
@ -28,7 +27,10 @@ export class AddonModSurveyOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static SURVEY_TABLE = 'addon_mod_survey_answers';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModSurveyOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModSurveyOfflineProvider.SURVEY_TABLE,
|
||||
columns: [
|
||||
|
@ -59,11 +61,12 @@ export class AddonModSurveyOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['surveyid', 'userid']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonModSurveyOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
|
||||
/**
|
||||
* Service to handle offline wiki.
|
||||
|
@ -27,7 +26,10 @@ export class AddonModWikiOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static NEW_PAGES_TABLE = 'addon_mod_wiki_new_pages_store';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModWikiOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModWikiOfflineProvider.NEW_PAGES_TABLE,
|
||||
columns: [
|
||||
|
@ -78,11 +80,12 @@ export class AddonModWikiOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['wikiid', 'subwikiid', 'userid', 'groupid', 'title']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider) {
|
||||
this.logger = logger.getInstance('AddonModWikiOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline workshop.
|
||||
|
@ -31,7 +30,10 @@ export class AddonModWorkshopOfflineProvider {
|
|||
static EVALUATE_SUBMISSIONS_TABLE = 'addon_mod_workshop_evaluate_submissions';
|
||||
static EVALUATE_ASSESSMENTS_TABLE = 'addon_mod_workshop_evaluate_assessments';
|
||||
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonModWorkshopOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonModWorkshopOfflineProvider.SUBMISSIONS_TABLE,
|
||||
columns: [
|
||||
|
@ -164,13 +166,14 @@ export class AddonModWorkshopOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['workshopid', 'assessmentid']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private fileProvider: CoreFileProvider,
|
||||
private sitesProvider: CoreSitesProvider,
|
||||
private textUtils: CoreTextUtilsProvider,
|
||||
private timeUtils: CoreTimeUtilsProvider) {
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to handle offline notes.
|
||||
|
@ -27,7 +26,10 @@ export class AddonNotesOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static NOTES_TABLE = 'addon_notes_offline_notes';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'AddonNotesOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: AddonNotesOfflineProvider.NOTES_TABLE,
|
||||
columns: [
|
||||
|
@ -62,11 +64,12 @@ export class AddonNotesOfflineProvider {
|
|||
],
|
||||
primaryKeys: ['userid', 'content', 'created']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider) {
|
||||
this.logger = logger.getInstance('AddonNotesOfflineProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injector } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { SQLiteDB, SQLiteDBTableSchema } from './sqlitedb';
|
||||
import { SQLiteDB } from './sqlitedb';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreDbProvider } from '@providers/db';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
|
@ -166,47 +166,8 @@ export class CoreSite {
|
|||
protected wsProvider: CoreWSProvider;
|
||||
|
||||
// Variables for the database.
|
||||
protected WS_CACHE_TABLE = 'wscache';
|
||||
protected CONFIG_TABLE = 'core_site_config';
|
||||
protected tableSchemas: SQLiteDBTableSchema[] = [
|
||||
{
|
||||
name: this.WS_CACHE_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'TEXT',
|
||||
primaryKey: true
|
||||
},
|
||||
{
|
||||
name: 'data',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'expirationTime',
|
||||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: this.CONFIG_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'TEXT',
|
||||
unique: true,
|
||||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'value'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
];
|
||||
static WS_CACHE_TABLE = 'wscache';
|
||||
static CONFIG_TABLE = 'core_site_config';
|
||||
|
||||
// Versions of Moodle releases.
|
||||
protected MOODLE_RELEASES = {
|
||||
|
@ -267,7 +228,6 @@ export class CoreSite {
|
|||
*/
|
||||
initDB(): void {
|
||||
this.db = this.dbProvider.getDB('Site-' + this.id);
|
||||
this.db.createTablesFromSchema(this.tableSchemas);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -784,10 +744,10 @@ export class CoreSite {
|
|||
let promise;
|
||||
|
||||
if (preSets.getCacheUsingCacheKey || (emergency && preSets.getEmergencyCacheUsingCacheKey)) {
|
||||
promise = this.db.getRecords(this.WS_CACHE_TABLE, { key: preSets.cacheKey }).then((entries) => {
|
||||
promise = this.db.getRecords(CoreSite.WS_CACHE_TABLE, { key: preSets.cacheKey }).then((entries) => {
|
||||
if (!entries.length) {
|
||||
// Cache key not found, get by params sent.
|
||||
return this.db.getRecord(this.WS_CACHE_TABLE, { id: id });
|
||||
return this.db.getRecord(CoreSite.WS_CACHE_TABLE, { id: id });
|
||||
} else if (entries.length > 1) {
|
||||
// More than one entry found. Search the one with same ID as this call.
|
||||
for (let i = 0, len = entries.length; i < len; i++) {
|
||||
|
@ -801,13 +761,13 @@ export class CoreSite {
|
|||
return entries[0];
|
||||
});
|
||||
} else {
|
||||
promise = this.db.getRecord(this.WS_CACHE_TABLE, { id: id }).catch(() => {
|
||||
promise = this.db.getRecord(CoreSite.WS_CACHE_TABLE, { id: id }).catch(() => {
|
||||
// Entry not found, try to get it using the old ID.
|
||||
const oldId = this.getCacheOldId(method, originalData || {});
|
||||
|
||||
return this.db.getRecord(this.WS_CACHE_TABLE, { id: oldId }).then((entry) => {
|
||||
return this.db.getRecord(CoreSite.WS_CACHE_TABLE, { id: oldId }).then((entry) => {
|
||||
// Update the entry ID to use the new one.
|
||||
this.db.updateRecords(this.WS_CACHE_TABLE, {id: id}, {id: oldId});
|
||||
this.db.updateRecords(CoreSite.WS_CACHE_TABLE, {id: id}, {id: oldId});
|
||||
|
||||
return entry;
|
||||
});
|
||||
|
@ -877,7 +837,7 @@ export class CoreSite {
|
|||
entry.key = preSets.cacheKey;
|
||||
}
|
||||
|
||||
return this.db.insertRecord(this.WS_CACHE_TABLE, entry);
|
||||
return this.db.insertRecord(CoreSite.WS_CACHE_TABLE, entry);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -898,10 +858,10 @@ export class CoreSite {
|
|||
const id = this.getCacheId(method, data);
|
||||
|
||||
if (allCacheKey) {
|
||||
return this.db.deleteRecords(this.WS_CACHE_TABLE, { key: preSets.cacheKey });
|
||||
return this.db.deleteRecords(CoreSite.WS_CACHE_TABLE, { key: preSets.cacheKey });
|
||||
}
|
||||
|
||||
return this.db.deleteRecords(this.WS_CACHE_TABLE, { id: id });
|
||||
return this.db.deleteRecords(CoreSite.WS_CACHE_TABLE, { id: id });
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -935,7 +895,7 @@ export class CoreSite {
|
|||
|
||||
this.logger.debug('Invalidate all the cache for site: ' + this.id);
|
||||
|
||||
return this.db.updateRecords(this.WS_CACHE_TABLE, { expirationTime: 0 });
|
||||
return this.db.updateRecords(CoreSite.WS_CACHE_TABLE, { expirationTime: 0 });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -954,7 +914,7 @@ export class CoreSite {
|
|||
|
||||
this.logger.debug('Invalidate cache for key: ' + key);
|
||||
|
||||
return this.db.updateRecords(this.WS_CACHE_TABLE, { expirationTime: 0 }, { key: key });
|
||||
return this.db.updateRecords(CoreSite.WS_CACHE_TABLE, { expirationTime: 0 }, { key: key });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -997,7 +957,7 @@ export class CoreSite {
|
|||
|
||||
this.logger.debug('Invalidate cache for key starting with: ' + key);
|
||||
|
||||
const sql = 'UPDATE ' + this.WS_CACHE_TABLE + ' SET expirationTime=0 WHERE key LIKE ?';
|
||||
const sql = 'UPDATE ' + CoreSite.WS_CACHE_TABLE + ' SET expirationTime=0 WHERE key LIKE ?';
|
||||
|
||||
return this.db.execute(sql, [key + '%']);
|
||||
}
|
||||
|
@ -1590,7 +1550,7 @@ export class CoreSite {
|
|||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
deleteSiteConfig(name: string): Promise<any> {
|
||||
return this.db.deleteRecords(this.CONFIG_TABLE, { name: name });
|
||||
return this.db.deleteRecords(CoreSite.CONFIG_TABLE, { name: name });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1601,7 +1561,7 @@ export class CoreSite {
|
|||
* @return {Promise<any>} Resolves upon success along with the config data. Reject on failure.
|
||||
*/
|
||||
getLocalSiteConfig(name: string, defaultValue?: any): Promise<any> {
|
||||
return this.db.getRecord(this.CONFIG_TABLE, { name: name }).then((entry) => {
|
||||
return this.db.getRecord(CoreSite.CONFIG_TABLE, { name: name }).then((entry) => {
|
||||
return entry.value;
|
||||
}).catch((error) => {
|
||||
if (typeof defaultValue != 'undefined') {
|
||||
|
@ -1620,6 +1580,6 @@ export class CoreSite {
|
|||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
setLocalSiteConfig(name: string, value: number | string): Promise<any> {
|
||||
return this.db.insertRecord(this.CONFIG_TABLE, { name: name, value: value });
|
||||
return this.db.insertRecord(CoreSite.CONFIG_TABLE, { name: name, value: value });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
|
||||
/**
|
||||
* Service to handle offline data for courses.
|
||||
|
@ -24,7 +23,10 @@ export class CoreCourseOfflineProvider {
|
|||
|
||||
// Variables for database.
|
||||
static MANUAL_COMPLETION_TABLE = 'course_manual_completion';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreCourseOfflineProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: CoreCourseOfflineProvider.MANUAL_COMPLETION_TABLE,
|
||||
columns: [
|
||||
|
@ -51,10 +53,11 @@ export class CoreCourseOfflineProvider {
|
|||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private sitesProvider: CoreSitesProvider) {
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,13 +17,12 @@ import { TranslateService } from '@ngx-translate/core';
|
|||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
|
||||
import { CoreConstants } from '../../constants';
|
||||
import { CoreCourseOfflineProvider } from './course-offline';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service that provides some features regarding a course.
|
||||
|
@ -48,7 +47,11 @@ export class CoreCourseProvider {
|
|||
|
||||
// Variables for database.
|
||||
protected COURSE_STATUS_TABLE = 'course_status';
|
||||
protected courseStatusTableSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreCourseProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.COURSE_STATUS_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -78,6 +81,8 @@ export class CoreCourseProvider {
|
|||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
protected logger;
|
||||
|
@ -92,7 +97,7 @@ export class CoreCourseProvider {
|
|||
private courseOffline: CoreCourseOfflineProvider, private appProvider: CoreAppProvider) {
|
||||
this.logger = logger.getInstance('CoreCourseProvider');
|
||||
|
||||
this.sitesProvider.createTableFromSchema(this.courseStatusTableSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ import { CoreEventsProvider } from '@providers/events';
|
|||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreCourseProvider } from './course';
|
||||
|
@ -27,7 +27,6 @@ import { CoreConstants } from '../../constants';
|
|||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
import { Subject, BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Progress of downloading a list of modules.
|
||||
|
@ -203,7 +202,11 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
|
|||
export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
||||
// Variables for database.
|
||||
protected CHECK_UPDATES_TIMES_TABLE = 'check_updates_times';
|
||||
protected checkUpdatesTableSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreCourseModulePrefetchDelegate',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.CHECK_UPDATES_TIMES_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -217,6 +220,8 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
|||
notNull: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
protected ROOT_CACHE_KEY = 'mmCourse:';
|
||||
|
@ -243,7 +248,7 @@ export class CoreCourseModulePrefetchDelegate extends CoreDelegate {
|
|||
protected eventsProvider: CoreEventsProvider) {
|
||||
super('CoreCourseModulePrefetchDelegate', loggerProvider, sitesProvider, eventsProvider);
|
||||
|
||||
this.sitesProvider.createTableFromSchema(this.checkUpdatesTableSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
|
||||
eventsProvider.on(CoreEventsProvider.LOGOUT, this.clearStatusCache.bind(this));
|
||||
eventsProvider.on(CoreEventsProvider.PACKAGE_STATUS_CHANGED, (data) => {
|
||||
|
|
|
@ -20,13 +20,12 @@ import { LocalNotifications, ILocalNotification } from '@ionic-native/local-noti
|
|||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreInitDelegate, CoreInitHandler } from '@providers/init';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreLocalNotificationsProvider } from '@providers/local-notifications';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { FileTransferErrorMock } from './file-transfer';
|
||||
import { CoreEmulatorCaptureHelperProvider } from './capture-helper';
|
||||
import { CoreConstants } from '../../constants';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Helper service for the emulator feature. It also acts as an init handler.
|
||||
|
@ -41,7 +40,10 @@ export class CoreEmulatorHelperProvider implements CoreInitHandler {
|
|||
|
||||
// Variables for database.
|
||||
protected LAST_RECEIVED_NOTIFICATION_TABLE = 'core_emulator_last_received_notification';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreEmulatorHelperProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.LAST_RECEIVED_NOTIFICATION_TABLE,
|
||||
columns: [
|
||||
|
@ -60,14 +62,15 @@ export class CoreEmulatorHelperProvider implements CoreInitHandler {
|
|||
],
|
||||
primaryKeys: ['component']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private file: File, private fileProvider: CoreFileProvider, private utils: CoreUtilsProvider,
|
||||
logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private localNotif: LocalNotifications,
|
||||
private captureHelper: CoreEmulatorCaptureHelperProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private appProvider: CoreAppProvider, private localNotifProvider: CoreLocalNotificationsProvider) {
|
||||
this.logger = logger.getInstance('CoreEmulatorHelper');
|
||||
sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* An object to represent a question state.
|
||||
|
@ -64,7 +63,10 @@ export class CoreQuestionProvider {
|
|||
// Variables for database.
|
||||
protected QUESTION_TABLE = 'questions';
|
||||
protected QUESTION_ANSWERS_TABLE = 'question_answers';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreQuestionProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.QUESTION_TABLE,
|
||||
columns: [
|
||||
|
@ -143,7 +145,8 @@ export class CoreQuestionProvider {
|
|||
],
|
||||
primaryKeys: ['component', 'attemptid', 'name']
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
protected QUESTION_PREFIX_REGEX = /q\d+:(\d+)_/;
|
||||
protected STATES: {[name: string]: CoreQuestionState} = {
|
||||
|
@ -245,7 +248,7 @@ export class CoreQuestionProvider {
|
|||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||
private utils: CoreUtilsProvider) {
|
||||
this.logger = logger.getInstance('CoreQuestionProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,9 +16,8 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
|
||||
/**
|
||||
* Service to provide user functionalities.
|
||||
|
@ -32,7 +31,10 @@ export class CoreUserProvider {
|
|||
|
||||
// Variables for database.
|
||||
protected USERS_TABLE = 'users';
|
||||
protected tablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreUserProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.USERS_TABLE,
|
||||
columns: [
|
||||
|
@ -51,14 +53,15 @@ export class CoreUserProvider {
|
|||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
protected logger;
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider,
|
||||
private filepoolProvider: CoreFilepoolProvider) {
|
||||
this.logger = logger.getInstance('CoreUserProvider');
|
||||
this.sitesProvider.createTablesFromSchema(this.tablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreFileProvider } from './file';
|
|||
import { CoreInitDelegate } from './init';
|
||||
import { CoreLoggerProvider } from './logger';
|
||||
import { CorePluginFileDelegate } from './plugin-file-delegate';
|
||||
import { CoreSitesProvider } from './sites';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from './sites';
|
||||
import { CoreWSProvider } from './ws';
|
||||
import { CoreDomUtilsProvider } from './utils/dom';
|
||||
import { CoreMimetypeUtilsProvider } from './utils/mimetype';
|
||||
|
@ -306,7 +306,10 @@ export class CoreFilepoolProvider {
|
|||
primaryKeys: ['siteId', 'fileId']
|
||||
}
|
||||
];
|
||||
protected sitesTablesSchema: SQLiteDBTableSchema[] = [
|
||||
protected siteSchma: CoreSiteSchema = {
|
||||
name: 'CoreFilepoolProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.FILES_TABLE,
|
||||
columns: [
|
||||
|
@ -413,8 +416,9 @@ export class CoreFilepoolProvider {
|
|||
type: 'TEXT'
|
||||
}
|
||||
]
|
||||
},
|
||||
];
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
protected logger;
|
||||
protected appDB: SQLiteDB;
|
||||
|
@ -443,7 +447,7 @@ export class CoreFilepoolProvider {
|
|||
this.appDB = this.appProvider.getDB();
|
||||
this.appDB.createTablesFromSchema(this.appTablesSchema);
|
||||
|
||||
this.sitesProvider.createTablesFromSchema(this.sitesTablesSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchma);
|
||||
|
||||
initDelegate.ready().then(() => {
|
||||
// Waiting for the app to be ready to start processing the queue.
|
||||
|
|
|
@ -265,6 +265,50 @@ export class CoreSitesProvider {
|
|||
}
|
||||
];
|
||||
|
||||
// Site schema for this provider.
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreSitesProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: CoreSite.WS_CACHE_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'TEXT',
|
||||
primaryKey: true
|
||||
},
|
||||
{
|
||||
name: 'data',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'key',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'expirationTime',
|
||||
type: 'INTEGER'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: CoreSite.CONFIG_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'TEXT',
|
||||
unique: true,
|
||||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'value'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private http: HttpClient, private sitesFactory: CoreSitesFactoryProvider,
|
||||
private appProvider: CoreAppProvider, private translate: TranslateService, private urlUtils: CoreUrlUtilsProvider,
|
||||
private eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider,
|
||||
|
@ -273,6 +317,7 @@ export class CoreSitesProvider {
|
|||
|
||||
this.appDB = appProvider.getDB();
|
||||
this.appDB.createTablesFromSchema(this.appTablesSchema);
|
||||
this.registerSiteSchema(this.siteSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreEventsProvider } from './events';
|
||||
import { CoreSitesProvider } from './sites';
|
||||
import { SQLiteDBTableSchema } from '@classes/sqlitedb';
|
||||
import { CoreSitesProvider, CoreSiteSchema } from './sites';
|
||||
|
||||
/*
|
||||
* Service that provides some features regarding synchronization.
|
||||
|
@ -25,7 +24,11 @@ export class CoreSyncProvider {
|
|||
|
||||
// Variables for the database.
|
||||
protected SYNC_TABLE = 'sync';
|
||||
protected tableSchema: SQLiteDBTableSchema = {
|
||||
protected siteSchema: CoreSiteSchema = {
|
||||
name: 'CoreSyncProvider',
|
||||
version: 1,
|
||||
tables: [
|
||||
{
|
||||
name: this.SYNC_TABLE,
|
||||
columns: [
|
||||
{
|
||||
|
@ -48,13 +51,15 @@ export class CoreSyncProvider {
|
|||
}
|
||||
],
|
||||
primaryKeys: ['component', 'id']
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Store blocked sync objects.
|
||||
protected blockedItems: { [siteId: string]: { [blockId: string]: { [operation: string]: boolean } } } = {};
|
||||
|
||||
constructor(eventsProvider: CoreEventsProvider, private sitesProvider: CoreSitesProvider) {
|
||||
this.sitesProvider.createTableFromSchema(this.tableSchema);
|
||||
this.sitesProvider.registerSiteSchema(this.siteSchema);
|
||||
|
||||
// Unblock all blocks on logout.
|
||||
eventsProvider.on(CoreEventsProvider.LOGOUT, (data) => {
|
||||
|
|
Loading…
Reference in New Issue