 AssignmentStudents = rclass
     displayName : "CourseEditor-AssignmentStudents"
     propTypes:
+        name       : rtypes.string.isRequired
         flux       : rtypes.object.isRequired
         assignment : rtypes.object.isRequired
         students   : rtypes.object.isRequired

StudentList = rclass
    displayName : "CourseEditor-StudentList"
    propTypes:
        students   : rtypes.object.isRequired
        user_map   : rtypes.object.isRequired
        info       : rtypes.func.isRequired

    render_last: (name, obj) ->
        v = [<span key='name'>{name+': '}</span>]
        if obj?
            if obj.time?
                v.push(<span key='time'>{new Date(obj.time).toLocaleString()}</span>)
            if obj.error
                v.push(<span key='error' style={color:'red'}>{obj.error}</span>)
        else
            v.push("(not yet)") # TODO: put a button on it
        return v

    render_student_info: (info) ->
        <Row >
            <Col md=4 key='last_assignment'>
                {@render_last('Assigned', info.last_assignment)}
            </Col>
            <Col md=4 key='collect'>
                {@render_last('Collected', info.last_collect)}
            </Col>
            <Col md=4 key='return_graded'>
                {@render_last('Returned', info.last_return_graded)}
            </Col>
        </Row>


                    @set_activity(id:id)
                    cb?()

        copy_assignment: (type, assignment_id, student_id) =>
            # type = assigned, collected, graded
            switch type
                when 'assigned'
                    @copy_assignment_to_student(assignment_id, student_id)
                when 'collected'
                    @copy_assignment_from_student(assignment_id, student_id)
                when 'graded'
                    @return_assignment_to_student(assignment_id, student_id)
                else
                    @set_error("copy_assignment -- unknown type: #{type}")

        open_assignment: (type, assignment_id, student_id) =>
            # type = assigned, collected, graded
            assignment = store.get_assignment(assignment_id)
            student    = store.get_student(student_id)
            student_project_id = student.get('project_id')
            if not student_project_id?
                @set_error("open_assignment: student project not yet created")
                return
            # Figure out what to open
            switch type
                when 'assigned' # where project was copied in the student's project.
                    path = assignment.get('target_path')
                    proj = student_project_id
                when 'collected'   # where collected locally
                    path = assignment.get('collect_path') + '/' + student.get('student_id')  # TODO: refactor
                    proj = project_id
                when 'graded'  # where project returned
                    path = assignment.get('graded_path')  # refactor
                    proj = student_project_id
                else
                    @set_error("open_assignment -- unknown type: #{type}")
            if not proj?
                @set_error("no such project")
                return
            # Now open it
            flux.getProjectActions(proj).open_directory(path)

    actions = flux.createActions(name, CourseActions)

