-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
var Student = require('../models/student'); | ||
|
||
exports.index = function(req, res){ | ||
Student.findAll(function(students){ | ||
res.render('students/index', {students:students}); | ||
}); | ||
}; | ||
|
||
exports.show = function(req, res){ | ||
Student.findById(req.params.id, function(student){ | ||
res.render('students/show', {student:student}); | ||
}); | ||
}; | ||
|
||
exports.addTest = function(req, res){ | ||
res.render('students/addtest', {id:req.params.id}); | ||
}; | ||
|
||
exports.init = function(req, res){ | ||
res.render('students/new'); | ||
}; | ||
|
||
exports.create = function(req, res){ | ||
var s = new Student(req.body); | ||
s.save(function(){ | ||
res.redirect('/students'); | ||
}); | ||
}; | ||
|
||
exports.update = function(req, res){ | ||
Student.findById(req.params.id, function(student){ | ||
student.addTest(req.body, function(){ | ||
res.redirect('/students/' + req.params.id); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
var port = process.env.PORT; | ||
var db = process.env.DB; | ||
|
||
var express = require('express'); | ||
var app = express(); | ||
|
||
require('./lib/config')(app); | ||
require('./lib/pipeline')(app, express); | ||
require('./lib/mongodb')(db); | ||
|
||
app.listen(port, function(){ | ||
console.log('Express Ready:', port); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
nav ul { | ||
list-style-type: none; | ||
} | ||
|
||
nav li { | ||
display: inline-block; | ||
margin: 0 10px; | ||
} | ||
|
||
table { | ||
text-align: center; | ||
border-collapse: collapse; | ||
} | ||
|
||
td, th { | ||
min-width: 50px; | ||
padding: 5px; | ||
border: 2px solid black; | ||
} | ||
|
||
.testscore { | ||
width: 20px; | ||
margin: 5px; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
extends ../shared/template | ||
block content | ||
h1 Adding test score | ||
form(method='post' action='/students/#{id}/test') | ||
label Score | ||
input(type="number", name="score") | ||
button Add test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extends ../shared/template | ||
block content | ||
h1 View students | ||
table#students | ||
thead | ||
tr | ||
th Name | ||
th Average | ||
th Letter | ||
th Suspended | ||
th Honor Roll | ||
tbody | ||
each student in students | ||
tr | ||
td(style="background-color:#{student.color}"): a(href="/students/#{student._id}")= student.name | ||
td(style="background-color:#{student.getColor(student.avg())};")= student.avg().toFixed(1) | ||
td(style="background-color:#{student.getColor(student.avg())};")= student.letter() | ||
-console.log(student.isSuspended); | ||
if student.isSuspended() | ||
td(style="background-color:red") Yes | ||
else | ||
td(style="background-color:green") No | ||
if student.onHonorRoll() | ||
td(style="background-color:green") Yes | ||
else | ||
td(style="background-color:red") No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extends ../shared/template | ||
block content | ||
h1 Add a new student | ||
form(method="post", action="/students/new") | ||
label Name | ||
input(type='text', name='name', placeholder='e.g. Bob Boberson') | ||
br | ||
label Color | ||
input(type='color', name='color') | ||
br | ||
button Submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extends ../shared/template | ||
block content | ||
h1 View Student | ||
table | ||
tbody | ||
tr | ||
td(colspan='2')= student.name | ||
tr | ||
td Avg: | ||
td= student.avg().toFixed(2) | ||
tr | ||
td Letter | ||
td= student.letter() | ||
tr | ||
td Suspended | ||
td= student.isSuspended() | ||
tr | ||
td Honor Roll | ||
td= student.onHonorRoll() | ||
tr | ||
td(colspan='2') | ||
form(method='get', action='/students/#{student._id}/test') | ||
button Add Test | ||
#test | ||
each test in student.tests | ||
.testscore(style='height:#{test}px;background-color:#{student.getColor(test)};') | ||
|