<commit_before>/* jshint node: true */

//************************************************************
//  authRouter.js                                           //
//  Active Learning 2110                                    //
//                                                          //
//  Created by <NAME> on 9/18/16.                    //
//  Copyright © 2016 <NAME>. All rights reserved.    //
//                                                          //
//  Date        Name        Description                     //
//  -------     ---------   --------------                  //
//  22Dec16     <NAME>  Initial Design                  //
//                                                          //
//************************************************************
"use strict";

var express           = require('express');
var courseRouter      = express.Router();

var authorizeController  = require('./../controllers/authorizeController');
var inputController      = require('./../controllers/inputController');
var tokenController      = require('./../controllers/tokenController');
var userController       = require('./../controllers/userController');
var courseController     = require('./../controllers/courseController');
var lectureController     = require('./../controllers/lectureController');
var signupController     = require('./../controllers/signupController');

/**
INSTRUCTOR CREATE COURSE

POST	/api_v2/course

Authentication:   user token
Authorization:    instructor

Path Parameters:  none
Query String:     none
Request Body:     application/json     required
{
    "title":      String               required
    "sections":   [
                    {
                      "name": String
                    }
                  ]                    required
    "course_schedule":
    {
        "semester": String             required
        "days":     [String]           required     enum ["mon", "tue", "wed", "thr", "fri"] required
        "time":     String             required
    }
}
**/
courseRouter.route('/')
    .post(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.instructor,
          inputController.requireCourseTitle,
          inputController.requireCourseSchedule,
          inputController.requireSections,
          courseController.createCourse,
          courseController.getUserCourses);

/**
STUDENT JOIN COURSE

POST	/api_v2/course/students

Authentication:   user token
Authorization:    student

Path Parameters:  none
Query String:     none
Request Body:     application/json    required
{
  "section_key":   String             required
}
**/
courseRouter.route('/students')
    .post(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.student,
          userController.setUserName,
          courseController.joinCourse,
          courseController.getUserCourses);

/**
INSTRUCTOR ADD STUDENT

PUT  /api_v2/course/{course_id}/student

Authentication:   user token
Authorization:    instructor

Path Parameters:  none
Query String:     none
Request Body:     application/json    required
{
  "username":     String              required
  "firstname":    String              required
  "lastname":     String              required
  "section_id":   String              required
}
**/
courseRouter.route('/:COURSEID/students')
    .put(tokenController.validateToken,
         tokenController.refreshToken,
         authorizeController.instructor,
         inputController.requireFirstname,
         inputController.requireLastname,
         inputController.requireUsername,
         userController.isValidStudent,
         signupController.preRegisterStudent,
         courseController.instructorAddStudent);

/**
INSTRUCTOR ADD STUDENTS

POST  /api_v2/course/{course_id}/sections/{section_id}/students/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id, section_id String    required
Query String:     none
Request Body:     application/json    required
{
 "username":     String              required
 "firstname":    String              required
 "lastname":     String              required
}
**/
courseRouter.route('/:COURSEID/sections/:SECTIONID/students/:USERID')
   .post(tokenController.validateToken,
        tokenController.refreshToken,
        authorizeController.instructor,
        inputController.requireFirstname,
        inputController.requireLastname,
        inputController.requireUsername,
        userController.isValidStudent,
        signupController.preRegisterStudent,
        courseController.instructorAddStudent);

/**
GET STUDENTS IN COURSE

GET	/api_v2/course/{course_id}/students

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
  "course_key":   String              required
}
**/
courseRouter.route('/:COURSEID/students')
    .get(tokenController.validateToken,
         tokenController.refreshToken,
         courseController.getStudents);

/**
DELETE STUDENT FROM COURSE

DELETE	/api_v2/course/{course_id}/students/{user_id}/

Authentication:   user token
Authorization:    admin, instructor or self student

Path Parameters:  course_id, user_id String    required
Query String:     none
Request Body:     application/json             required
{
  "section_name":   String                     required
}
**/
courseRouter.route('/:COURSEID/students/:USERID')
    .delete(tokenController.validateToken,
            tokenController.refreshToken,
            authorizeController.adminOrInstructorOrSelf,
            courseController.deleteStudentFromCourse);

