Skip to content

Commit 0fcd120

Browse files
unknownunknown
authored andcommitted
#5-08-2024
1 parent d38498b commit 0fcd120

7 files changed

Lines changed: 39 additions & 38 deletions

File tree

appsTeacher/books/app.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ module.exports = function init(site) {
355355
app.view(_data, (err, doc) => {
356356
if (!err && doc) {
357357
response.done = true;
358-
if (req.session.user && req.session.user.booksList && req.session.user.booksList.some((s) => s.toString() == doc._id.toString())) {
358+
if (req.session.user && req.session.user.booksList && req.session.user.booksList.some((s) => s == doc.id)) {
359359
doc.$buy = true;
360360
}
361361
response.doc = doc;
@@ -405,12 +405,11 @@ module.exports = function init(site) {
405405
if (req.session.user && req.session.user.type == "student") {
406406
where["educationalLevel.id"] = req.session.user?.educationalLevel?.id;
407407
where["schoolYear.id"] = req.session.user?.schoolYear?.id;
408-
409408
}
410409
} else if (req.body.type == "myStudent") {
411410
if (req.session.user && req.session.user.type == "student") {
412411
let idList = req.session.user.booksList.map((_item) => _item);
413-
where["_id"] = {
412+
where["id"] = {
414413
$in: idList,
415414
};
416415
}
@@ -449,13 +448,13 @@ module.exports = function init(site) {
449448
(err, user) => {
450449
if (!err && user) {
451450
user.booksList = user.booksList || [];
452-
if (!user.booksList.some((l) => l == doc._id.toString())) {
453-
user.booksList.push(doc._id);
451+
if (!user.booksList.some((l) => l == doc.id)) {
452+
user.booksList.push(doc.id);
454453
}
455454

456455
site.addPurchaseOrder({
457456
type: "book",
458-
target: { id: doc._id, name: doc.name },
457+
target: { id: doc.id, name: doc.name },
459458
price: doc.price,
460459
address: _data.address,
461460
date: new Date(),

appsTeacher/lectures/app.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ module.exports = function init(site) {
166166
name: "view-video",
167167
},
168168
(req, res) => {
169+
169170
app.$collection.find({ _id: req.query.id }, (err, lecture) => {
170171
if (!err && lecture) {
171172
let video = lecture.linksList.find((itm) => itm.code == req.query.code);
172173
let videoURL = video.url;
173174
// handle links
174175
if(videoURL.like('*youtu*')){
175176
videoURL = 'https://www.youtube.com/embed/' + videoURL.split('=')[1].split('&')[0];
176-
}
177-
177+
}
178178
res.render(
179179
app.name + "/view-video.html",
180180
{
@@ -444,7 +444,7 @@ module.exports = function init(site) {
444444
user.socialBrowserID = _data.socialBrowserID;
445445
}
446446
}
447-
let index = user.viewsList.findIndex((itm) => itm.lectureId.toString() === doc._id.toString() && itm.code === _data.code);
447+
let index = user.viewsList.findIndex((itm) => itm.lectureId === doc.id && itm.code === _data.code);
448448
if (index !== -1) {
449449
if (user.viewsList[index].views >= doc.numberAvailableViews && doc.typeExpiryView.name == "number") {
450450
response.error = "The number of views allowed for this video has been exceeded";
@@ -471,7 +471,7 @@ module.exports = function init(site) {
471471
user.viewsList[index].views += 1;
472472
} else {
473473
user.viewsList.push({
474-
lectureId: doc._id,
474+
lectureId: doc.id,
475475
code: _data.code,
476476
date: new Date(),
477477
views: 1,
@@ -520,7 +520,7 @@ module.exports = function init(site) {
520520
},
521521
(err, user) => {
522522
if (!err && user) {
523-
let index = user.viewsList.findIndex((itm) => itm.lectureId.toString() === doc._id.toString() && itm.code === _data.code);
523+
let index = user.viewsList.findIndex((itm) => itm.lectureId === doc.id && itm.code === _data.code);
524524
if (index !== -1) {
525525
if (user.viewsList[index].views >= doc.numberAvailableViews && doc.typeExpiryView.name == "number") {
526526
response.error = "The number of views allowed for this video has been exceeded";
@@ -547,7 +547,7 @@ module.exports = function init(site) {
547547
user.viewsList[index].views += 1;
548548
} else {
549549
user.viewsList.push({
550-
lectureId: doc._id,
550+
lectureId: doc.id,
551551
code: _data.code,
552552
date: new Date(),
553553
views: 1,
@@ -605,13 +605,13 @@ module.exports = function init(site) {
605605
delete _doc.questionsList;
606606

607607
if (req.session.user) {
608-
if (req.session.user.lecturesList && req.session.user.lecturesList.some((s) => s.lectureId.toString() == _doc._id.toString())) {
608+
if (req.session.user.lecturesList && req.session.user.lecturesList.some((s) => s.lectureId == _doc.id)) {
609609
_doc.$buy = true;
610610
_doc.linksList.forEach((_video) => {
611611
delete _video.url;
612612

613613
req.session.user.viewsList = req.session.user.viewsList || [];
614-
let index = req.session.user.viewsList.findIndex((itm) => itm.lectureId.toString() === _doc._id.toString() && itm.code === _video.code);
614+
let index = req.session.user.viewsList.findIndex((itm) => itm.lectureId === _doc.id && itm.code === _video.code);
615615
_video.isValid = false;
616616
if (index !== -1) {
617617
if (_doc.typeExpiryView.name == "number") {
@@ -796,9 +796,9 @@ module.exports = function init(site) {
796796
if (req.session.user && req.session.user.type == "student" && req.session.user.lecturesList) {
797797
let idList = [];
798798
req.session.user.lecturesList.forEach((element) => {
799-
idList.push(site.mongodb.ObjectID(element.lectureId));
799+
idList.push(element.lectureId);
800800
});
801-
where["_id"] = {
801+
where["id"] = {
802802
$in: idList,
803803
};
804804
}
@@ -808,7 +808,7 @@ module.exports = function init(site) {
808808
} else {
809809
where["host"] = site.getHostFilter(req.host);
810810
}
811-
811+
812812
app.all({ where, select, limit, sort: { id: -1 } }, (err, docs) => {
813813
if (req.body.type) {
814814
for (let i = 0; i < docs.length; i++) {
@@ -845,14 +845,14 @@ module.exports = function init(site) {
845845
(err, user) => {
846846
if (!err && user) {
847847
user.lecturesList = user.lecturesList || [];
848-
if (!user.lecturesList.some((l) => l.lectureId.toString() == doc._id.toString())) {
848+
if (!user.lecturesList.some((l) => l.lectureId == doc.id)) {
849849
user.lecturesList.push({
850-
lectureId: doc._id.toString(),
850+
lectureId: doc.id,
851851
});
852852
}
853853
site.addPurchaseOrder({
854854
type: "lecture",
855-
target: { id: doc._id, name: doc.name },
855+
target: { id: doc.id, name: doc.name },
856856
price: doc.price,
857857
code: _data.code,
858858
date: new Date(),
@@ -893,16 +893,16 @@ module.exports = function init(site) {
893893
code: 1,
894894
};
895895
let where = {};
896-
site.security.getUser({ _id: req.body.studentId }, (err, user) => {
896+
site.security.getUser({ id: req.body.studentId }, (err, user) => {
897897
if (!err) {
898898
if (user) {
899899
let idList = [];
900900
user.lecturesList = user.lecturesList || [];
901901
user.lecturesList.forEach((element) => {
902-
idList.push(site.mongodb.ObjectID(element.lectureId));
902+
idList.push(element.lectureId);
903903
});
904904

905-
where["_id"] = {
905+
where["id"] = {
906906
$in: idList,
907907
};
908908
app.$collection.findMany({ where, select, sort: { id: -1 } }, (err, docs) => {

appsTeacher/lectures/site_files/js/lectureView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ app.controller("lectureView", function ($scope, $http, $timeout) {
1616
$scope.busy = false;
1717
if (response.data.done) {
1818
$scope.item = response.data.doc;
19+
$scope.quizView();
1920
} else {
2021
$scope.error = response.data.error;
2122
}
@@ -82,7 +83,7 @@ app.controller("lectureView", function ($scope, $http, $timeout) {
8283
method: "POST",
8384
url: `${$scope.baseURL}/api/quizzes/viewByUserLecture`,
8485
data: {
85-
"lecture._id": "##query.id##",
86+
"lecture.id": $scope.item.id,
8687
},
8788
}).then(
8889
function (response) {
@@ -260,5 +261,4 @@ app.controller("lectureView", function ($scope, $http, $timeout) {
260261
};
261262

262263
$scope.view();
263-
$scope.quizView();
264264
});

appsTeacher/packages/app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ module.exports = function init(site) {
367367
app.view(_data, (err, doc) => {
368368
if (!err && doc) {
369369
response.done = true;
370-
if (req.session.user && req.session.user.packagesList && req.session.user.packagesList.some((s) => s.toString() == doc._id.toString())) {
370+
if (req.session.user && req.session.user.packagesList && req.session.user.packagesList.some((s) => s == doc.id)) {
371371
doc.$buy = true;
372372
}
373373
doc.$time = site.xtime(doc.date, req.session.lang || "ar");
@@ -449,7 +449,7 @@ module.exports = function init(site) {
449449
} else if (req.body.type == "myStudent") {
450450
if (req.session.user && req.session.user.type == "student" && req.session.user.packagesList) {
451451
let idList = req.session.user.packagesList.map((_item) => _item);
452-
where["_id"] = {
452+
where["id"] = {
453453
$in: idList,
454454
};
455455
}
@@ -501,17 +501,17 @@ module.exports = function init(site) {
501501
user.packagesList = user.packagesList || [];
502502
user.lecturesList = user.lecturesList || [];
503503
doc.lecturesList.forEach((_l) => {
504-
if (!user.lecturesList.some((l) => _l.lecture && l.lectureId && l.lectureId.toString() == _l.lecture._id.toString())) {
504+
if (!user.lecturesList.some((l) => _l.lecture && l.lectureId && l.lectureId == _l.lecture.id)) {
505505
user.lecturesList.push({
506-
lectureId: _l.lecture._id,
506+
lectureId: _l.lecture.id,
507507
});
508508
}
509509
});
510510

511-
user.packagesList.push(doc._id);
511+
user.packagesList.push(doc.id);
512512
site.addPurchaseOrder({
513513
type: "package",
514-
target: { id: doc._id, name: doc.name },
514+
target: { id: doc.id, name: doc.name },
515515
code: _data.code,
516516
price: doc.price,
517517
date: new Date(),

appsTeacher/purchaseOrders/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,17 @@ module.exports = function init(site) {
290290
delete where.toDate;
291291
}
292292
if (where["package"]) {
293-
where["target.id"] =where["package"]._id;
293+
where["target.id"] =where["package"].id;
294294
delete where["package"];
295295
}
296296

297297
if (where["book"]) {
298-
where["target.id"] =where["book"]._id;
298+
where["target.id"] =where["book"].id;
299299
delete where["book"];
300300
}
301301

302302
if (where["lecture"]) {
303-
where["target.id"] =where["lecture"]._id;
303+
where["target.id"] =where["lecture"].id;
304304
delete where["lecture"];
305305
}
306306

appsTeacher/quizzes/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ module.exports = function init(site) {
246246
firstName: req.session.user.firstName,
247247
email: req.session.user.email,
248248
},
249-
lecture: { _id: lecture._id.toString(), id: lecture.id, name: lecture.name, educationalLevel: lecture.educationalLevel, schoolYear: lecture.schoolYear },
249+
lecture: { _id: lecture._id, id: lecture.id, name: lecture.name, educationalLevel: lecture.educationalLevel, schoolYear: lecture.schoolYear },
250250
questionsList: lecture.questionsList,
251251
correctAnswers: 0,
252252
userDegree: 0,
@@ -406,11 +406,11 @@ module.exports = function init(site) {
406406
};
407407

408408
let where = req.data;
409-
if (!where || !where["lecture._id"]) {
409+
if (!where || !where["lecture.id"]) {
410410
res.json(response);
411411
return;
412412
}
413-
where["lecture._id"] = where["lecture._id"].toString();
413+
where["lecture.id"] = where["lecture.id"];
414414
where["user.id"] = req.session.user.id;
415415

416416
app.$collection.find(where, (err, doc) => {

appsTeacher/register/site_files/html/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
font-size: x-large;
1010
color: white;
1111
padding: 10px;
12+
border-radius: 15px;
13+
text-align: center;
1214
background: linear-gradient(120deg, rgb(244 82 82) 0%, rgb(229 18 18 / 86%) 100%);
1315
margin: 10px;
1416
}
@@ -131,7 +133,7 @@ <h1 class="bold text-center color2">##word.Register##</h1>
131133
</button>
132134
</div>
133135

134-
<div class="row" id="emailData" ng-show="user.placeType || user.type == 'parent'">
136+
<div class="row" id="emailData" ng-show="(user.placeType && user.type) || user.type == 'parent'">
135137
<div class="register-content">
136138
<div class="row">
137139
<div class="col6">

0 commit comments

Comments
 (0)