diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-21 10:09:30 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-21 10:09:30 +0000 |
| commit | 7f385f73ebc024e2c07e628fc1500bcb21b69837 (patch) | |
| tree | 0363ad066c3d8654469749bf3675fb3add83e556 | |
| parent | 68be8844ddc1e30e34745a0589fa3395ae6ec198 (diff) | |
added admin page, fixed some minor issues
| -rw-r--r-- | node_simple.js | 13 | ||||
| -rw-r--r-- | routes/index.js | 4 | ||||
| -rw-r--r-- | views/admin.hbs | 69 |
3 files changed, 73 insertions, 13 deletions
diff --git a/node_simple.js b/node_simple.js index 1542b83..419495a 100644 --- a/node_simple.js +++ b/node_simple.js @@ -65,8 +65,6 @@ var uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo' //****************************FUNCTIONS************************************************| - - // this function returns an array where is element contains info for a particular question // such as the question number (_id), number of solutions (count), and number of comments // (comments). [ {_id,count,comments}, {} ...] @@ -113,8 +111,6 @@ exports.get_exam_info_by_ID = function (exam_id, callback) { } - - exports.add_comment = function (sol_id, fields) { var Data = { text: fields[0], @@ -210,8 +206,6 @@ exports.add_solution = function (fields) { } - - /* * This function will retrieve all exams in the database given the course code ... * ... ordered by the year of the exam. @@ -262,8 +256,6 @@ exports.get_all_exams = function (course_code, callback) { } - - /* * This function will add an exam to the database UNLESS the exams already exists. * If the exams table is empty, this will create one and then add the data. @@ -334,7 +326,6 @@ exports.add_exam = function (fields, questions_array) { }); } - /* * This function will return TRUE if the provided exam info already exists in the database * OR FALSE if it does not exist in the database. @@ -388,7 +379,6 @@ exports.find_exam = function (fields, callback) { }); } - /* * This function will add a course to the database UNLESS the course already exists. * If the course table is empty, this will create one and then add the data. @@ -432,7 +422,6 @@ exports.add_course = function (course_code, title) { }); } - /* * This function will return TRUE if the provided course info already exists in the database * OR FALSE if it does not exist in the database. @@ -473,7 +462,6 @@ exports.find_course = function (course_code, callback) { }); } - /* * This function will remove the exam from the database given the combination of (course_code+ year + term + type) * Params: fields - an array of format ["course_code", year, "term", "type"] @@ -518,7 +506,6 @@ exports.remove_exam = function (fields) { }); } - //get_exam_byID("578a44ff71ed097fc3079d6e"); exports.get_exam_byID = function (id) { diff --git a/routes/index.js b/routes/index.js index 708e532..bea28da 100644 --- a/routes/index.js +++ b/routes/index.js @@ -34,6 +34,10 @@ router.get('/questions', function(req, res, next) { res.render('questions'); }); +router.get('/admin', function(req,res){ + res.render('admin'); +}); + /* Render/GET exam page */ /* Render/GET exam page */ //EXAMPLE EXPECTED DATA GIVEN BELOW: diff --git a/views/admin.hbs b/views/admin.hbs new file mode 100644 index 0000000..89e78c7 --- /dev/null +++ b/views/admin.hbs @@ -0,0 +1,69 @@ +<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="/add_exam" method="post"> + <div class="form-group"> + <input type="text" + class="form-control" + placeholder="course code" + name="course_code"> + </div> + <div class="form-group"> + <input type="text" + class="form-control" + placeholder="year" + name="year"> + </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 |