/**
DELETE STUDENT FROM SECTION

DELETE	/api_v2/course/{course_id}/sections/{section_id}/students/{user_id}/

Authentication:   user token
Authorization:    admin, instructor or self student

Path Parameters:  course_id, user_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/sections/:SECTIONID/students/:USERID')
    .delete(tokenController.validateToken,
            tokenController.refreshToken,
            authorizeController.adminOrInstructorOrSelf,
            courseController.deleteStudentFromCourse3);

/**
GET COURSE INFO

GET	/api_v2/course/{course_id}/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID')
    .get(tokenController.validateToken,
         tokenController.refreshToken,
         courseController.getCourse);

/**
GET COURSE SECTION NAMES

GET	/api_v2/course/{course_id}/sections

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/sections')
   .get(tokenController.validateToken,
        tokenController.refreshToken,
        courseController.getSectionNames);

/**
CREATE COURSE LECTURE

POST	/api_v2/course/{course_id}/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
  "title":        String              required
  "day":          String              required
}
**/
courseRouter.route('/:COURSEID/lectures')
   .post(tokenController.validateToken,
         tokenController.refreshToken,
         authorizeController.instructor,
         courseController.createLecture);

/**
CREATE COURSE LECTURE 2

POST	/api_v2/course/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
 "title":        String              required
 "day":          String              required
}
**/
courseRouter.route('/testing/lectures')
  .post(tokenController.validateToken,
        tokenController.refreshToken,
        authorizeController.instructor,
        lectureController.initialSetup);

/**
DELETE COURSE LECTURE

DELETE	/api_v2/course/{course_id}/lectures/{lecture_id}/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String, lecture_id String     required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/lectures/:LECTUREID')
  .delete(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.instructor,
          courseController.deleteLecture);

/**
GET COURSE LECTURES

GET	/api_v2/course/{course_id}/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String     required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/lectures')
  .get(tokenController.validateToken,
       tokenController.refreshToken,
       authorizeController.instructor,
       courseController.getLectures);

module.exports = courseRouter;
<commit_msg>updates to student complete register and instructor delete student<commit_after>/* jshint node: true */

//************************************************************
//  authRouter.js                                           //
//  Active Learning 2110                                    //
//                                                          //
//  Created by <NAME> on 9/18/16.                    //
//  Copyright © 2016 <NAME>. All rights reserved.    //
//                                                          //
//  Date        Name        Description                     //
//  -------     ---------   --------------                  //
//  22Dec16     <NAME>  Initial Design                  //
//                                                          //
//************************************************************
"use strict";

var express           = require('express');
var courseRouter      = express.Router();

var authorizeController  = require('./../controllers/authorizeController');
var inputController      = require('./../controllers/inputController');
var tokenController      = require('./../controllers/tokenController');
var userController       = require('./../controllers/userController');
var courseController     = require('./../controllers/courseController');
var lectureController     = require('./../controllers/lectureController');
var signupController     = require('./../controllers/signupController');

/**
INSTRUCTOR CREATE COURSE

POST	/api_v2/course

Authentication:   user token
Authorization:    instructor

Path Parameters:  none
Query String:     none
Request Body:     application/json     required
{
    "title":      String               required
    "sections":   [
                    {
                      "name": String
                    }
                  ]                    required
    "course_schedule":
    {
        "semester": String             required
        "days":     [String]           required     enum ["mon", "tue", "wed", "thr", "fri"] required
        "time":     String             required
    }
}
**/
courseRouter.route('/')
    .post(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.instructor,
          inputController.requireCourseTitle,
          inputController.requireCourseSchedule,
          inputController.requireSections,
          courseController.createCourse,
          courseController.getUserCourses);

/**
STUDENT JOIN COURSE

POST	/api_v2/course/students

Authentication:   user token
Authorization:    student

Path Parameters:  none
Query String:     none
Request Body:     application/json    required
{
  "section_key":   String             required
}
**/
courseRouter.route('/students')
    .post(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.student,
          userController.setUserName,
          courseController.joinCourse,
          courseController.getUserCourses);

/**
INSTRUCTOR ADD STUDENT

PUT  /api_v2/course/{course_id}/student

Authentication:   user token
Authorization:    instructor

Path Parameters:  none
Query String:     none
Request Body:     application/json    required
{
  "username":     String              required
  "firstname":    String              required
  "lastname":     String              required
  "section_id":   String              required
}
**/
courseRouter.route('/:COURSEID/students')
    .put(tokenController.validateToken,
         tokenController.refreshToken,
         authorizeController.instructor,
         inputController.requireFirstname,
         inputController.requireLastname,
         inputController.requireUsername,
         userController.isValidStudent,
         signupController.preRegisterStudent,
         courseController.instructorAddStudent);

