MOBILE-2404 db: Use lowercase in DB of modules and question
parent
7ef4726bf5
commit
4cc9934d22
|
@ -384,7 +384,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy {
|
|||
|
||||
// Check if there's any offline data for this submission.
|
||||
promises.push(this.assignOfflineProvider.getSubmission(assign.id, this.submitId).then((data) => {
|
||||
this.hasOffline = data && data.pluginData && Object.keys(data.pluginData).length > 0;
|
||||
this.hasOffline = data && data.plugindata && Object.keys(data.plugindata).length > 0;
|
||||
this.submittedOffline = data && data.submitted;
|
||||
}).catch(() => {
|
||||
// No offline data found.
|
||||
|
@ -561,8 +561,8 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy {
|
|||
this.originalGrades.grade = this.grade.grade;
|
||||
}
|
||||
|
||||
this.grade.applyToAll = data.applyToAll;
|
||||
this.grade.addAttempt = data.addAttempt;
|
||||
this.grade.applyToAll = data.applytoall;
|
||||
this.grade.addAttempt = data.addattempt;
|
||||
this.originalGrades.applyToAll = this.grade.applyToAll;
|
||||
this.originalGrades.addAttempt = this.grade.addAttempt;
|
||||
|
||||
|
|
|
@ -128,13 +128,13 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
|
|||
return this.assignOfflineProvider.getSubmissionGrade(this.assign.id, this.userId).catch(() => {
|
||||
// No offline data found.
|
||||
}).then((offlineData) => {
|
||||
if (offlineData && offlineData.pluginData && offlineData.pluginData.assignfeedbackcomments_editor) {
|
||||
if (offlineData && offlineData.plugindata && offlineData.plugindata.assignfeedbackcomments_editor) {
|
||||
// Save offline as draft.
|
||||
this.isSent = false;
|
||||
this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin,
|
||||
offlineData.pluginData.assignfeedbackcomments_editor);
|
||||
offlineData.plugindata.assignfeedbackcomments_editor);
|
||||
|
||||
return offlineData.pluginData.assignfeedbackcomments_editor.text;
|
||||
return offlineData.plugindata.assignfeedbackcomments_editor.text;
|
||||
}
|
||||
|
||||
// No offline data found, return online text.
|
||||
|
|
|
@ -128,8 +128,8 @@ export class AddonModAssignFeedbackCommentsHandler implements AddonModAssignFeed
|
|||
return this.assignOfflineProvider.getSubmissionGrade(assign.id, userId).catch(() => {
|
||||
// No offline data found.
|
||||
}).then((data) => {
|
||||
if (data && data.pluginData && data.pluginData.assignfeedbackcomments_editor) {
|
||||
return data.pluginData.assignfeedbackcomments_editor.text;
|
||||
if (data && data.plugindata && data.plugindata.assignfeedbackcomments_editor) {
|
||||
return data.plugindata.assignfeedbackcomments_editor.text;
|
||||
}
|
||||
|
||||
// No offline data found, get text from plugin.
|
||||
|
|
|
@ -156,7 +156,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy {
|
|||
|
||||
// Check if there's any offline data for this submission.
|
||||
return this.assignOfflineProvider.getSubmission(this.assign.id, this.userId).then((data) => {
|
||||
this.hasOffline = data && data.pluginData && Object.keys(data.pluginData).length > 0;
|
||||
this.hasOffline = data && data.plugindata && Object.keys(data.plugindata).length > 0;
|
||||
}).catch(() => {
|
||||
// No offline data found.
|
||||
this.hasOffline = false;
|
||||
|
|
|
@ -35,23 +35,23 @@ export class AddonModAssignOfflineProvider {
|
|||
name: this.SUBMISSIONS_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'assignId',
|
||||
name: 'assignid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'courseId',
|
||||
name: 'courseid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'pluginData',
|
||||
name: 'plugindata',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'onlineTimemodified',
|
||||
name: 'onlinetimemodified',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -67,25 +67,25 @@ export class AddonModAssignOfflineProvider {
|
|||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'submissionStatement',
|
||||
name: 'submissionstatement',
|
||||
type: 'INTEGER'
|
||||
}
|
||||
],
|
||||
primaryKeys: ['assignId', 'userId']
|
||||
primaryKeys: ['assignid', 'userid']
|
||||
},
|
||||
{
|
||||
name: this.SUBMISSIONS_GRADES_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'assignId',
|
||||
name: 'assignid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'courseId',
|
||||
name: 'courseid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -93,19 +93,19 @@ export class AddonModAssignOfflineProvider {
|
|||
type: 'REAL'
|
||||
},
|
||||
{
|
||||
name: 'attemptNumber',
|
||||
name: 'attemptnumber',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'addAttempt',
|
||||
name: 'addattempt',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'workflowState',
|
||||
name: 'workflowstate',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'applyToAll',
|
||||
name: 'applytoall',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ export class AddonModAssignOfflineProvider {
|
|||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
name: 'pluginData',
|
||||
name: 'plugindata',
|
||||
type: 'TEXT'
|
||||
},
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ export class AddonModAssignOfflineProvider {
|
|||
type: 'INTEGER'
|
||||
}
|
||||
],
|
||||
primaryKeys: ['assignId', 'userId']
|
||||
primaryKeys: ['assignid', 'userid']
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -143,7 +143,7 @@ export class AddonModAssignOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().deleteRecords(this.SUBMISSIONS_TABLE, {assignId, userId});
|
||||
return site.getDb().deleteRecords(this.SUBMISSIONS_TABLE, {assignid: assignId, userid: userId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ export class AddonModAssignOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().deleteRecords(this.SUBMISSIONS_GRADES_TABLE, {assignId, userId});
|
||||
return site.getDb().deleteRecords(this.SUBMISSIONS_GRADES_TABLE, {assignid: assignId, userid: userId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ export class AddonModAssignOfflineProvider {
|
|||
|
||||
// Get assign id.
|
||||
results = results.map((object) => {
|
||||
return object.assignId;
|
||||
return object.assignid;
|
||||
});
|
||||
|
||||
// Get unique values.
|
||||
|
@ -206,7 +206,7 @@ export class AddonModAssignOfflineProvider {
|
|||
|
||||
// Parse the plugin data.
|
||||
submissions.forEach((submission) => {
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
});
|
||||
|
||||
return submissions;
|
||||
|
@ -227,7 +227,7 @@ export class AddonModAssignOfflineProvider {
|
|||
// Parse the plugin data and outcomes.
|
||||
submissions.forEach((submission) => {
|
||||
submission.outcomes = this.textUtils.parseJSON(submission.outcomes, {});
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
});
|
||||
|
||||
return submissions;
|
||||
|
@ -243,12 +243,12 @@ export class AddonModAssignOfflineProvider {
|
|||
*/
|
||||
getAssignSubmissions(assignId: number, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSiteDb(siteId).then((db) => {
|
||||
return db.getRecords(this.SUBMISSIONS_TABLE, {assignId});
|
||||
return db.getRecords(this.SUBMISSIONS_TABLE, {assignid: assignId});
|
||||
}).then((submissions) => {
|
||||
|
||||
// Parse the plugin data.
|
||||
submissions.forEach((submission) => {
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
});
|
||||
|
||||
return submissions;
|
||||
|
@ -264,13 +264,13 @@ export class AddonModAssignOfflineProvider {
|
|||
*/
|
||||
getAssignSubmissionsGrade(assignId: number, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSiteDb(siteId).then((db) => {
|
||||
return db.getRecords(this.SUBMISSIONS_GRADES_TABLE, {assignId});
|
||||
return db.getRecords(this.SUBMISSIONS_GRADES_TABLE, {assignid: assignId});
|
||||
}).then((submissions) => {
|
||||
|
||||
// Parse the plugin data and outcomes.
|
||||
submissions.forEach((submission) => {
|
||||
submission.outcomes = this.textUtils.parseJSON(submission.outcomes, {});
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
});
|
||||
|
||||
return submissions;
|
||||
|
@ -289,11 +289,11 @@ export class AddonModAssignOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().getRecord(this.SUBMISSIONS_TABLE, {assignId, userId});
|
||||
return site.getDb().getRecord(this.SUBMISSIONS_TABLE, {assignid: assignId, userid: userId});
|
||||
}).then((submission) => {
|
||||
|
||||
// Parse the plugin data.
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
|
||||
return submission;
|
||||
});
|
||||
|
@ -331,12 +331,12 @@ export class AddonModAssignOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().getRecord(this.SUBMISSIONS_GRADES_TABLE, {assignId, userId});
|
||||
return site.getDb().getRecord(this.SUBMISSIONS_GRADES_TABLE, {assignid: assignId, userid: userId});
|
||||
}).then((submission) => {
|
||||
|
||||
// Parse the plugin data and outcomes.
|
||||
submission.outcomes = this.textUtils.parseJSON(submission.outcomes, {});
|
||||
submission.pluginData = this.textUtils.parseJSON(submission.pluginData, {});
|
||||
submission.plugindata = this.textUtils.parseJSON(submission.plugindata, {});
|
||||
|
||||
return submission;
|
||||
});
|
||||
|
@ -410,18 +410,18 @@ export class AddonModAssignOfflineProvider {
|
|||
const now = this.timeUtils.timestamp();
|
||||
|
||||
return {
|
||||
assignId: assignId,
|
||||
courseId: courseId,
|
||||
userId: userId,
|
||||
onlineTimemodified: timemodified,
|
||||
assignid: assignId,
|
||||
courseid: courseId,
|
||||
userid: userId,
|
||||
onlinetimemodified: timemodified,
|
||||
timecreated: now,
|
||||
timemodified: now
|
||||
};
|
||||
}).then((submission) => {
|
||||
// Mark the submission.
|
||||
submission.submitted = submitted ? 1 : 0;
|
||||
submission.submissionStatement = acceptStatement ? 1 : 0;
|
||||
submission.pluginData = submission.pluginData ? JSON.stringify(submission.pluginData) : '{}';
|
||||
submission.submissionstatement = acceptStatement ? 1 : 0;
|
||||
submission.plugindata = submission.plugindata ? JSON.stringify(submission.plugindata) : '{}';
|
||||
|
||||
return site.getDb().insertRecord(this.SUBMISSIONS_TABLE, submission);
|
||||
});
|
||||
|
@ -448,14 +448,14 @@ export class AddonModAssignOfflineProvider {
|
|||
|
||||
const now = this.timeUtils.timestamp(),
|
||||
entry = {
|
||||
assignId: assignId,
|
||||
courseId: courseId,
|
||||
pluginData: pluginData ? JSON.stringify(pluginData) : '{}',
|
||||
userId: userId,
|
||||
assignid: assignId,
|
||||
courseid: courseId,
|
||||
plugindata: pluginData ? JSON.stringify(pluginData) : '{}',
|
||||
userid: userId,
|
||||
submitted: submitted ? 1 : 0,
|
||||
timecreated: now,
|
||||
timemodified: now,
|
||||
onlineTimemodified: timemodified
|
||||
onlinetimemodified: timemodified
|
||||
};
|
||||
|
||||
return site.getDb().insertRecord(this.SUBMISSIONS_TABLE, entry);
|
||||
|
@ -484,16 +484,16 @@ export class AddonModAssignOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const now = this.timeUtils.timestamp(),
|
||||
entry = {
|
||||
assignId: assignId,
|
||||
userId: userId,
|
||||
courseId: courseId,
|
||||
assignid: assignId,
|
||||
userid: userId,
|
||||
courseid: courseId,
|
||||
grade: grade,
|
||||
attemptNumber: attemptNumber,
|
||||
addAttempt: addAttempt ? 1 : 0,
|
||||
workflowState: workflowState,
|
||||
applyToAll: applyToAll ? 1 : 0,
|
||||
attemptnumber: attemptNumber,
|
||||
addattempt: addAttempt ? 1 : 0,
|
||||
workflowstate: workflowState,
|
||||
applytoall: applyToAll ? 1 : 0,
|
||||
outcomes: outcomes ? JSON.stringify(outcomes) : '{}',
|
||||
pluginData: pluginData ? JSON.stringify(pluginData) : '{}',
|
||||
plugindata: pluginData ? JSON.stringify(pluginData) : '{}',
|
||||
timemodified: now
|
||||
};
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
return Promise.reject(null);
|
||||
}
|
||||
|
||||
courseId = submissions.length > 0 ? submissions[0].courseId : grades[0].courseId;
|
||||
courseId = submissions.length > 0 ? submissions[0].courseid : grades[0].courseid;
|
||||
|
||||
return this.assignProvider.getAssignmentById(courseId, assignId, siteId).then((assignData) => {
|
||||
assign = assignData;
|
||||
|
@ -264,7 +264,7 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
* @return {Promise<any>} Promise resolved if success, rejected otherwise.
|
||||
*/
|
||||
protected syncSubmission(assign: any, offlineData: any, warnings: string[], siteId?: string): Promise<any> {
|
||||
const userId = offlineData.userId,
|
||||
const userId = offlineData.userid,
|
||||
pluginData = {};
|
||||
let discardError,
|
||||
submission;
|
||||
|
@ -274,7 +274,7 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
submission = this.assignProvider.getSubmissionObjectFromAttempt(assign, status.lastattempt);
|
||||
|
||||
if (submission.timemodified != offlineData.onlineTimemodified) {
|
||||
if (submission.timemodified != offlineData.onlinetimemodified) {
|
||||
// The submission was modified in Moodle, discard the submission.
|
||||
discardError = this.translate.instant('addon.mod_assign.warningsubmissionmodified');
|
||||
|
||||
|
@ -300,7 +300,7 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
return promise.then(() => {
|
||||
if (assign.submissiondrafts && offlineData.submitted) {
|
||||
// The user submitted the assign manually. Submit it for grading.
|
||||
return this.assignProvider.submitForGradingOnline(assign.id, offlineData.submissionStatement, siteId);
|
||||
return this.assignProvider.submitForGradingOnline(assign.id, offlineData.submissionstatement, siteId);
|
||||
}
|
||||
}).then(() => {
|
||||
// Submission data sent, update cached data. No need to block the user for this.
|
||||
|
@ -355,7 +355,7 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
protected syncSubmissionGrade(assign: any, offlineData: any, warnings: string[], courseId: number, siteId?: string)
|
||||
: Promise<any> {
|
||||
|
||||
const userId = offlineData.userId;
|
||||
const userId = offlineData.userid;
|
||||
let discardError;
|
||||
|
||||
return this.assignProvider.getSubmissionStatus(assign.id, userId, false, true, true, siteId).then((status) => {
|
||||
|
@ -394,9 +394,9 @@ export class AddonModAssignSyncProvider extends CoreSyncBaseProvider {
|
|||
});
|
||||
}).then(() => {
|
||||
// Now submit the grade.
|
||||
return this.assignProvider.submitGradingFormOnline(assign.id, userId, offlineData.grade, offlineData.attemptNumber,
|
||||
offlineData.addAttempt, offlineData.workflowState, offlineData.applyToAll, offlineData.outcomes,
|
||||
offlineData.pluginData, siteId).then(() => {
|
||||
return this.assignProvider.submitGradingFormOnline(assign.id, userId, offlineData.grade, offlineData.attemptnumber,
|
||||
offlineData.addattempt, offlineData.workflowstate, offlineData.applytoall, offlineData.outcomes,
|
||||
offlineData.plugindata, siteId).then(() => {
|
||||
|
||||
// Grades sent, update cached data. No need to block the user for this.
|
||||
this.assignProvider.getSubmissionStatus(assign.id, userId, false, true, true, siteId);
|
||||
|
|
|
@ -47,10 +47,10 @@ export class AddonModAssignSubmissionFileComponent extends AddonModAssignSubmiss
|
|||
this.assignOfflineProvider.getSubmission(this.assign.id).catch(() => {
|
||||
// Error getting data, assume there's no offline submission.
|
||||
}).then((offlineData) => {
|
||||
if (offlineData && offlineData.pluginData && offlineData.pluginData.files_filemanager) {
|
||||
if (offlineData && offlineData.plugindata && offlineData.plugindata.files_filemanager) {
|
||||
// It has offline data.
|
||||
let promise;
|
||||
if (offlineData.pluginData.files_filemanager.offline) {
|
||||
if (offlineData.plugindata.files_filemanager.offline) {
|
||||
promise = this.assignHelper.getStoredSubmissionFiles(this.assign.id,
|
||||
AddonModAssignSubmissionFileHandler.FOLDER_NAME);
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ export class AddonModAssignSubmissionFileComponent extends AddonModAssignSubmiss
|
|||
}
|
||||
|
||||
return promise.then((offlineFiles) => {
|
||||
const onlineFiles = offlineData.pluginData.files_filemanager.online || [];
|
||||
const onlineFiles = offlineData.plugindata.files_filemanager.online || [];
|
||||
offlineFiles = this.fileUploaderProvider.markOfflineFiles(offlineFiles);
|
||||
|
||||
this.files = onlineFiles.concat(offlineFiles);
|
||||
|
|
|
@ -237,9 +237,9 @@ export class AddonModAssignSubmissionFileHandler implements AddonModAssignSubmis
|
|||
return this.assignOfflineProvider.getSubmission(assign.id, submission.userid).catch(() => {
|
||||
// No offline data found.
|
||||
}).then((offlineData) => {
|
||||
if (offlineData && offlineData.pluginData && offlineData.pluginData.files_filemanager) {
|
||||
if (offlineData && offlineData.plugindata && offlineData.plugindata.files_filemanager) {
|
||||
// Has offline data, return the number of files.
|
||||
return offlineData.pluginData.files_filemanager.offline + offlineData.pluginData.files_filemanager.online.length;
|
||||
return offlineData.plugindata.files_filemanager.offline + offlineData.plugindata.files_filemanager.online.length;
|
||||
}
|
||||
|
||||
// No offline data, return the number of online files.
|
||||
|
@ -333,7 +333,7 @@ export class AddonModAssignSubmissionFileHandler implements AddonModAssignSubmis
|
|||
prepareSyncData(assign: any, submission: any, plugin: any, offlineData: any, pluginData: any, siteId?: string)
|
||||
: void | Promise<any> {
|
||||
|
||||
const filesData = offlineData && offlineData.pluginData && offlineData.pluginData.files_filemanager;
|
||||
const filesData = offlineData && offlineData.plugindata && offlineData.plugindata.files_filemanager;
|
||||
if (filesData) {
|
||||
// Has some data to sync.
|
||||
let files = filesData.online || [],
|
||||
|
|
|
@ -68,8 +68,8 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
|
|||
return this.assignOfflineProvider.getSubmission(this.assign.id).catch(() => {
|
||||
// No offline data found.
|
||||
}).then((offlineData) => {
|
||||
if (offlineData && offlineData.pluginData && offlineData.pluginData.onlinetext_editor) {
|
||||
return offlineData.pluginData.onlinetext_editor.text;
|
||||
if (offlineData && offlineData.plugindata && offlineData.plugindata.onlinetext_editor) {
|
||||
return offlineData.plugindata.onlinetext_editor.text;
|
||||
}
|
||||
|
||||
// No offline data found, return online text.
|
||||
|
|
|
@ -188,8 +188,8 @@ export class AddonModAssignSubmissionOnlineTextHandler implements AddonModAssign
|
|||
return this.assignOfflineProvider.getSubmission(assign.id, submission.userid).catch(() => {
|
||||
// No offline data found.
|
||||
}).then((data) => {
|
||||
if (data && data.pluginData && data.pluginData.onlinetext_editor) {
|
||||
return data.pluginData.onlinetext_editor.text;
|
||||
if (data && data.plugindata && data.plugindata.onlinetext_editor) {
|
||||
return data.plugindata.onlinetext_editor.text;
|
||||
}
|
||||
|
||||
// No offline data found, get text from plugin.
|
||||
|
|
|
@ -39,7 +39,7 @@ export class AddonModScormOfflineProvider {
|
|||
name: this.ATTEMPTS_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'scormId',
|
||||
name: 'scormid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
|
@ -49,12 +49,12 @@ export class AddonModScormOfflineProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'courseId',
|
||||
name: 'courseid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -70,13 +70,13 @@ export class AddonModScormOfflineProvider {
|
|||
type: 'TEXT'
|
||||
},
|
||||
],
|
||||
primaryKeys: ['scormId', 'userId', 'attempt']
|
||||
primaryKeys: ['scormid', 'userid', 'attempt']
|
||||
},
|
||||
{
|
||||
name: this.TRACKS_TABLE,
|
||||
columns: [
|
||||
{
|
||||
name: 'scormId',
|
||||
name: 'scormid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
|
@ -86,12 +86,12 @@ export class AddonModScormOfflineProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'scoId',
|
||||
name: 'scoid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ export class AddonModScormOfflineProvider {
|
|||
type: 'INTEGER'
|
||||
},
|
||||
],
|
||||
primaryKeys: ['scormId', 'userId', 'attempt', 'scoId', 'element']
|
||||
primaryKeys: ['scormid', 'userid', 'attempt', 'scoid', 'element']
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -145,7 +145,9 @@ export class AddonModScormOfflineProvider {
|
|||
this.logger.debug('Change attempt number from ' + attempt + ' to ' + newAttempt + ' in SCORM ' + scormId);
|
||||
|
||||
// Update the attempt number.
|
||||
const db = site.getDb();
|
||||
const db = site.getDb(),
|
||||
currentAttemptConditions = {scormid: scormId, userid: userId, attempt: attempt},
|
||||
newAttemptConditions = {scormid: scormId, userid: userId, attempt: newAttempt};
|
||||
let newData: any = {
|
||||
attempt: newAttempt,
|
||||
timemodified: this.timeUtils.timestamp()
|
||||
|
@ -154,7 +156,7 @@ export class AddonModScormOfflineProvider {
|
|||
// Block the SCORM so it can't be synced.
|
||||
this.syncProvider.blockOperation(AddonModScormProvider.COMPONENT, scormId, 'changeAttemptNumber', site.id);
|
||||
|
||||
return db.updateRecords(this.ATTEMPTS_TABLE, newData, {scormId, userId, attempt}).then(() => {
|
||||
return db.updateRecords(this.ATTEMPTS_TABLE, newData, currentAttemptConditions).then(() => {
|
||||
|
||||
// Now update the attempt number of all the tracks and mark them as not synced.
|
||||
newData = {
|
||||
|
@ -162,9 +164,9 @@ export class AddonModScormOfflineProvider {
|
|||
synced: 0
|
||||
};
|
||||
|
||||
return db.updateRecords(this.TRACKS_TABLE, newData, {scormId, userId, attempt}).catch((error) => {
|
||||
return db.updateRecords(this.TRACKS_TABLE, newData, currentAttemptConditions).catch((error) => {
|
||||
// Failed to update the tracks, restore the old attempt number.
|
||||
return db.updateRecords(this.ATTEMPTS_TABLE, { attempt }, {scormId, userId, attempt: newAttempt}).then(() => {
|
||||
return db.updateRecords(this.ATTEMPTS_TABLE, { attempt: attempt }, newAttemptConditions).then(() => {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
});
|
||||
|
@ -199,10 +201,10 @@ export class AddonModScormOfflineProvider {
|
|||
// Create attempt in DB.
|
||||
const db = site.getDb(),
|
||||
entry: any = {
|
||||
scormId: scorm.id,
|
||||
userId: userId,
|
||||
scormid: scorm.id,
|
||||
userid: userId,
|
||||
attempt: attempt,
|
||||
courseId: scorm.course,
|
||||
courseid: scorm.course,
|
||||
timecreated: this.timeUtils.timestamp(),
|
||||
timemodified: this.timeUtils.timestamp(),
|
||||
snapshot: null
|
||||
|
@ -256,10 +258,10 @@ export class AddonModScormOfflineProvider {
|
|||
db = site.getDb();
|
||||
|
||||
// Delete the attempt.
|
||||
promises.push(db.deleteRecords(this.ATTEMPTS_TABLE, {scormId, userId, attempt}));
|
||||
promises.push(db.deleteRecords(this.ATTEMPTS_TABLE, {scormid: scormId, userid: userId, attempt: attempt}));
|
||||
|
||||
// Delete all the tracks.
|
||||
promises.push(db.deleteRecords(this.TRACKS_TABLE, {scormId, userId, attempt}));
|
||||
promises.push(db.deleteRecords(this.TRACKS_TABLE, {scormid: scormId, userid: userId, attempt: attempt}));
|
||||
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
@ -352,11 +354,11 @@ export class AddonModScormOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().getRecord(this.ATTEMPTS_TABLE, {scormId, userId, attempt}).then((entry) => {
|
||||
entry.snapshot = this.textUtils.parseJSON(entry.snapshot);
|
||||
return site.getDb().getRecord(this.ATTEMPTS_TABLE, {scormid: scormId, userid: userId, attempt: attempt});
|
||||
}).then((entry) => {
|
||||
entry.snapshot = this.textUtils.parseJSON(entry.snapshot);
|
||||
|
||||
return entry;
|
||||
});
|
||||
return entry;;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -389,7 +391,7 @@ export class AddonModScormOfflineProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
userId = userId || site.getUserId();
|
||||
|
||||
return site.getDb().getRecords(this.ATTEMPTS_TABLE, {scormId, userId});
|
||||
return site.getDb().getRecords(this.ATTEMPTS_TABLE, {scormid: scormId, userid: userId});
|
||||
}).then((attempts) => {
|
||||
attempts.forEach((attempt) => {
|
||||
attempt.snapshot = this.textUtils.parseJSON(attempt.snapshot);
|
||||
|
@ -454,8 +456,8 @@ export class AddonModScormOfflineProvider {
|
|||
userId = userId || site.getUserId();
|
||||
|
||||
const conditions: any = {
|
||||
scormId: scormId,
|
||||
userId: userId,
|
||||
scormid: scormId,
|
||||
userid: userId,
|
||||
attempt: attempt
|
||||
};
|
||||
|
||||
|
@ -513,7 +515,7 @@ export class AddonModScormOfflineProvider {
|
|||
|
||||
// Gather user data retrieved from DB, grouping it by scoid.
|
||||
entries.forEach((entry) => {
|
||||
const scoId = entry.scoId;
|
||||
const scoId = entry.scoid;
|
||||
|
||||
if (!response[scoId]) {
|
||||
// Initialize SCO.
|
||||
|
@ -690,9 +692,9 @@ export class AddonModScormOfflineProvider {
|
|||
value: any, synchronous?: boolean): boolean | Promise<any> {
|
||||
|
||||
const entry = {
|
||||
userId: userId,
|
||||
scormId: scormId,
|
||||
scoId: scoId,
|
||||
userid: userId,
|
||||
scormid: scormId,
|
||||
scoid: scoId,
|
||||
attempt: attempt,
|
||||
element: element,
|
||||
value: typeof value == 'undefined' ? null : JSON.stringify(value),
|
||||
|
@ -789,10 +791,10 @@ export class AddonModScormOfflineProvider {
|
|||
this.logger.debug('Mark SCO ' + scoId + ' as synced for attempt ' + attempt + ' in SCORM ' + scormId);
|
||||
|
||||
return site.getDb().updateRecords(this.TRACKS_TABLE, {synced: 1}, {
|
||||
scormId: scormId,
|
||||
userId: userId,
|
||||
scormid: scormId,
|
||||
userid: userId,
|
||||
attempt: attempt,
|
||||
scoId: scoId,
|
||||
scoid: scoId,
|
||||
synced: 0
|
||||
});
|
||||
});
|
||||
|
@ -914,7 +916,7 @@ export class AddonModScormOfflineProvider {
|
|||
snapshot: JSON.stringify(this.removeDefaultData(userData))
|
||||
};
|
||||
|
||||
return site.getDb().updateRecords(this.ATTEMPTS_TABLE, newData, { scormId, userId, attempt });
|
||||
return site.getDb().updateRecords(this.ATTEMPTS_TABLE, newData, { scormid: scormId, userid: userId, attempt: attempt });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,13 +379,13 @@ export class AddonModScormSyncProvider extends CoreSyncBaseProvider {
|
|||
// We need to add the synced data to the snapshot.
|
||||
return this.scormOfflineProvider.getScormStoredData(scormId, attempt, false, true, siteId).then((synced) => {
|
||||
synced.forEach((entry) => {
|
||||
if (!data[entry.scoId]) {
|
||||
data[entry.scoId] = {
|
||||
scoid: entry.scoId,
|
||||
if (!data[entry.scoid]) {
|
||||
data[entry.scoid] = {
|
||||
scoid: entry.scoid,
|
||||
userdata: {}
|
||||
};
|
||||
}
|
||||
data[entry.scoId].userdata[entry.element] = entry.value;
|
||||
data[entry.scoid].userdata[entry.element] = entry.value;
|
||||
});
|
||||
|
||||
return this.scormOfflineProvider.setAttemptSnapshot(scormId, attempt, data, siteId);
|
||||
|
@ -461,12 +461,12 @@ export class AddonModScormSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
// Get the IDs of all the SCORMs that have something to be synced.
|
||||
attempts.forEach((attempt) => {
|
||||
if (ids.indexOf(attempt.scormId) == -1) {
|
||||
ids.push(attempt.scormId);
|
||||
if (ids.indexOf(attempt.scormid) == -1) {
|
||||
ids.push(attempt.scormid);
|
||||
|
||||
scorms.push({
|
||||
id: attempt.scormId,
|
||||
courseId: attempt.courseId
|
||||
id: attempt.scormid,
|
||||
courseId: attempt.courseid
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -517,11 +517,11 @@ export class AddonModScormSyncProvider extends CoreSyncBaseProvider {
|
|||
// Get data to send (only elements with dots like cmi.core.exit, in Mobile we store more data to make offline work).
|
||||
entries.forEach((entry) => {
|
||||
if (entry.element.indexOf('.') > -1) {
|
||||
if (!scos[entry.scoId]) {
|
||||
scos[entry.scoId] = [];
|
||||
if (!scos[entry.scoid]) {
|
||||
scos[entry.scoid] = [];
|
||||
}
|
||||
|
||||
scos[entry.scoId].push({
|
||||
scos[entry.scoid].push({
|
||||
element: entry.element,
|
||||
value: entry.value
|
||||
});
|
||||
|
|
|
@ -73,7 +73,7 @@ export class CoreQuestionProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'attemptId',
|
||||
name: 'attemptid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
|
@ -83,11 +83,11 @@ export class CoreQuestionProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'componentId',
|
||||
name: 'componentid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ export class CoreQuestionProvider {
|
|||
type: 'TEXT'
|
||||
}
|
||||
],
|
||||
primaryKeys: ['component', 'attemptId', 'slot']
|
||||
primaryKeys: ['component', 'attemptid', 'slot']
|
||||
},
|
||||
{
|
||||
name: this.QUESTION_ANSWERS_TABLE,
|
||||
|
@ -110,7 +110,7 @@ export class CoreQuestionProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'attemptId',
|
||||
name: 'attemptid',
|
||||
type: 'INTEGER',
|
||||
notNull: true
|
||||
},
|
||||
|
@ -120,15 +120,15 @@ export class CoreQuestionProvider {
|
|||
notNull: true
|
||||
},
|
||||
{
|
||||
name: 'componentId',
|
||||
name: 'componentid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'userId',
|
||||
name: 'userid',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
name: 'questionSlot',
|
||||
name: 'questionslot',
|
||||
type: 'INTEGER'
|
||||
},
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ export class CoreQuestionProvider {
|
|||
type: 'INTEGER'
|
||||
}
|
||||
],
|
||||
primaryKeys: ['component', 'attemptId', 'name']
|
||||
primaryKeys: ['component', 'attemptid', 'name']
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -310,7 +310,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
getAnswer(component: string, attemptId: number, name: string, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecord(this.QUESTION_ANSWERS_TABLE, {component, attemptId, name});
|
||||
return site.getDb().getRecord(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId, name: name});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
getAttemptAnswers(component: string, attemptId: number, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecords(this.QUESTION_ANSWERS_TABLE, {component, attemptId});
|
||||
return site.getDb().getRecords(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
getAttemptQuestions(component: string, attemptId: number, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecords(this.QUESTION_TABLE, {component, attemptId});
|
||||
return site.getDb().getRecords(this.QUESTION_TABLE, {component: component, attemptid: attemptId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
getQuestion(component: string, attemptId: number, slot: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecord(this.QUESTION_TABLE, {component, attemptId, slot});
|
||||
return site.getDb().getRecord(this.QUESTION_TABLE, {component: component, attemptid: attemptId, slot: slot});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -405,8 +405,9 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
getQuestionAnswers(component: string, attemptId: number, slot: number, filter?: boolean, siteId?: string): Promise<any[]> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().getRecords(this.QUESTION_ANSWERS_TABLE, {component, attemptId, questionSlot: slot})
|
||||
.then((answers) => {
|
||||
return site.getDb().getRecords(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId,
|
||||
questionslot: slot}).then((answers) => {
|
||||
|
||||
if (filter) {
|
||||
// Get only answers that isn't "extra" data like sequencecheck or certainty.
|
||||
return this.getBasicAnswersFromArray(answers);
|
||||
|
@ -467,7 +468,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
removeAttemptAnswers(component: string, attemptId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component, attemptId});
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -481,7 +482,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
removeAttemptQuestions(component: string, attemptId: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().deleteRecords(this.QUESTION_TABLE, {component, attemptId});
|
||||
return site.getDb().deleteRecords(this.QUESTION_TABLE, {component: component, attemptid: attemptId});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -496,7 +497,8 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
removeAnswer(component: string, attemptId: number, name: string, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component, attemptId, name});
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId,
|
||||
name: name});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -511,7 +513,7 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
removeQuestion(component: string, attemptId: number, slot: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().deleteRecords(this.QUESTION_TABLE, {component, attemptId, slot});
|
||||
return site.getDb().deleteRecords(this.QUESTION_TABLE, {component: component, attemptid: attemptId, slot: slot});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -526,7 +528,8 @@ export class CoreQuestionProvider {
|
|||
*/
|
||||
removeQuestionAnswers(component: string, attemptId: number, slot: number, siteId?: string): Promise<any> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component, attemptId, questionSlot: slot});
|
||||
return site.getDb().deleteRecords(this.QUESTION_ANSWERS_TABLE, {component: component, attemptid: attemptId,
|
||||
questionslot: slot});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -568,10 +571,10 @@ export class CoreQuestionProvider {
|
|||
const value = answers[name],
|
||||
entry = {
|
||||
component: component,
|
||||
componentId: componentId,
|
||||
attemptId: attemptId,
|
||||
userId: userId,
|
||||
questionSlot: this.getQuestionSlotFromName(name),
|
||||
componentid: componentId,
|
||||
attemptid: attemptId,
|
||||
userid: userId,
|
||||
questionslot: this.getQuestionSlotFromName(name),
|
||||
name: name,
|
||||
value: value,
|
||||
timemodified: timemodified
|
||||
|
@ -602,7 +605,7 @@ export class CoreQuestionProvider {
|
|||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const entry = {
|
||||
component: component,
|
||||
componentId: componentId,
|
||||
componentid: componentId,
|
||||
attemptid: attemptId,
|
||||
userid: userId,
|
||||
number: question.number,
|
||||
|
|
Loading…
Reference in New Issue