Commit f0f44d55 authored by Hasitha Samarasekara's avatar Hasitha Samarasekara

Merge branch 'IT18050240' into 'master'

It18050240

See merge request !16
parents f14423bd 274a44c9
module.exports = {
mongoURI: 'mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/SmartCoach?retryWrites=true&w=majority',
};
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
let Answer = new Schema({
answer_id: mongoose.Schema.Types.ObjectId,
student_id: {
type: String
},
student_name:{
type:String
},
lesson_no:{
type:Number
},
no_of_questions:{
type:Number
},
question_text:{
type:String
},
question_answer:{
type:String
},
defult_mark:{
type:Number
}
});
module.exports = mongoose.model('Answer',Answer);
\ No newline at end of file
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ImageSchema = new Schema({
caption: {
required: true,
type: String,
},
lessonname: {
required: true,
type: String,
},
lessonno: {
required: true,
type: String,
},
filename: {
required: true,
type: String,
},
fileId: {
required: true,
type: String,
},
createdAt: {
default: Date.now(),
type: Date,
},
});
const Image = mongoose.model('Image', ImageSchema);
module.exports = Image;
\ No newline at end of file
......@@ -4,10 +4,10 @@ const Schema = mongoose.Schema;
let Question = new Schema({
question_id: mongoose.Schema.Types.ObjectId,
category:{
type:String
lesson_no:{
type:Number
},
name:{
lesson_name:{
type:String
},
question_text:{
......@@ -17,10 +17,7 @@ let Question = new Schema({
type:String
},
defult_mark:{
type: Number
},
q_type:{
type: String
type:Number
},
time_createdby:{
type: Date
......
......@@ -35,73 +35,11 @@
"negotiator": "0.6.2"
}
},
"ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"dev": true,
"requires": {
"safer-buffer": "~2.1.0"
}
},
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
"dev": true
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
},
"aws-sign2": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=",
"dev": true
},
"aws4": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==",
"dev": true
},
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"requires": {
"follow-redirects": "^1.14.0"
}
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"dev": true,
"requires": {
"tweetnacl": "^0.14.3"
}
},
"bl": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz",
......@@ -143,21 +81,6 @@
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
},
"caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
"dev": true
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
},
"content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
......@@ -195,15 +118,6 @@
"vary": "^1"
}
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
......@@ -212,12 +126,6 @@
"ms": "2.0.0"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
"denque": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz",
......@@ -238,16 +146,6 @@
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
"integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
},
"ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"dev": true,
"requires": {
"jsbn": "~0.1.0",
"safer-buffer": "^2.1.0"
}
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
......@@ -305,30 +203,6 @@
"vary": "~1.1.2"
}
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"dev": true
},
"extsprintf": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"dev": true
},
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"dev": true
},
"finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
......@@ -343,28 +217,6 @@
"unpipe": "~1.0.0"
}
},
"follow-redirects": {
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g=="
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
"dev": true
},
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"dev": true,
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
......@@ -375,31 +227,6 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0"
}
},
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
"dev": true
},
"har-validator": {
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz",
"integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==",
"dev": true,
"requires": {
"ajv": "^6.12.3",
"har-schema": "^2.0.0"
}
},
"http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
......@@ -412,17 +239,6 @@
"toidentifier": "1.0.0"
}
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0",
"jsprim": "^1.2.2",
"sshpk": "^1.7.0"
}
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
......@@ -441,59 +257,11 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
},
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
"dev": true
},
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"dev": true
},
"json-schema": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
"dev": true
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
"dev": true,
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.2.3",
"verror": "1.10.0"
}
},
"kareem": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz",
......@@ -630,12 +398,6 @@
"integrity": "sha512-YSzu7TLbI+bsjCis/TZlAXBoM4y93HhlIgo0P5oiA2ua9Z4k+E2Fod//ybIzdJxOlXGRcHIh/WaeCBehvxZb/Q==",
"dev": true
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
"dev": true
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
......@@ -664,12 +426,6 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"dev": true
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
......@@ -684,18 +440,6 @@
"ipaddr.js": "1.9.1"
}
},
"psl": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz",
"integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==",
"dev": true
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
......@@ -736,42 +480,6 @@
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
},
"request": {
"version": "2.88.2",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
"integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==",
"dev": true,
"requires": {
"aws-sign2": "~0.7.0",
"aws4": "^1.8.0",
"caseless": "~0.12.0",
"combined-stream": "~1.0.6",
"extend": "~3.0.2",
"forever-agent": "~0.6.1",
"form-data": "~2.3.2",
"har-validator": "~5.1.3",
"http-signature": "~1.2.0",
"is-typedarray": "~1.0.0",
"isstream": "~0.1.2",
"json-stringify-safe": "~5.0.1",
"mime-types": "~2.1.19",
"oauth-sign": "~0.9.0",
"performance-now": "^2.1.0",
"qs": "~6.5.2",
"safe-buffer": "^5.1.2",
"tough-cookie": "~2.5.0",
"tunnel-agent": "^0.6.0",
"uuid": "^3.3.2"
},
"dependencies": {
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
"dev": true
}
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
......@@ -853,23 +561,6 @@
"memory-pager": "^1.0.2"
}
},
"sshpk": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
"integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
"dev": true,
"requires": {
"asn1": "~0.2.3",
"assert-plus": "^1.0.0",
"bcrypt-pbkdf": "^1.0.0",
"dashdash": "^1.12.0",
"ecc-jsbn": "~0.1.1",
"getpass": "^0.1.1",
"jsbn": "~0.1.0",
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
}
},
"statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
......@@ -888,31 +579,6 @@
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
},
"tough-cookie": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
"integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
"dev": true,
"requires": {
"psl": "^1.1.28",
"punycode": "^2.1.1"
}
},
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"dev": true,
"requires": {
"safe-buffer": "^5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
"dev": true
},
"type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
......@@ -927,15 +593,6 @@
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
"uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......@@ -946,27 +603,10 @@
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"verror": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "^1.2.0"
}
}
}
}
......@@ -10,14 +10,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.21.4",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"mongoose": "^5.12.15"
},
"devDependencies": {
"nodemailer": "^6.6.2",
"request": "^2.88.2"
"nodemailer": "^6.6.2"
}
}
const answerRoute = require('express').Router();
let answer = require('../models/answer.model');
const mongoose = require('mongoose');
answerRoute.route('/').get(function(req, res) {
answer.find(function(err, questions) {
if (err) {
console.log(err);
res.render('index');
} else {
res.json(questions);
}
});
});
answerRoute.route('/:id').get(function (req, res) {
let id = req.params.id;
answer.findById(id, function (err, question) {
res.json(question);
});
});
answerRoute.route('/questionId/:id').get(function (req, res) {
console.log("Question ID");
console.log(req.params.id);
let id = req.params.id;
answer.find({"_id" : id}, function (err, question) {
res.json(question);
});
});
answerRoute.route('/add').post(function(req, res) {
const ans = new answer({
answer_id: new mongoose.Types.ObjectId(),
student_id : req.body.student_id,
student_name : req.body.student_name,
lesson_no : req.body.lesson_no,
no_of_questions : req.body.no_of_questions,
question_text: req.body.question_text,
question_answer:req.body.question_answer,
defult_mark: req.body.defult_mark,
});
ans.save().then(ans =>{
res.json('Item update!');
})
.catch(err =>{
res.status(400).send("Update not possible");
});
});
answerRoute.route('/update/:id').post((req, res) => {
answer.findById(req.params.id,function(err, answer){
if(!answer)
req.status(404).send("data is not found");
else {
answer.lesson_no = req.body.lesson_no,
answer.student_id = req.body.student_id,
answer.student_name = req.body.student_name,
answer.no_of_questions = req.body.no_of_questions,
answer.question_text = req.body.question_text,
answer.question_answer = req.body.question_answer,
answer.defult_mark = req.body.defult_mark
}
answer.save().then(answer =>{
res.json('Item update!');
})
.catch(err =>{
res.status(400).send("Update not possible");
});
});
});
answerRoute.route('/lessonNo/:id').get(function (req, res) {
console.log("Product Item ID");
console.log(req.params.id);
let id = req.params.id;
answer.find({"lesson_no" : id}, function (err, answer) {
res.json(answer);
});
});
answerRoute.route('/delete/:id').delete((req, res) => {
answer.findByIdAndDelete(req.params.id)
.then(() => res.json('Product Deleted.'))
.catch(err => res.status(400).json('Error: ' + err));
});
module.exports = answerRoute;
\ No newline at end of file
const express = require('express');
const imageRouter = express.Router();
const mongoose = require('mongoose');
const Image = require('../models/pdf.model');
const config = require('../config');
module.exports = (upload) => {
const url = config.mongoURI;
const connect = mongoose.createConnection(url, {useNewUrlParser: true, useUnifiedTopology: true});
let gfs;
connect.once('open', () => {
// initialize stream
gfs = new mongoose.mongo.GridFSBucket(connect.db, {
bucketName: "uploads"
});
});
/*
POST: Upload a single image/file to Image collection
*/
imageRouter.route('/')
.post(upload.single('file'), (req, res, next) => {
console.log(req.body);
// check for existing images
Image.findOne({caption: req.body.caption})
.then((image) => {
console.log(image);
if (image) {
return res.status(200).json({
success: false,
message: 'Image already exists',
});
}
let newImage = new Image({
lessonname: req.body.lessonname,
lessonno: req.body.lessonno,
caption: req.body.caption,
filename: req.file.filename,
fileId: req.file.id,
});
newImage.save()
.then((image) => {
res.status(200).json({
success: true,
image,
});
})
.catch(err => res.status(500).json(err));
})
.catch(err => res.status(500).json(err));
})
.get((req, res, next) => {
Image.find({})
.then(images => {
res.status(200).json({
success: true,
images,
});
})
.catch(err => res.status(500).json(err));
});
/*
GET: Delete an image from the collection
*/
imageRouter.route('/delete/:id')
.get((req, res, next) => {
Image.findOne({_id: req.params.id})
.then((image) => {
if (image) {
Image.deleteOne({_id: req.params.id})
.then(() => {
return res.status(200).json({
success: true,
message: `File with ID: ${req.params.id} deleted`,
});
})
.catch(err => {
return res.status(500).json(err)
});
} else {
res.status(200).json({
success: false,
message: `File with ID: ${req.params.id} not found`,
});
}
})
.catch(err => res.status(500).json(err));
});
/*
GET: Fetch most recently added record
*/
imageRouter.route('/recent')
.get((req, res, next) => {
Image.findOne({}, {}, {sort: {'_id': -1}})
.then((image) => {
res.status(200).json({
success: true,
image,
});
})
.catch(err => res.status(500).json(err));
});
/*
POST: Upload multiple files upto 3
*/
imageRouter.route('/multiple')
.post(upload.array('file', 3), (req, res, next) => {
res.status(200).json({
success: true,
message: `${req.files.length} files uploaded successfully`,
});
});
/*
GET: Fetches all the files in the uploads collection
*/
imageRouter.route('/')
.get((req, res, next) => {
gfs.find().toArray((err, files) => {
if (!files || files.length === 0) {
return res.status(200).json({
success: false,
message: 'No files available'
});
}
files.map(file => {
if (file.contentType === 'image/jpeg' || file.contentType === 'image/png' || file.contentType === 'image/svg') {
file.isImage = true;
} else {
file.isImage = false;
}
});
res.status(200).json({
success: true,
files,
});
});
});
/*
GET: Fetches a particular file by filename
*/
imageRouter.route('/file/:filename')
.get((req, res, next) => {
gfs.find({ filename: req.params.filename }).toArray((err, files) => {
if (!files[0] || files.length === 0) {
return res.status(200).json({
success: false,
message: 'No files available',
});
}
res.status(200).json({
success: true,
file: files[0],
});
});
});
/*
GET: Fetches a particular image and render on browser
*/
imageRouter.route('/image/:filename')
.get((req, res, next) => {
gfs.find({ filename: req.params.filename }).toArray((err, files) => {
if (!files[0] || files.length === 0) {
return res.status(200).json({
success: false,
message: 'No files available',
});
}
if (files[0].contentType === 'image/jpeg' || files[0].contentType === 'image/png' || files[0].contentType === 'image/svg+xml') {
// render image to browser
gfs.openDownloadStreamByName(req.params.filename).pipe(res);
} else {
res.status(404).json({
err: 'Not an image',
});
}
});
});
/*
GET: Fetches a particular PDF and render on browser
*/
imageRouter.route('/pdf/:filename')
.get((req, res, next) => {
gfs.find({ filename: req.params.filename }).toArray((err, files) => {
if (!files[0] || files.length === 0) {
return res.status(200).json({
success: false,
message: 'No files available',
});
}
if (files[0].contentType === 'application/pdf' || files[0].contentType === 'application/vnd.ms-powerpoint'|| files[0].contentType === 'application/vnd.openxmlformats-officedocument.presentationml.presentation') {
// render PDF to browser
gfs.openDownloadStreamByName(req.params.filename).pipe(res);
} else {
res.status(404).json({
err: 'Not a PDF',
});
}
});
});
/*
DELETE: Delete a particular file by an ID
*/
imageRouter.route('/file/del/:id')
.post((req, res, next) => {
console.log(req.params.id);
gfs.delete(new mongoose.Types.ObjectId(req.params.id), (err, data) => {
if (err) {
return res.status(404).json({ err: err });
}
res.status(200).json({
success: true,
message: `File with ID ${req.params.id} is deleted`,
});
});
});
return imageRouter;
};
\ No newline at end of file
......@@ -13,6 +13,7 @@ questionRouter.route('/').get(function(req, res) {
});
});
questionRouter.route('/:id').get(function (req, res) {
let id = req.params.id;
Question.findById(id, function (err, question) {
......@@ -32,43 +33,20 @@ questionRouter.route('/questionId/:id').get(function (req, res) {
questionRouter.route('/add').post(function(req, res) {
const question = new Question({
question_id: new mongoose.Types.ObjectId(),
category : req.body.category,
name : req.body.name,
lesson_no : req.body.lesson_no,
lesson_name : req.body.lesson_name,
question_text: req.body.question_text,
question_answer:req.body.question_answer,
defult_mark: req.body.defult_mark,
q_type: req.body.q_type,
time_createdby: req.body.time_createdby,
time_modifiedby: req.body.time_modifiedby,
general_feedback: req.body.general_feedback
});
question
.save()
.then(result => {
res.json(result);
console.log(result);
res.status(201).json({
message: "Created product successfully",
createdProduct: {
category: result.category,
name: result.name,
question_text: result.question_text,
defult_mark: result.defult_mark,
q_type: result.q_type,
time_createdby: req.body.time_createdby,
time_modifiedby: req.body.time_modifiedby,
general_feedback: req.body.general_feedback,
question_id: result.question_id,
request: {
type: 'GET',
url: "http://localhost:5000/questions/" + result._id
}
}
});
})
.catch(err => {
console.log(err);
res.status(500).json({error: err});
question.save().then(question =>{
res.json('Item update!');
})
.catch(err =>{
res.status(400).send("Update not possible");
});
});
......@@ -77,8 +55,8 @@ questionRouter.route('/update/:id').post((req, res) => {
if(!question)
req.status(404).send("data is not found");
else {
question.category = req.body.category;
question.name = req.body.name;
question.lesson_no = req.body.lesson_no;
question.lesson_name = req.body.lesson_name;
question.question_text = req.body.question_text;
question.question_answer = req.body.question_answer;
question.defult_mark = req.body.defult_mark;
......@@ -96,7 +74,14 @@ questionRouter.route('/update/:id').post((req, res) => {
});
});
questionRouter.route('c').get(function (req, res) {
console.log("Product Item ID");
console.log(req.params.id);
let id = req.params.id;
Question.find({"lesson_no" : id}, function (err, product) {
res.json(product);
});
});
questionRouter.route('/delete/:id').delete((req, res) => {
Question.findByIdAndDelete(req.params.id)
......
const createError = require('http-errors');
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const methodOverride = require('method-override');
const config = require('./config');
const multer = require('multer');
const {GridFsStorage} = require('multer-gridfs-storage');
const crypto = require('crypto');
const cors = require('cors');
const bodyParser = require('body-parser');
const mongoose =require('mongoose');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 5001;
const port = process.env.PORT || 5000;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(cors({
origin: '*',
}));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(methodOverride('_method'));
app.use(express.static(path.join(__dirname, 'public')));
mongoose.Promise = require('bluebird');
const uri = process.env.ATLAS_URI;
mongoose.connect(uri,{useNewUrlParser:true, useUnifiedTopology: true, useCreateIndex:true, useFindAndModify: false });
const url = config.mongoURI;
const connect = mongoose.connect(url, { useNewUrlParser:true, useUnifiedTopology: true, useCreateIndex:true, useFindAndModify: false });
const connection = mongoose.connection;
connection.once('open',() => {
console.log("MongoDB database connection established successfully");
}).catch(err => {
console.error('App starting error:', err.stack);
process.exit(1);
connect.then(() => {
console.log('Connected to database: GridApp');
}, (err) => console.log(err));
// create storage engine
const storage = new GridFsStorage({
url: config.mongoURI,
file: (req, file) => {
return new Promise((resolve, reject) => {
crypto.randomBytes(16, (err, buf) => {
if (err) {
return reject(err);
}
const filename = buf.toString('hex') + path.extname(file.originalname);
const fileInfo = {
filename: filename,
bucketName: 'uploads'
};
resolve(fileInfo);
});
});
}
});
const upload = multer({ storage });
// const connection = mongoose.connection;
// connection.once('open',() => {
// console.log("MongoDB database connection established successfully");
// }).catch(err => {
// console.error('App starting error:', err.stack);
// process.exit(1);
// });
const studentRouter = require('./routes/student.route');
const tutorRouter = require('./routes/tutor.route');
const instituteRouter = require('./routes/institute.route');
......@@ -29,21 +81,19 @@ const userAccount = require('./routes/userAccount.route');
const questionManage = require('./routes/question.route');
const financeRouter = require('./routes/finance.route');
const studentResult = require('./routes/studentALResult.route');
const tutorRating = require('./routes/tutorRatings.route');
const filteredList = require('./routes/filteredListNew.route');
const createClassRoute = require('./routes/createClass.route');
const imageRouter = require('./routes/pdf.route');
const answerManage = require('./routes/answer_route');
app.use('/studentSingUp',studentRouter);
app.use('/tutorSingUp',tutorRouter);
app.use('/instituteSingUp',instituteRouter);
app.use('/userAccount',userAccount);
app.use('/questions', questionManage);
app.use('/answer', answerManage);
app.use('/admin/finance', financeRouter);
app.use('/studentResults', studentResult);
app.use('/tutorRatings', tutorRating);
app.use('/filteredList', filteredList);
app.use('/createClass', createClassRoute);
app.use('/', imageRouter(upload));
app.listen(port, () => {
console.log(`Server is running on Port: ${port}`);
});
\ No newline at end of file
});
......@@ -2305,11 +2305,28 @@
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.2.3.tgz",
"integrity": "sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA=="
},
"@types/prop-types": {
"version": "15.7.4",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz",
"integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==",
"dev": true
},
"@types/q": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz",
"integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug=="
},
"@types/react": {
"version": "17.0.26",
"resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.26.tgz",
"integrity": "sha512-MXxuXrH2xOcv5cp/su4oz69dNQnSA90JjFw5HBd5wifw6Ihi94j7dRJm7qNsB30tnruXSCPc9qmlhGop4nh9Hw==",
"dev": true,
"requires": {
"@types/prop-types": "*",
"@types/scheduler": "*",
"csstype": "^3.0.2"
}
},
"@types/resolve": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz",
......@@ -2318,6 +2335,12 @@
"@types/node": "*"
}
},
"@types/scheduler": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==",
"dev": true
},
"@types/source-list-map": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz",
......@@ -4775,6 +4798,12 @@
}
}
},
"csstype": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz",
"integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==",
"dev": true
},
"cyclist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz",
......@@ -12341,6 +12370,14 @@
"object-assign": "^4.1.1"
}
},
"react-addons-shallow-compare": {
"version": "15.6.3",
"resolved": "https://registry.npmjs.org/react-addons-shallow-compare/-/react-addons-shallow-compare-15.6.3.tgz",
"integrity": "sha512-EDJbgKTtGRLhr3wiGDXK/+AEJ59yqGS+tKE6mue0aNXT6ZMR7VJbbzIiT6akotmHg1BLj46ElJSb+NBMp80XBg==",
"requires": {
"object-assign": "^4.1.0"
}
},
"react-app-polyfill": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/react-app-polyfill/-/react-app-polyfill-2.0.0.tgz",
......@@ -12645,6 +12682,14 @@
"prop-types": "^15.6.1"
}
},
"react.pure.component": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/react.pure.component/-/react.pure.component-1.2.0.tgz",
"integrity": "sha1-8nuetnM3rtQ8XQ2sY4lD7Zux3hE=",
"requires": {
"react-addons-shallow-compare": "^15.3.2"
}
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
......@@ -14881,6 +14926,11 @@
"is-typedarray": "^1.0.0"
}
},
"typescript": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA=="
},
"unbox-primitive": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
......
......@@ -18,7 +18,9 @@
"react-scripts": "4.0.3",
"react-select-search": "^3.0.8",
"react-star-rating-component": "^1.4.1",
"react.pure.component": "^1.2.0",
"sweetalert": "^2.1.2",
"typescript": "^4.4.3",
"web-vitals": "^1.1.1"
},
"scripts": {
......@@ -46,6 +48,7 @@
]
},
"devDependencies": {
"@types/react": "^17.0.26",
"axios": "^0.21.1",
"react-notify-toast": "^0.5.1"
}
......
......@@ -11,7 +11,9 @@
<link rel="stylesheet" href="DashboardAssets/css/dashboard.css">
<link rel="stylesheet" href="DashboardAssets/css/custom.css">
<!-- fa fa icons cdn -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.7/css/all.css">
</head>
<body>
......
......@@ -14,9 +14,11 @@ import Dashboard from "./Components/Admin/Dashboard";
import StudentDashboard from "./Components/Student/StudentDashboard";
import QuestionDetails from "./Components/IT18050240/question_details"
import QuestionLayout from "./Components/IT18050240/question_layout"
//import AdminQuestionManagement from "./Components/IT18050240/admin_question_management.js"
import AdminQuestionManagement from "./Components/IT18050240/admin_question_management.js"
import QuestionBank from "./Components/IT18050240/question_bank"
import TutorProfileView from "./Components/HomePage/TutorProfileView";
import LessonAndExam from "./Components/IT18050240/lessonandexampage";
import AutomaticQuestion from "./Components/IT18050240/automatic_question"
import Upload from "./Components/IT18050240/UploadPage";
function App() {
return (
......@@ -28,8 +30,7 @@ function App() {
<Route path="/SignUp" exact component={SignUp}/>
<Route path="/beforeConfirm" exact component={beforeConfirmation}/>
<Route path="/AccountVerified/:id" exact component={VerifiedAccount}/>
<Route path="/Home/ViewProfile/:id" exact component={TutorProfileView}/>
<Route path="/studentDashboard" exact component={StudentDashboard}/>
{/*<Route path="/studentDashboard" exact component={StudentDashboard}/>*/}
{/*<Route path="/" exact component={Dashboard}/>*/}
......@@ -37,10 +38,13 @@ function App() {
<Route path="/admin"><Dashboard/></Route>
<Route path="/studentDashboard"><StudentDashboard/></Route>
<Route path="/questiondetails" exact component={QuestionDetails}/>
<Route path="/question" exact component={QuestionLayout}/>
{/*<Route path="/questionmanagement" exact component={AdminQuestionManagement}/>*/}
<Route path="/question/:id" exact component={QuestionLayout}/>
<Route path="/questionmanagement/:id" exact component={AdminQuestionManagement}/>
<Route path="/questionbank" exact component={QuestionBank}/>
{/*<Route path="/edititem/:id" exact component={AdminQuestionManagement}/>*/}
<Route path="/questionmanagement" exact component={AdminQuestionManagement}/>
<Route path="/lesson" exact component={LessonAndExam}/>
<Route path="/automaticquestion" exact component={AutomaticQuestion}/>
<Route path="/upload" exact component={Upload}/>
</Switch>
......
......@@ -382,6 +382,37 @@ export default class Dashboard extends Component {
{/*</Link>*/}
</li>
<li>
<a href="#">
<i className="metismenu-icon fa fa-book"></i>
Exams
<i className="metismenu-state-icon fa fa-caret-down"></i>
</a>
<ul>
<li>
<NavLink to={"/questionbank"}>
<i className="metismenu-icon"></i>
Question Bank
</NavLink>
</li>
</ul>
</li>
<li>
<a href="#">
<i className="metismenu-icon fa fa-book"></i>
Lesson
<i className="metismenu-state-icon fa fa-caret-down"></i>
</a>
<ul>
<li>
<NavLink to={"/upload"}>
<i className="metismenu-icon"></i>
Lesson upload
</NavLink>
</li>
</ul>
</li>
<li>
<a href="#">
......
import React, { PureComponent } from 'react';
import axios from 'axios';
import PDF from '../../Images/pdficon.png';
import PW from '../../Images/pptxicon.png';
interface UploadState {
recentImage: any;
caption: string;
uploadedImageUrl: string;
uploadedImage: any;
imagename: string;
filetype :string,
lessonname:string,
lessonno: any,
filename :string
};
class UploadPage extends PureComponent<{}, UploadState> {
constructor(props: {}) {
super(props);
this.state = {
recentImage: {},
caption: '',
uploadedImageUrl: '',
uploadedImage: {},
imagename : '',
filetype: '',
lessonname:'',
lessonno:'',
filename:''
};
}
componentDidMount = () => {
this.fetchRecent();
}
componentDidUpdate=()=> {
this.fetchRecent();
}
fetchRecent = () => {
axios.get('http://localhost:5000/recent')
.then((response) => {
this.setState({
filename: response.data.filename,
lessonname :response.data.lessonname,
lessonno :response.data.lessonno
});
})
.catch(err => alert('Error: ' + err));
//let str = this.state.filename;
//
// if (str.includes(".pdf")) {
// this.setState({
// imagename: PDF,
// filetype : ".pdf"
// });
// }else if (str.includes(".pptx")) {
// this.setState({
// imagename: PW,
// filetype :".pptx"
// });
// }
}
uploadImage = () => {
if (!this.state.caption.trim() || !this.state.uploadedImage.name) {
return alert('Caption or file is missing');
}
let formData = new FormData();
formData.append('caption', this.state.caption);
formData.append('file', this.state.uploadedImage);
formData.append('lessonno', this.state.lessonno);
formData.append('lessonname', this.state.lessonname);
axios.post('http://localhost:5000/', formData)
.then((response) => {
response.data.success ? alert('File successfully uploaded') : alert('File already exists');
this.fetchRecent();
})
.catch(err => alert('Error: ' + err));
}
render() {
return (
<div className="UploadPage">
<div className="Recent">
<div className="container text-left">
<div className="col-10" >
<hr />
<div className="row">
<div className="col-sm-6">
<label>Lesson name: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ lessonname: event.target.value })}
value={this.state.lessonname}/>
</div>
</div>
<div className="col-sm-6">
<label>Lesson no: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ lessonno: event.target.value })}
value={this.state.lessonno}/>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-6">
<label>Lesson caption: </label>
<div style={{padding: '0px'}}>
<input
type="text"
className="form-control"
placeholder="Enter caption..."
onChange={event => this.setState({ caption: event.target.value })}
value={this.state.caption}
/>
</div>
</div>
<div className="col-sm-6">
<label>Upload file: </label>
<div style={{padding: '0px'}}>
<input
type="file"
className="Upload__Input"
onChange={(event: any) => {
this.setState({
uploadedImageUrl: URL.createObjectURL(event.target.files[0]),
uploadedImage: event.target.files[0],
})
}}
/>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-12">
<button type ="submit" value ="Submit"
className = "btn btn-block btn-success mt-3" onClick={this.uploadImage}> ADD
</button>
</div>
</div>
<br/><br/>
<div className="border">
<div style={{margin: "15px"}}>
<h5 className="text-center"> Recent Upload File </h5>
<p className="text-center"> File type : (.pdf) <img src={PDF} alt="upload-image" style={{width:'30px'}}/> </p>
<p className="text-center"> Lesson No: 1 {this.state.lessonno} </p>
<p className="text-center"> Lesson Name: Accounting{this.state.lessonname} </p>
</div>
</div>
</div>
<br/><br/>
</div></div>
</div>
);
}
}
export default UploadPage;
......@@ -9,16 +9,11 @@ export default class AdminUI extends Component {
constructor(props){
super(props);
var today = new Date(),
time = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + today.getDate() +'T'+today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds()+'Z';
this.onChangeCategory = this.onChangeCategory.bind(this);
this.onChangeName = this.onChangeName.bind(this);
this.onChangeLessonNo = this.onChangeLessonNo.bind(this);
this.onChangeLessonName = this.onChangeLessonName.bind(this);
this.onChangeQuestionText = this.onChangeQuestionText.bind(this);
this.onChangeQuestionAnswer = this.onChangeQuestionAnswer.bind(this);
this.onChangeDefultMark = this.onChangeDefultMark.bind(this);
this.onChangeQType = this.onChangeQType.bind(this);
this.onChangeGeneralFeedback = this.onChangeGeneralFeedback.bind(this);
this.addQuestion = this.addQuestion.bind(this);
......@@ -26,31 +21,30 @@ export default class AdminUI extends Component {
this.state = {
question_id : '',
category : '',
name : '',
lesson_no : '',
lesson_name : '',
question_text : '',
question_answer : '',
defult_mark : '',
q_type : '',
general_feedback : '',
submitStatus : false,
currentTime: time,
currentTime: Date.now(),
editItem : false
}
}
onChangeCategory(e){
onChangeLessonNo(e){
this.setState({
category :e.target.value
lesson_no :e.target.value
});
}
onChangeName(e){
onChangeLessonName(e){
this.setState({
name :e.target.value
lesson_name :e.target.value
});
}
......@@ -99,11 +93,11 @@ export default class AdminUI extends Component {
const newQuestion = {
category : this.state.category,
name : this.state.name,
lesson_no : this.state.lesson_no,
lesson_name : this.state.lesson_name,
question_text : this.state.question_text,
question_answer : this.state.question_answer,
defult_mark : this.state.defult_mark,
q_type : this.state.q_type,
time_createdby: this.state.currentTime,
time_modifiedby: this.state.currentTime,
general_feedback : this.state.general_feedback,
......@@ -117,14 +111,6 @@ export default class AdminUI extends Component {
);
swal("Data Saved Successfully!", "Your Details has been Saved Successfully!", "success");
// this.setState({
// nextStep : true
// });
// } else{
// alert("You must fill in all of the fields.");
// }
// window.location = 'https://senosafrontend.herokuapp.com/admin/itemlist';
}
......@@ -133,8 +119,8 @@ export default class AdminUI extends Component {
axios.get('http://localhost:5000/questions/'+ this.props.match.params.id)
.then(response =>{
this.setState({
category : response.data.category,
name : response.data.name,
lesson_no : response.data.lesson_no,
lesson_name : response.data.lesson_name,
question_text : response.data.question_text,
question_answer : response.data.question_answer,
defult_mark : response.data.defult_mark,
......@@ -161,7 +147,7 @@ export default class AdminUI extends Component {
editQuestion(e){
e.preventDefault();
//if(this.state.item_name != null && this.state.item_description != null && this.state.item_category != null && this.state.item_quantity != null && this.state.item_price){
if(this.props.match.params.id != null){
console.log(`Form Update submitted:`);
console.log(`Category: ${this.state.category}`);
console.log(`Name: ${this.state.name}`);
......@@ -171,14 +157,13 @@ export default class AdminUI extends Component {
console.log(`Genaral Feedback: ${this.state.general_feedback}`);
const editQuestion = {
category : this.state.category,
name : this.state.name,
question_text : this.state.question_text,
question_answer : this.state.question_answer,
defult_mark : this.state.defult_mark,
q_type : this.state.q_type,
time_modifiedby: this.state.currentTime,
general_feedback : this.state.general_feedback,
lesson_no : this.state.lesson_no,
lesson_name : this.state.lesson_name,
question_text : this.state.question_text,
question_answer : this.state.question_answer,
defult_mark : this.state.defult_mark,
time_modifiedby: this.state.currentTime,
general_feedback : this.state.general_feedback,
};
// axios.post('https://senosaonlineshoppingwebsite.herokuapp.com/products/update/'+this.props.match.params.id,editItem)
......@@ -195,7 +180,7 @@ export default class AdminUI extends Component {
// }else{
// alert("You must fill in all of the fields.");
// }
}
}}
render(){
return(
......@@ -226,11 +211,17 @@ export default class AdminUI extends Component {
<div className="row">
<div className="col-sm-5">
<label>Category: </label>
<label>Lesson No: </label>
<div style={{padding: '0px'}}>
<select style={{width: '100%'}} className="browser-default custom-select"
onChange={(e) => this.onChangeCategory(e)}>
<option>Select Category</option>
onChange={(e) => this.onChangeLessonNo(e)}>
<option>Select Lesson No</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
......@@ -241,8 +232,8 @@ export default class AdminUI extends Component {
<div style={{padding: '0px'}}>
<input type="text" required
className="form-control"
value ={this.state.name}
onChange={this.onChangeName}
value ={this.state.lesson_name}
onChange={this.onChangeLessonName}
/>
</div>
......@@ -275,7 +266,7 @@ export default class AdminUI extends Component {
<div className="row">
<div className="col-sm-5">
<div className="col-sm-10">
<label>Default mark: </label>
<input type="text"
className="form-control"
......@@ -283,14 +274,6 @@ export default class AdminUI extends Component {
onChange = {this.onChangeDefultMark}
/>
</div>
<div className="col-sm-5">
<label>Question type: </label>
<input type="text"
className="form-control"
value ={this.state.q_type}
onChange = {this.onChangeQType}
/>
</div>
</div>
......@@ -321,17 +304,14 @@ export default class AdminUI extends Component {
<div className="row">
<div className="col-sm-4">
</div>
<div className="col-sm- mt-3">
<Link style={{textDecoration:"none"}} to={"/admin/itemlist"}><button className="btn btn-block btn-warning" style={{width:"159px" , color:"white"}}>BACK</button></Link>
<div className="col-sm-5">
<Link style={{textDecoration:"none"}} to={"/admin/itemlist"}><button className="btn btn-block btn-warning" style={{color:"white"}}>BACK</button></Link>
</div>
<div className="col-sm-4">
<button style={{marginTop:10}} type ="submit" value ="Submit"
<div className="col-sm-5">
<button type ="submit" value ="Submit"
className = {this.state.submitStatus
? "btn btn-block btn-success mt-3"
: "btn btn-block btn-primary mt-3"}
? "btn btn-block btn-success"
: "btn btn-block btn-primary"}
> {this.state.submitStatus ? "EDIT" : "ADD"}
</button>
</div>
......
import React, { Component } from 'react';
import axios from 'axios';
//import swal from 'sweetalert';
import { Link } from "react-router-dom";
import swal from "sweetalert";
export default class Automatic_question extends Component {
constructor(props){
super(props);
this.onChangeLessonNo = this.onChangeLessonNo.bind(this);
this.onChangeLessonName = this.onChangeLessonName.bind(this);
this.onChangeDefultMark = this.onChangeDefultMark.bind(this);
this.onChangeFeedBack = this.onChangeFeedBack.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.state = {
lesson_no : '',
lesson_name : '',
defult_mark : '',
general_feedback : '',
}
}
onChangeLessonNo(e){
this.setState({
lesson_no :e.target.value
});
}
onChangeLessonName(e){
this.setState({
lesson_name :e.target.value
});
}
onChangeDefultMark(e){
this.setState({
defult_mark :e.target.value
});
}
onChangeFeedBack(e){
this.setState({
general_feedback :e.target.value
});
}
async onSubmit(e) {
e.preventDefault();
//if(this.state.item_name != null && this.state.item_description != null && this.state.item_category != null && this.state.item_quantity != null && this.state.item_price){
console.log(`Form submitted:`);
console.log(`Lesson Name: ${this.state.lesson_name}`);
console.log(`Lesson No: ${this.state.lesson_no}`);
console.log(`Defualt mark: ${this.state.defult_mark}`);
console.log(`Genaral Feedback: ${this.state.general_feedback}`);
const newQuestion = {
lesson_no: this.state.lesson_no,
lesson_name: this.state.lesson_name,
defult_mark: this.state.defult_mark,
general_feedback: this.state.general_feedback,
};
let options = {
uri: 'http://127.0.0.1:5000/generate',
body: JSON.stringify(newQuestion),
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}
let response = await axios.post(options.uri, options.body);
console.log(response.data.result);
// axios.post('http://127.0.0.1:5000/generate')
// .then(res => {this.setState({
// question_id: res.data.question_id})
// })
// .catch(//swal("Good job!", "You clicked the button!", "warning"
// );
// swal("Data Saved Successfully!", "Your Details has been Saved Successfully!", "success");
}
render() {
return (
<div className="container">
<form onSubmit={this.onSubmit}>
<div className="row">
<div className="col-sm-5">
<label>Lesson no: </label>
<div style={{padding: '0px'}}>
<input type="text" required
className="form-control"
value={this.state.lesson_no}
onChange={this.onChangeLessonNo}
/>
</div>
</div>
<div className="col-sm-5">
<label>Lesson name: </label>
<div style={{padding: '0px'}}>
<input type="text" required
className="form-control"
value={this.state.lesson_name}
onChange={this.onChangeLessonName}
/>
</div>
</div>
<div className="col-sm-5">
<label>defult_mark: </label>
<div style={{padding: '0px'}}>
<input type="text" required
className="form-control"
value={this.state.defult_mark}
onChange={this.onChangeDefultMark}
/>
</div>
</div>
<div className="col-sm-5">
<label>general_feedback: </label>
<div style={{padding: '0px'}}>
<input type="text" required
className="form-control"
value={this.state.general_feedback}
onChange={this.onChangeFeedBack}
/>
</div>
</div>
</div>
<div className="row">
<div className="col-sm-10">
<label style={{textAlign: 'left'}} >Question text: </label>
<textarea
className="form-control" required
/>
<br/>
<button className="btn btn-block btn btn-secondary" type="submit" value="Submit" style={{ color: "white" }}>Create New Quiz</button>
</div>
</div>
</form>
</div>
)
}
}
\ No newline at end of file
import React, {Component} from 'react';
import axios from 'axios';
import {Link} from "react-router-dom";
import EX from '../../Images/exam.png';
import LS from '../../Images/lesson.png';
export default class LessonAndExam extends Component {
constructor(props) {
super(props);
this.state = {
lessonList:[]
}
}
componentDidMount = () => {
let quizLessonTemp = []
axios.get('http://localhost:5000/')
.then(response => {
console.log(response);
this.setState({ lessonList: response.data.images });
console.log(this.state.lessonList.length)
})
.catch(err => alert(err));
}
render(){
return(
<div className="container">
{this.state.lessonList.map((file) => (
<div className="">
<div className="p-3 mb-2 bg-light text-dark text-left">Accounting Lecture {file.lessonno}</div>
<div className="text-left ml-3">
</div>
<div className="row">
<div className="col-1">
<div style={{padding: '0px'}}>
<img src={EX} alt="upload-image" style={{width:'35px'}}/>
<hr/>
<img src={LS} alt="upload-image" style={{width:'35px'}}/>
</div>
</div>
<div style={{padding: '0px'}}>
<a href={'http://localhost:5000/pdf/'+ file.filename}><p style={{marginTop: '7px'}}>{file.lessonname}</p></a>
<br/>
<a href={'/question/'+ file.lessonno}><p style={{marginTop: '7px'}}>Exam {file.lessonno}</p></a>
</div>
</div>
</div>
))
}
</div>
)
}
}
\ No newline at end of file
import React, { Component } from 'react';
import axios from 'axios';
import { Link } from "react-router-dom";
import swal from 'sweetalert';
const Quantity = props => (
<tr>
{/*<td>{props.quantity.item_id}</td>*/}
<td>{props.quantity.question_text}</td>
<td>{props.quantity.question_answer}</td>
<td>{props.quantity.time_modifiedby}</td>
<td>{props.questions.lesson_no}</td>
<td>{props.questions.question_text}</td>
<td>{props.questions.question_answer}</td>
<td>
<div>
<Link className="mx-1 text-success fas fa-pen text-decoration-none" to={"/edititem/"+props.quantity._id}></Link> <span className=" mx-1 text-danger fas fa-trash" href='#' onClick={()=>{props.deleteProduct(props.quantity._id)}} ></span>
<Link className="text-success fas fa-edit" to={"/questionmanagement/"+props.questions._id}></Link> <span className=" mx-1 text-danger fas fa-trash" href='#' onClick={()=>{props.deleteProduct(props.questions._id)}} ></span>
</div>
</td>
</tr>
......@@ -29,13 +28,13 @@ export default class QuestionBankUI extends Component {
this.state = {
q_type: '',
quantity: []
questions: []
}
}
quantityList() {
return this.state.quantity.map(currentTodo => {
return <Quantity quantity={currentTodo} deleteProduct={this.deleteProduct} key={currentTodo._id} />
return this.state.questions.map(currentTodo => {
return <Quantity questions={currentTodo} deleteProduct={this.deleteProduct} key={currentTodo._id} />
});
}
......@@ -43,7 +42,7 @@ export default class QuestionBankUI extends Component {
axios.get('http://localhost:5000/questions/')
.then(response => {
this.setState({ quantity: response.data });
this.setState({ questions: response.data });
})
.catch(function (error) {
console.log(error);
......@@ -56,7 +55,7 @@ export default class QuestionBankUI extends Component {
axios.get('http://localhost:5000/questions/')
.then(response => {
this.setState({ quantity: response.data });
this.setState({ questions: response.data });
})
.catch(function (error) {
console.log(error);
......@@ -74,13 +73,9 @@ export default class QuestionBankUI extends Component {
onSubmit(e) {
e.preventDefault();
console.log(`Question type: ${this.state.q_type}`);
if (this.state.q_type == "Multiple_choice") {
window.location = '/questionmanagement/';
} else {
//console.log(`Question type: ${this.state.q_type}`);
window.location = '/questionmanagement/';
}
//window.location = '/admin/pcategory';
}
......@@ -88,7 +83,7 @@ export default class QuestionBankUI extends Component {
axios.delete('http://localhost:5000/questions/delete/'+pid)
.then(res => console.log(res.data));
this.setState({
quantity:this.state.quantity.filter(el => el.pid !==pid)
questions:this.state.questions.filter(el => el.pid !==pid)
});
}
......@@ -96,46 +91,27 @@ export default class QuestionBankUI extends Component {
return (
<div className="container text-left">
<div className="col-sm-10" >
<h4> Business Studies</h4>
<h6>Dashboard/My courses/Business Studies/Question bank/Questions</h6>
<hr />
</div>
<form onSubmit={this.onSubmit}>
<div className="col-sm-10" >
<div className="row" >
<div className="col-sm-1 mt-1"><label>Category: </label>
</div>
<div className="col-sm-5">
<div style={{ padding: '0px' }}>
<select style={{ width: '100%' }} className="browser-default custom-select"
onChange={(e) => this.onChangeQType(e)}>
<option>Select Question Type</option>
<option key="Multiple_choice" value="Multiple_choice">Multiple choice</option>
<option key="True_False" value="True_False">True/False</option>)
</select>
</div>
</div>
<div className="col-sm-3">
<button className="btn btn-block btn btn-secondary" type="submit" value="Submit" style={{ color: "white" }}>Create new Question</button>
<Link style={{textDecoration:"none"}} to={"/questionmanagement"}><button className="btn btn-block btn btn-secondary" style={{color:"white"}}>Create new Question</button></Link>
</div>
<div className="col-sm-3">
<button className="btn btn-block btn btn-info" type="submit" value="Submit" style={{ color: "white" }}>Auto Genarate Question</button>
<Link style={{textDecoration:"none"}} to={"/automaticquestion"}><button className="btn btn-block btn btn-info" style={{color:"white"}}>Auto Genarate Question</button></Link>
</div>
</div></div>
</form>
<br/>
......@@ -144,9 +120,9 @@ export default class QuestionBankUI extends Component {
<table className="table" >
<thead>
<tr>
<th><h6>Question Text</h6></th>
<th><h6>Question Answer</h6></th>
<th><h6>Last modified by</h6></th>
<th><h6>Lesson</h6></th>
<th><h6>Question</h6></th>
<th><h6>Answer</h6></th>
<th className="col-sm-1"><h6>Action </h6></th>
</tr>
</thead>
......
......@@ -99,7 +99,7 @@ export default class QuestionLayout extends Component {
// if (this.state.item_id != null) {
axios.get('http://localhost:5000/questions/')
axios.get('http://localhost:5000/questions/lessonNo/1')
.then(response => {
//this.setState({productQuantities: response.data});
let CategoryList = [];
......
......@@ -388,8 +388,9 @@ export default class StudentDashboard extends Component {
<ul>
<li>
<a href="#">
<i className="metismenu-icon"></i>
<i className="metismenu-icon"> </i>
19-Acc-Sasip
</a>
</li>
<li>
......@@ -409,7 +410,7 @@ export default class StudentDashboard extends Component {
</a>
<ul>
<li>
<a href="#">
<a href="/lesson">
<i className="metismenu-icon"></i>
19-Acc-Sasip
</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment