File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ MONGO_DBNAME=blockly
44PORT = 8080
55
66APP_ORIGIN = http://localhost:3000
7+ JWT_SECRET = qsldkjf9348u2rjsdf09234jfsd()$§JFSDF2309sdf
8+ REFRESH_TOKEN_SECRET = 2323kjh4r23kjh5g23jh4g23jh4g23jh4g2
9+
710
811# time in seconds
912SHARE_EXPIRES_IN = 2592000
Original file line number Diff line number Diff line change 44
55const mongoose = require ( "mongoose" ) ;
66
7+ const QuestionSchema = new mongoose . Schema (
8+ {
9+ question : String ,
10+ answers : [ Object ] ,
11+ h5plink : String ,
12+ type : String ,
13+ multipleChoice : Boolean ,
14+ } ,
15+ { _id : true }
16+ ) ;
17+
718const StepSchema = new mongoose . Schema ( {
819 type : {
920 type : String ,
@@ -14,6 +25,7 @@ const StepSchema = new mongoose.Schema({
1425 "finish" ,
1526 "question" ,
1627 "blocklyExample" ,
28+ "h5p" ,
1729 ] ,
1830 required : true ,
1931 } ,
@@ -32,12 +44,15 @@ const StepSchema = new mongoose.Schema({
3244 default : undefined ,
3345 } ,
3446 questionData : {
35- type : [ Object ] ,
47+ type : [ QuestionSchema ] ,
3648 default : undefined ,
3749 } ,
3850 xml : {
3951 type : String ,
4052 } ,
53+ h5psrc : {
54+ type : String ,
55+ } ,
4156} ) ;
4257
4358const TutorialSchema = new mongoose . Schema (
@@ -97,4 +112,18 @@ const TutorialSchema = new mongoose.Schema(
97112 }
98113) ;
99114
115+ TutorialSchema . pre ( "save" , function ( next ) {
116+ this . steps . forEach ( ( step ) => {
117+ if ( step . type === "question" && Array . isArray ( step . questionData ) ) {
118+ step . questionData . forEach ( ( q ) => {
119+ if ( ! q . id ) {
120+ q . id = q . _id ?. toString ( ) ;
121+ }
122+ } ) ;
123+ }
124+ } ) ;
125+
126+ next ( ) ;
127+ } ) ;
128+
100129module . exports = mongoose . model ( "Tutorial" , TutorialSchema ) ;
You can’t perform that action at this time.
0 commit comments