-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
68 lines (58 loc) · 1.7 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var express = require('express');
var app = express();
app.use(express.bodyParser());
app.use(express.methodOverride());
var mongoose = require('mongoose')
var ObjectId = mongoose.Schema.ObjectId;
var Schema = mongoose.Schema;
var restify = require('express-restify-mongoose')
restify.defaults({
prefix: "/",
version: "1"
})
app.use(express.static(__dirname + '/client'));
mongoose.connect("mongodb://localhost/coursebuilder");
//var restful = require('node-restful')
var path = require('path')
var Problem = new Schema({
title: { type: String},
body: { type: String },
type: { type: String},
correct_answer: { type: String},
choices: [
{
id: { type: String},
body: { type: String},
is_correct: { type: Boolean}
}
]
});
var ProblemModel = mongoose.model('Problem', Problem);
var Activity = new Schema({
title: { type: String, required: true },
summary: { type: String },
body: { type: String },
type: { type: String},
is_final: { type: Boolean},
randomize_problems: { type: Boolean},
randomize_choices: { type: Boolean},
show_answer: { type: Boolean},
problems: [
{type: ObjectId, ref: "Problem"}
]
});
var ActivityModel = mongoose.model('Activity', Activity);
var Lesson = new Schema({
title: { type: String, required: true },
summary: { type: String },
activities: [
{type: ObjectId, ref: "Activity"}
]
});
var LessonModel = mongoose.model('Lesson', Lesson);
restify.serve(app, ProblemModel);
restify.serve(app, ActivityModel);
restify.serve(app, LessonModel);
var server = app.listen(3000, function () {
console.log('Listening on port %d', server.address().port);
});