diff options
| -rw-r--r-- | app.js | 2 | ||||
| -rw-r--r-- | assets/css/style.css | 12 | ||||
| -rw-r--r-- | node_simple.js | 2 | ||||
| -rw-r--r-- | routes/index.js | 18 | ||||
| -rw-r--r-- | views/admin.hbs | 161 | ||||
| -rw-r--r-- | views/layouts/layout.hbs | 2 |
6 files changed, 126 insertions, 71 deletions
@@ -21,7 +21,7 @@ app.engine('.hbs', hbs({extname: '.hbs', defaultLayout: 'layout', partialsDir: __dirname + '/views/partials'})); // Set directory for partials app.set('views', path.join(__dirname, 'views')); // Our view path -app.set('view engine', '.hbs'); +app.set('view engine', 'hbs'); // Middleware initialization, make sure everything is initialized in proper order app.use(bodyParser.json()); diff --git a/assets/css/style.css b/assets/css/style.css index e81046d..b4fafb1 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -32,7 +32,6 @@ main { justify-content: center; flex-flow: column; /* Makes it grow vertically */ } - /*** INDEX.HTML ***/ main .search { background-color: rgba(235,235,235, 0.7); @@ -405,7 +404,7 @@ section.exam-info em { } /*** ABOUT PAGE END ***/ -/************************** Pop-up Window *********************************************/ +/************************** Pop-up Window ************************************/ .login-window, .registration-window { display: inline-block; @@ -424,4 +423,13 @@ section.exam-info em { .login-window .modal-header, .registration-window .modal-header { text-align: center; } +/** Form Pages for Admin **/ + +.admin-form{ + padding: 3px; + margin: 3px; + border-radius: 10px; + background-color: rgba(197, 197, 197, 0.6); + +} diff --git a/node_simple.js b/node_simple.js index 7e9c736..033beb7 100644 --- a/node_simple.js +++ b/node_simple.js @@ -746,4 +746,4 @@ exports.get_exam_byID = function (id) { } ); }); - });*/
\ No newline at end of file + });*/ diff --git a/routes/index.js b/routes/index.js index 1e3f1e0..da9ec8d 100644 --- a/routes/index.js +++ b/routes/index.js @@ -38,8 +38,8 @@ router.get('/admin', function(req,res){ res.render('admin', {csrfToken: req.csrfToken()}); }); - -router.post('/admin/update', function(req,res){ +/* Adds exam from front-end */ +router.post('/admin/update/exam', function(req,res){ var course_code = req.body.course_code, year = req.body.year, type = req.body.type, @@ -73,6 +73,20 @@ router.post('/admin/update', function(req,res){ res.redirect('/admin'); }); +/* Adds course from front-end */ +router.post('/admin/update/course', function(req,res){ + var course_code = req.body.course_code, + title = req.body.title; + dbFile.add_course(course_code, title, function(courseAdded, statusMessage){ + if(courseAdded){ + console.log("Success!"); + }else{ + console.log("Failure!"); + } + console.log("Status message: " + statusMessage) + }); + res.redirect('/admin'); +}); //EXAMPLE EXPECTED DATA GIVEN BELOW: /*[ {courseCode: 'CSC240', diff --git a/views/admin.hbs b/views/admin.hbs index ecbd46e..da33f41 100644 --- a/views/admin.hbs +++ b/views/admin.hbs @@ -1,69 +1,102 @@ <main id="solutions-main"> -<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3"> -<h4>Add Exam</h4> -<form action="/admin/update" method="post"> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="course code" - name="course_code"> +<div class="row signup"> + <div class="col-md-3 col-md-offset-1 admin-form"> + <h4>Add Exam</h4> + <form action="/admin/update/exam" method="post"> + <div class="form-group"> + Course Code: <input type="text" + class="form-control" + placeholder="course code" + name="course_code"> + </div> + <div class="form-group"> + Year of Exam: + <input type="text" + class="form-control" + placeholder="year" + name="year"> + </div> + <div class="form-group"> + Term: <input type="text" + class="form-control" + placeholder="term" + name="term"> + </div> + <div class="form-group"> + Type of test: + <input type="radio" name="type" value="Midterm"> Midterm + <input type="radio" name="type" value="Final"> Final + </div> + <div class="form-group"> + List all instructors separated by comma: + <input type="text" + class="form-control" + placeholder="instructor1,instructor2,.." + name="instructors"> + </div> + <div class="form-group"> + Page Count: + <input type="text" + class="form-control" + placeholder="page count" + name="page_count"> + </div> + <div class="form-group"> + Questions count: + <input type="text" + class="form-control" + placeholder="questions count" + name="questions_count"> + </div> + <div class="form-group"> + Questions Seperated by Comma + <input type="text" + class="form-control" + placeholder="q1,q2,q3,.." + name="questions_list"> + </div> + + <div class="form-group"> + Upload Date: + <input type="text" + class="form-control" + placeholder="yyyy-mm-dd" + name="upload_date"> + </div> + <div class="form-group"> + Your username: + <input type="text" + class="form-control" + placeholder="uploader" + name="uploaded_by"> + </div> + + <input type="hidden" name="_csrf" value="{{ csrfToken }}"> + <button type="submit" class="btn btn-primary">Submit</button> + </form> </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="year" - name="year"> + + <div class="col-md-3 admin-form"> + <h4>Add Course</h4> + <form action="/admin/update/course" method="post"> + <div class="form-group"> + Course Code: <input type="text" + class="form-control" + placeholder="e.g. CSC240" + name="course_code"> + </div> + <div class="form-group"> + Title: <input type="text" + class="form-control" + placeholder="e.g. Theory of Computation" + name="title"> + </div> + <input type="hidden" name="_csrf" value="{{ csrfToken }}"> + <button type="submit" class="btn btn-primary">Submit</button> + </form> + </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="term" - name="term"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="type" - name="type"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="instructor1,instructor2,.." - name="instructors"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="page count" - name="page_count"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="questions count" - name="questions_count"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="q1,q2,q3,.." - name="questions_list"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="upload date" - name="upload_date"> - </div> - <div class="form-group"> - <input type="text" - class="form-control" - placeholder="uploader" - name="uploaded_by"> - </div> - <input type="hidden" name="_csrf" value="{{ csrfToken }}"> - <button type="submit" class="btn btn-primary">Submit</button> -</form> + + </div> </main>
\ No newline at end of file diff --git a/views/layouts/layout.hbs b/views/layouts/layout.hbs index 667860c..62e9134 100644 --- a/views/layouts/layout.hbs +++ b/views/layouts/layout.hbs @@ -1,4 +1,4 @@ -!doctype html> +<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> |
