Skip to content

Commit 1c03904

Browse files
authored
Merge pull request #891 from crazyserver/MOBILE-1666
Mobile 1666
2 parents 77641cd + 5a60f40 commit 1c03904

File tree

10 files changed

+274
-163
lines changed

10 files changed

+274
-163
lines changed

upgrade.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ information provided here is intended especially for developers.
1515
or
1616
ionic state restore
1717
* mm-rich-text-editor now admits a new parameter adjust-height (default: true). It admits an HTML DOM Id string or boolean. Specifying it will adjust height of the editor to the selected element. If true it will adjust to the whole page and false will use height parameter instead.
18+
* Generators on stores are deprecated. Using generators will make Android < 4.4 fail. Use keyPath instead. They will be automatically generated if needed. DB Functions query, update and where are not allowed using compoung indexes see JSdoc DB functions on db.js for more info.
1819

1920
=== 3.2 ===
2021

www/addons/mod/forum/services/forum_offline.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ angular.module('mm.addons.mod_forum')
3636
name: 'timecreated'
3737
},
3838
{
39-
// Not using compound indexes because they seem to have issues with where().
4039
name: 'forumAndUser',
41-
generator: function(obj) {
42-
return [obj.forumid, obj.userid];
43-
}
40+
keyPath: ['forumid', 'userid']
4441
}
4542
]
4643
},
@@ -61,18 +58,12 @@ angular.module('mm.addons.mod_forum')
6158
name: 'timecreated'
6259
},
6360
{
64-
// Not using compound indexes because they seem to have issues with where().
6561
name: 'discussionAndUser',
66-
generator: function(obj) {
67-
return [obj.discussionid, obj.userid];
68-
}
62+
keyPath: ['discussionid', 'userid']
6963
},
7064
{
71-
// Not using compound indexes because they seem to have issues with where().
7265
name: 'forumAndUser',
73-
generator: function(obj) {
74-
return [obj.forumid, obj.userid];
75-
}
66+
keyPath: ['forumid', 'userid']
7667
}
7768
]
7869
}

www/addons/mod/glossary/services/glossary_offline.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ angular.module('mm.addons.mod_glossary')
3232
name: 'userid'
3333
},
3434
{
35-
// Not using compound indexes because they seem to have issues with where().
3635
name: 'glossaryAndUser',
37-
generator: function(obj) {
38-
return [obj.glossaryid, obj.userid];
39-
}
36+
keyPath: ['glossaryid', 'userid']
4037
}
4138
]
4239
}

www/addons/mod/quiz/services/quiz_offline.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ angular.module('mm.addons.mod_quiz')
4040
name: 'finished'
4141
},
4242
{
43-
// Not using compound indexes because they seem to have issues with where().
4443
name: 'quizAndUser',
45-
generator: function(obj) {
46-
return [obj.quizid, obj.userid];
47-
}
44+
keyPath: ['quizid', 'userid']
4845
}
4946
]
5047
}

www/addons/mod/scorm/services/scorm_offline.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ angular.module('mm.addons.mod_scorm')
3939
name: 'timemodified'
4040
},
4141
{
42-
// Not using compound indexes because they seem to have issues with where().
4342
name: 'scormAndUser',
44-
generator: function(obj) {
45-
return [obj.scormid, obj.userid];
46-
}
43+
keyPath: ['scormid', 'userid']
4744
}
4845
]
4946
},
@@ -70,18 +67,12 @@ angular.module('mm.addons.mod_scorm')
7067
name: 'synced'
7168
},
7269
{
73-
// Not using compound indexes because they seem to have issues with where().
7470
name: 'scormUserAttempt',
75-
generator: function(obj) {
76-
return [obj.scormid, obj.userid, obj.attempt];
77-
}
71+
keyPath: ['scormid', 'userid', 'attempt']
7872
},
7973
{
80-
// Not using compound indexes because they seem to have issues with where().
8174
name: 'scormUserAttemptSynced',
82-
generator: function(obj) {
83-
return [obj.scormid, obj.userid, obj.attempt, obj.synced];
84-
}
75+
keyPath: ['scormid', 'userid', 'attempt', 'synced']
8576
}
8677
]
8778
}
@@ -430,16 +421,18 @@ angular.module('mm.addons.mod_scorm')
430421
return $mmSitesManager.getSite(siteId).then(function(site) {
431422
userId = userId || site.getUserId();
432423

433-
var where;
424+
var fileName, where;
434425

435426
if (excludeSynced && excludeNotSynced) {
436427
return $q.when([]);
437428
} else if (excludeSynced || excludeNotSynced) {
438-
where = ['scormUserAttemptSynced', '=', [scormId, userId, attempt, excludeNotSynced ? 1 : 0]];
429+
fileName = 'scormUserAttemptSynced';
430+
where = [scormId, userId, attempt, excludeNotSynced ? 1 : 0];
439431
} else {
440-
where = ['scormUserAttempt', '=', [scormId, userId, attempt]];
432+
fileName = 'scormUserAttempt';
433+
where = [scormId, userId, attempt];
441434
}
442-
return site.getDb().query(mmaModScormOfflineTracksStore, where);
435+
return site.getDb().whereEqual(mmaModScormOfflineTracksStore, fieldName, where);
443436
});
444437
};
445438

www/core/components/question/services/question.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,12 @@ angular.module('mm.core.question')
4242
name: 'state'
4343
},
4444
{
45-
// Not using compound indexes because they seem to have issues with where().
4645
name: 'componentAndAttempt',
47-
generator: function(obj) {
48-
return [obj.component, obj.attemptid];
49-
}
46+
keyPath: ['component', 'attemptid']
5047
},
5148
{
52-
// Not using compound indexes because they seem to have issues with where().
5349
name: 'componentAndComponentId',
54-
generator: function(obj) {
55-
return [obj.component, obj.componentId];
56-
}
50+
keyPath: ['component', 'componentId']
5751
}
5852
]
5953
},
@@ -80,25 +74,16 @@ angular.module('mm.core.question')
8074
name: 'questionslot'
8175
},
8276
{
83-
// Not using compound indexes because they seem to have issues with where().
8477
name: 'componentAndAttempt',
85-
generator: function(obj) {
86-
return [obj.component, obj.attemptid];
87-
}
78+
keyPath: ['component', 'attemptid']
8879
},
8980
{
90-
// Not using compound indexes because they seem to have issues with where().
9181
name: 'componentAndComponentId',
92-
generator: function(obj) {
93-
return [obj.component, obj.componentId];
94-
}
82+
keyPath: ['component', 'componentId']
9583
},
9684
{
97-
// Not using compound indexes because they seem to have issues with where().
9885
name: 'componentAndAttemptAndQuestion',
99-
generator: function(obj) {
100-
return [obj.component, obj.attemptid, obj.questionslot];
101-
}
86+
keyPath: ['component', 'attemptid', 'questionslot']
10287
}
10388
]
10489
}

0 commit comments

Comments
 (0)