/**
INSTRUCTOR ADD STUDENTS

POST  /api_v2/course/{course_id}/sections/{section_id}/students/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id, section_id String    required
Query String:     none
Request Body:     application/json    required
{
 "username":     String              required
 "firstname":    String              required
 "lastname":     String              required
}
**/
courseRouter.route('/:COURSEID/sections/:SECTIONID/students')
   .post(tokenController.validateToken,
        tokenController.refreshToken,
        authorizeController.instructor,
        inputController.requireFirstname,
        inputController.requireLastname,
        inputController.requireUsername,
        userController.isValidStudent,
        signupController.preRegisterStudent,
        courseController.instructorAddStudent);

/**
GET STUDENTS IN COURSE

GET	/api_v2/course/{course_id}/students

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
  "course_key":   String              required
}
**/
courseRouter.route('/:COURSEID/students')
    .get(tokenController.validateToken,
         tokenController.refreshToken,
         courseController.getStudents);

/**
DELETE STUDENT FROM COURSE

DELETE	/api_v2/course/{course_id}/students/{user_id}/

Authentication:   user token
Authorization:    admin, instructor or self student

Path Parameters:  course_id, user_id String    required
Query String:     none
Request Body:     application/json             required
{
  "section_name":   String                     required
}
**/
courseRouter.route('/:COURSEID/students/:USERID')
    .delete(tokenController.validateToken,
            tokenController.refreshToken,
            authorizeController.adminOrInstructorOrSelf,
            courseController.deleteStudentFromCourse);

/**
DELETE STUDENT FROM SECTION

DELETE	/api_v2/course/{course_id}/sections/{section_id}/students/{user_id}/

Authentication:   user token
Authorization:    admin, instructor or self student

Path Parameters:  course_id, user_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/sections/:SECTIONID/students/:USERID')
    .delete(tokenController.validateToken,
            tokenController.refreshToken,
            authorizeController.adminOrInstructorOrSelf,
            courseController.deleteStudentFromCourse3);

/**
GET COURSE INFO

GET	/api_v2/course/{course_id}/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID')
    .get(tokenController.validateToken,
         tokenController.refreshToken,
         courseController.getCourse);

/**
GET COURSE SECTION NAMES

GET	/api_v2/course/{course_id}/sections

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/sections')
   .get(tokenController.validateToken,
        tokenController.refreshToken,
        courseController.getSectionNames);

/**
CREATE COURSE LECTURE

POST	/api_v2/course/{course_id}/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
  "title":        String              required
  "day":          String              required
}
**/
courseRouter.route('/:COURSEID/lectures')
   .post(tokenController.validateToken,
         tokenController.refreshToken,
         authorizeController.instructor,
         courseController.createLecture);

/**
CREATE COURSE LECTURE 2

POST	/api_v2/course/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String    required
Query String:     none
Request Body:     application/json    required
{
 "title":        String              required
 "day":          String              required
}
**/
courseRouter.route('/testing/lectures')
  .post(tokenController.validateToken,
        tokenController.refreshToken,
        authorizeController.instructor,
        lectureController.initialSetup);

/**
DELETE COURSE LECTURE

DELETE	/api_v2/course/{course_id}/lectures/{lecture_id}/

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String, lecture_id String     required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/lectures/:LECTUREID')
  .delete(tokenController.validateToken,
          tokenController.refreshToken,
          authorizeController.instructor,
          courseController.deleteLecture);

/**
GET COURSE LECTURES

GET	/api_v2/course/{course_id}/lectures

Authentication:   user token
Authorization:    instructor

Path Parameters:  course_id String     required
Query String:     none
Request Body:     none
**/
courseRouter.route('/:COURSEID/lectures')
  .get(tokenController.validateToken,
       tokenController.refreshToken,
       authorizeController.instructor,
       courseController.getLectures);

module.exports = courseRouter;

{'fraction_non_alphanumeric': 0.10382903916936768, 'fraction_numerical': 0.0035159039718727684, 'mean_word_length': 2.450341167551175, 'pattern_counts': {'":': 42, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607736', 'n_tokens_mistral': 4611, 'n_tokens_neox': 4617, 'n_words': 998}