Skip to content

Commit

Permalink
Add lines of code endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixeliot committed Feb 10, 2017
1 parent d872992 commit 30202ed
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/templates/admin/outcome-report-results.jade
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ div.style-flat
h4 across an estimated...
div.fakebar
div
| 123,3456
| #{view.options.linesOfCode}
= " "
small lines of code
h4 and expressed creativity by building
Expand Down
28 changes: 24 additions & 4 deletions app/views/admin/OutcomesReportView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ OutcomesReportComponent = Vue.extend
originals = _.map(shareableLevels, 'original')
projects = _.where(Object.values(@indexedSessions), (s) -> s.level.original in originals)
projects.length
selectedClassrooms: ->
@classrooms.filter (c) => @isClassroomSelected[c._id]
selectedCourses: ->
@courses.filter (c) => @isCourseSelected[c._id]
insightsHtml: ->
marked(@insightsMarkdown, sanitize: false)
dataReady: ->
Expand Down Expand Up @@ -150,12 +154,15 @@ OutcomesReportComponent = Vue.extend
submitEmail: (e) ->
$.ajax
type: 'GET',
url: "/db/user"
url: '/db/user'
data: {email: @teacherEmail}
success: @fetchCompleteUser
error: (data) => noty text: "Failed to find user by that email"
error: (data) => noty text: 'Failed to find user by that email', type: 'error'

displayReport: (e) ->
@fetchLinesOfCode().then @finishDisplayReport

finishDisplayReport: ->
resultView = new OutcomeReportResult({
teacher:
fullName: @teacherFullName
Expand All @@ -169,11 +176,12 @@ OutcomesReportComponent = Vue.extend
@trialRequest # toJSON'd
@startDate # string YYYY-MM-DD
@endDate # string YYYY-MM-DD
classrooms: @classrooms.filter (c) => @isClassroomSelected[c._id]
courses: @courses.filter (c) => @isCourseSelected[c._id]
classrooms: @selectedClassrooms
courses: @selectedCourses
@courseCompletion
@courseStudentCounts
@numProgramsWritten
@linesOfCode
@numShareableProjects
@insightsHtml
})
Expand Down Expand Up @@ -257,3 +265,15 @@ OutcomesReportComponent = Vue.extend
courseInstances.forEach (courseInstance) =>
if not _.contains(@$data.courseInstances, { _id: courseInstance.id })
@$data.courseInstances.push(courseInstance.toJSON())

fetchLinesOfCode: ->
$.ajax
type: 'GET',
url: '/admin/calculate-lines-of-code'
data: {
classroomIDs: @selectedClassrooms.map (c) -> c._id
courseIDs: @selectedCourses.map (c) -> c._id
}
success: (data) =>
@linesOfCode = parseInt(data.linesOfCode)
error: (data) => noty text: 'Failed to fetch lines of code', type: 'error'
7 changes: 7 additions & 0 deletions server/middleware/admin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ deleteFeatureMode = (req, res) ->
delete req.session.featureMode
res.send({})

calculateLinesOfCode = (req, res) ->
{ courseIDs, classroomIDs } = req.query
console.log {courseIDs, classroomIDs}
# Get total number of lines of code for all sessions that are in
# one of these classrooms AND one of these courses
res.send({ linesOfCode: "42" })

module.exports = {
putFeatureMode
deleteFeatureMode
calculateLinesOfCode
}
1 change: 1 addition & 0 deletions server/routes/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports.setup = (app) ->

app.put('/admin/feature-mode/:featureMode', mw.admin.putFeatureMode)
app.delete('/admin/feature-mode', mw.admin.deleteFeatureMode)
app.get('/admin/calculate-lines-of-code', mw.admin.calculateLinesOfCode) # For outcomes report

app.all('/api/*', mw.api.clientAuth)

Expand Down

0 comments on commit 30202ed

Please sign in to comment.