Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Track progress of Assignment #242

Merged
merged 2 commits into from
Aug 24, 2016
Merged
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
3 changes: 2 additions & 1 deletion app/actions/assignment-actions.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Reflux = require 'reflux'

module.exports = Reflux.createActions [
'setAssignment'
'setAssignment',
'incrementClassificationProgress'
]
19 changes: 19 additions & 0 deletions app/partials/education-bar.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,29 @@ module.exports = React.createClass
</option>
}
</select>
{@renderMyClassificationsCount()}
</div>

render: ->
if @state.assignments.active
@renderEducationBar()
else
null

renderMyClassificationsCount: ->
htmlCounter = null
if @state.assignments.activeAssignment && @state.assignments.activeAssignment.id != '0'
classificationTarget = parseInt(@state.assignments.activeAssignment.classificationTarget)
if isNaN(classificationTarget)
classificationTarget = ''
else
classificationTarget = ' / ' + classificationTarget
myClassificationCount = @state.assignments.activeAssignment.myClassificationCount

htmlCounter =
<div className="my-classifications">
<label>Progress:</label>
<span>{myClassificationCount}{classificationTarget}</span>
</div>

return htmlCounter
11 changes: 11 additions & 0 deletions app/stores/assignments-store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module.exports = Reflux.createStore
id: '0',
name: 'No assignment'
workflowId: config.workflowId
classificationTarget: ''
myClassificationCount: 0
]
activeAssignment: false
active: undefined
Expand All @@ -41,6 +43,11 @@ module.exports = Reflux.createStore
console.warn "Setting assignment to #{newAssignmentId}"
@data = newState
@trigger @data

onIncrementClassificationProgress: () ->
newState = _.assign {}, @data
if newState.activeAssignment
newState.activeAssignment.myClassificationCount++

_fetchAssignments: (user) ->
fetch 'https://education-api.zooniverse.org/assignments/',
Expand All @@ -55,10 +62,14 @@ module.exports = Reflux.createStore
if json.data.length
newState = _.assign {}, @data
newState.active = true

newState.assignments = newState.assignments.concat json.data.map (assignment) ->
id: assignment.id
workflowId: assignment.attributes.workflow_id
name: assignment.attributes.name
classificationTarget: assignment.attributes.metadata.classifications_target ? ''
myClassificationCount: 999999 #TODO: determine my initial Classification Count

@data = newState
@trigger @data
console.info 'assignments', @data
Expand Down
4 changes: 3 additions & 1 deletion app/stores/classification-store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ config = require '../lib/config'
classifierActions = require '../actions/classifier-actions'

annotationsStore = require './annotations-store'
projectStore = require './project-store'
#projectStore = require './project-store'
subjectStore = require './subject-store'
workflowStore = require './workflow-store'
assignmentActions = require '../actions/assignment-actions'

module.exports = Reflux.createStore
data: null
Expand Down Expand Up @@ -37,6 +38,7 @@ module.exports = Reflux.createStore
@trigger @data

finish: ->
assignmentActions.incrementClassificationProgress()
annotations = _.map annotationsStore.data, (annotation) ->
task: workflowStore.data.first_task
value: [annotation]
Expand Down
10 changes: 9 additions & 1 deletion css/education-bar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
color: white
padding: 1em 1vw
display: flex
flex-wrap: wrap
align-items: center
margin-bottom: 10px

select
font-size: 2em
font-size: 1em
display: block

h4
Expand All @@ -18,3 +19,10 @@
p
margin: 0
margin-right: 0.5em

.my-classifications
margin-left: 2em

label
margin-right: 0.5em
font-weight: bold