Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

// lol, could probably get rid of this or get a favicon :P
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
Expand Down Expand Up @@ -50,6 +51,7 @@ app.get('/verify', index.GETemailver);
app.get('/user', function(req, res, next) {
res.json({user: req.user});
})
// I might add a few organizational comments and line breaks here
app.post('/api/login', index.POSTlogin);
app.post('/api/logout', index.POSTlogout);
app.post('/api/register', index.POSTregister);
Expand All @@ -72,6 +74,11 @@ app.delete('/api/delUser/:_id', index.DELETEdelUser);
app.post('/api/editOverview/', index.POSTeditOverview);
app.get('/api/overview', index.GEToverview);

//kinda weird to do this as the end of the middleware chain. I would probably do
// app.get('/', function(req, res){
// res.sendFile('main.html', { root: path.join(__dirname, 'views') });
// })
// that what it only sends the file if they go to '/' and not to any request that is unrecognized.
app.use(function(req, res) {
// Use res.sendfile, as it streams instead of reading the file into memory.
res.sendFile('main.html', { root: path.join(__dirname, 'views') });
Expand Down
1 change: 1 addition & 0 deletions models/cohort.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var mongoose = require('mongoose');

var cohortSchema = mongoose.Schema({
// how do you know what students are in the cohort?
name: String,
comment: String,
actionSteps: String,
Expand Down
1 change: 1 addition & 0 deletions models/overview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var mongoose = require('mongoose');

//why does overview have it's own database object? What is it an overview of?
var overviewSchema = mongoose.Schema({
overview: String
});
Expand Down
2 changes: 2 additions & 0 deletions models/student.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ var mongoose = require('mongoose');

var studentSchema = mongoose.Schema({
name: String,
// is this how you know which cohort they are in?
program: String,
archived: Boolean,
//should probably be a ref to overview
overview: String,
actionSteps: String
});
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/cohortController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var cohortController = function($scope, $http, $state) {
var cohortStudentsController = function($scope, $http, $state) {

$scope.showStudent = function(student) {
// seems a bit convoluted but it works
$scope.$parent.$parent.currentStudent = student;
$scope.$parent.$parent.editStudent = angular.copy(student);
$state.go('index.student.showData');
Expand Down
12 changes: 12 additions & 0 deletions public/javascripts/cohortVizController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ var cohortVizController = function($scope, $http, $state) {
$http.get('/api/cohort/data/' + $scope.currentCohortName).then(function successCallback(
response) {
$scope.timeFrame = "-1";
// oh man, this is a bit late, but there are some really cool ways to do shit like this in es6/7/8, if you are interested look into object destructuring and spread
// it would be $scope = {...$scope, ...response.data};
// or Object.assign($scope, response.data);
$scope.attendance = response.data.attendanceList;
$scope.dates = response.data.datesList;
$scope.stars = response.data.starsList;
Expand All @@ -18,6 +21,7 @@ var cohortVizController = function($scope, $http, $state) {
var thresh = new Date();
thresh.setDate(thresh.getDate() - days);
if (arr !== undefined) {
// this would have been a great place for a dates.filter()
for (var i = 0; i < arr.length; i++) {
if (new Date(dates[i]) >= thresh || days === -1) {
newArray.push(arr[i]);
Expand All @@ -30,13 +34,21 @@ var cohortVizController = function($scope, $http, $state) {

var formatPieData = function(data){
var newList = [];
// no dicts in JS, objects have some important differences
var dataDict = {};
// probably not the clearest way to format this
if (data !== undefined) {
data.forEach(function(i) {
if (i !== undefined && i === i && i!== null) {
dataDict[i] = (dataDict[i] || 0) + 1;
}
});
// would have probably gone with
// return Object.keys.map(function (key){
// return {key:key, y:dataDict[key]}
//})
//or with new syntax
// return Object.keys,map(key => ({key, y:dataDict[key]}))
var keys = Object.keys(dataDict);
for (var i = 0; i < keys.length; i++) {
newList.push({
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/indexController.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var indexController = function($scope, $http, $location, $state) {
});

$scope.logout = function(){
// if you guys are curious you should look in the the official promise spec, which is different and in my opinion way cleaner than the q bullshit that angular uses
$http.post("/api/logout").then(function successCallback(response) {
$state.go('login');
}, function errorCallback(response) {
Expand Down
2 changes: 2 additions & 0 deletions routes/entryRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ routes.POSTnewDailyEntry = function(req, res, next) {
var engageContent = parseInt(req.body.engageContent);
var engagePeer = parseInt(req.body.engagePeer);
var engageAdult = parseInt(req.body.engageAdult);
//oooof ^ looks like it was a pain to write
var querry = {
_studentID: studentID,
date: currentDate,
Expand All @@ -38,6 +39,7 @@ routes.POSTnewDailyEntry = function(req, res, next) {
engagePeer: engagePeer,
engageAdult:engageAdult
};
// why define the callback here instead of in line? Not bad just curious
var callback = function(err, newEntryObj) {
if (err) return res.status(500).json({msg: 'Error submitting entry'});
res.json({newEntryObj:newEntryObj, msg: 'Entry submitted successfully!'});
Expand Down