Skip to content

cs-education/ClassCapture_HTTPServer

Repository files navigation

ClassCapture

A platform whereby students participate in a crowdsourced effort to aggregate quality lecture video content via mobile devices.

Why SailsJS

This is a Sails application.

There are a whole host of reasons for choosing SailsJS

Schemas

All database models are stored in the api/models/ directory. The API to interact with these Schemas are scaffolded by the SailsJS framework. The blueprint of the scaffolded API are detailed here.

Recording

Look at api/models/Recording.js for a concrete, up to date representation of this model. A Recording contains basic metadata regarding a given user uploaded video.

  • Attributes
    • startTime
      • The timestamp for the starting time of the related recording file
      • Type: Date
      • Required
      • Must be chronologically before endTime
    • endTime
      • The timestamp for the ending time of the related recording file
      • Type: Date
      • Required
      • Must be chronologically after startTime
    • filename
      • The filename for the video resource that this Recording object holds metadata for
      • Type: String
      • Unique
    • section
      • The section that this recording was taken for
      • Type: Section
      • Required

Course

Look at api/models/Course.js for a concrete, up to date representation of this model. A Course object contains basic metadata for a Course that contains sections.

  • Attributes
    • department
      • Department that the course is under. For example, CS 225 is under the CS department.
      • Type: String
      • Required
      • Must consist of only uppercase alphabet characters and must have a minimum length of 2
    • number
      • The course number. For example, CS 225 has the course number 225
      • Type: integer
      • Required
    • sections
      • The sections under this course. This would things like Lecture, Discussion, or Lab sections for a particular course.
      • Type: Collection of Sections (AKA Section Array)
      • This can just be an array of Section IDs like [1,3,67]
    • year
      • The year that the course is in (such as 2015)
    • semester
      • The semester, which can either be in ['spring', 'summer', 'fall']

Section

Look at api/models/Section.js for a concrete, up to date representation of this model. A Section contains basic metadata for a Section that is part of a course.

  • Attributes
    • startTime
      • Starting time for the section. The date for this value is scaled back to epoch (Jan 1st, 1970), however, the time of the value is preserved. For example: 1 PM on November 5th, 2015 is scaled back to 1 PM on January 1st, 1970.
      • Type: Datetime
      • Required
    • endTime
      • Ending time for the section. The data for this value is also scaled back to epoch, like the startTime field.
      • Type: Datetime
      • Required
    • name
      • The name for the section. For example, Lecture sections are typically named somthing like AL1.
      • Type: String
      • Required
      • Must be at least 2 characters long
    • course
      • The course object that this section falls under.
      • Type: Course
      • Required
      • This can be specified with just the ID of the Course object.

API Docs

Here's some basic info on how to interact with the API. This is all just from the API scaffolding that is provided by the SailsJS framework (they have good documentation on this as well).

Basic Object manipulation

  • /<model>/
    • GET
      • Responds with a list of all objects of the model type in the form of a JSON array
    • POST
      • Creates a new object within the Model schema
      • Request body must contain JSON representation of the object you want to create. All required fields must be in this JSON object
  • /<model>/<id>
    • GET
      • Responds with the object that has the specified id.
    • PUT
      • Used to edit the object with the specified id.
      • Request body must contain JSON object with fields that contain the new values that you want to update the object with. For example, if I wanted to update the startTime for a Recording object with the ID 3, I would send a put to /recording/3 and would put the following JSON in the request body: { "startTime": <new date value here> }
    • DELETE
      • Delete the object with the specified ID.

Video Storage Interface

Just some more info on how to interact with the video storage system through the API server.

  • video/<videoname>
    • GET
      • Will respond with a filestream to the video file that is specified by the videoname parameter.
    • POST
      • Used to upload a new video to the video storage. The filename for the video is specified by the videoname parameter.
      • Request must be a multi-part file upload
    • PUT
      • Used to overwrite an existing video that exists in video storage. The filename for the video you wish to overwrite should be specified by the videoname parameter.
      • Request should be a multi-part file upload.
    • DELETE
      • Used to delete the video specified by the videoname parameter.

Complex Queries

You can also do complex queries with the API. The Sails JS Docs on this topic give a good overview on how to do this.

Dev Tips

Testing

  • Quick tip: If you're banging you're head against a failing test case, try cleaning the database (npm run clean) and then running the tests again (npm test).

Database Seeding for Development

  • I've added some seed scripts to help out with development. These scripts will prepopulate the database with entries for each of the Course, Section, Recording objects. These scripts can be found in the test/seed_scripts directory.
  • To run a seed script, like test/seed_scripts/Course.seed.test.js, you can do so by typing mocha test/bootstrap.test.js test/seed_scripts/Course.seed.test.js. This must be done in the base directory of the project (same level as package.json).
  • You must run the seed scripts in this order: test/seed_scripts/Course.seed.test.js, test/seed_scripts/Section.seed.test.js,test/seed_scripts/Recording.seed.test.js
  • For convenience, I've added a one-line npm script to the package.json. To run all the seed scripts at once, just run npm run-script seed.
  • Additionally, you can also just copy test/seed_db_files/seeded_db.json into the .tmp/localDiskDb.db file and unzip the contents of test/seed_db_files/classcapture_videos.zip into ~/classcapture_videos/.
  • Each seed script should only be run once (to prevent duplicate classes from being created). A seed script will fail some tests if it has already been run before (for example the Course seed script creates some courses with hardcoded values).

About

HTTP Server for ClassCapture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •