Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add total attendance column to workshop dashboard for local summer workshops #26828

Merged
merged 27 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
049c0ce
add total attendance column to workshop dashboard
Jan 31, 2019
d37db40
add unit tests
Jan 31, 2019
18368b9
Merge branch 'staging' into add-attendance-column
Feb 5, 2019
b80d3e5
Merge branch 'staging' into add-attendance-column
Feb 6, 2019
c2ad7db
WIP UI tests
Feb 7, 2019
f292241
Merge branch 'staging' into add-attendance-column
Feb 9, 2019
f0aef54
Merge branch 'staging' into add-attendance-column
Feb 14, 2019
b2e25fa
Merge branch 'staging' into add-attendance-column
Feb 20, 2019
22a822d
Merge branch 'staging' into add-attendance-column
Feb 20, 2019
20ead1b
undo changes to soundlibrary
Feb 22, 2019
5f843f9
Update package.json
Feb 21, 2019
fe97255
Merge branch 'staging' into add-attendance-column
Feb 22, 2019
d916f5a
Merge branch 'staging' into add-attendance-column
Feb 26, 2019
d58515f
Merge branch 'staging' into add-attendance-column
Mar 7, 2019
ff7f283
prettier changes
Mar 7, 2019
4a9b63b
add UI tests
Mar 8, 2019
78712f7
Merge branch 'staging' into add-attendance-column
Mar 12, 2019
598d9e7
remove column that has moved in staging, remove soundlibrary.json fro…
Mar 12, 2019
90b5600
fix tests
Mar 15, 2019
42f3233
Merge branch 'staging' into add-attendance-column
Mar 18, 2019
c21a524
Merge branch 'staging' into add-attendance-column
Mar 22, 2019
16e9c14
Merge branch 'staging' into add-attendance-column
Mar 26, 2019
e298989
fix factory
Mar 26, 2019
4982fd4
fix serializer test
Mar 26, 2019
c1840e4
remove breaking change to pd factory
Mar 27, 2019
e6ab338
Merge branch 'staging' into add-attendance-column
Mar 27, 2019
8e0ed38
Merge branch 'staging' into add-attendance-column
Apr 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export default class WorkshopEnrollment extends React.Component {
enrollments: PropTypes.arrayOf(enrollmentShape).isRequired,
workshopId: PropTypes.string.isRequired,
workshopCourse: PropTypes.string.isRequired,
workshopSubject: PropTypes.string,
workshopSubject: PropTypes.string.isRequired,
workshopDate: PropTypes.string.isRequired,
numSessions: PropTypes.number.isRequired,
accountRequiredForAttendance: PropTypes.bool.isRequired,
onDelete: PropTypes.func.isRequired,
location: PropTypes.object,
Expand Down Expand Up @@ -59,6 +60,7 @@ export default class WorkshopEnrollment extends React.Component {
onDelete={this.props.onDelete}
workshopCourse={this.props.workshopCourse}
workshopSubject={this.props.workshopSubject}
numSessions={this.props.numSessions}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {workshopEnrollmentStyles as styles} from '../workshop_enrollment_styles'
const CSF = 'CS Fundamentals';
const DEEP_DIVE = 'Deep Dive';
const NA = 'N/A';
const LOCAL_SUMMER = '5-day Summer';

export default class WorkshopEnrollmentSchoolInfo extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -87,6 +88,11 @@ export default class WorkshopEnrollmentSchoolInfo extends React.Component {
<td>{enrollment.email}</td>
<td>{enrollment.district_name}</td>
<td>{enrollment.school}</td>
{this.props.workshopSubject === LOCAL_SUMMER && (
<td>
{enrollment.attendances} / {this.props.numSessions}
</td>
)}
{this.props.workshopCourse === CSF && (
<td>{enrollment.role ? enrollment.role : NA}</td>
)}
Expand Down Expand Up @@ -160,6 +166,9 @@ export default class WorkshopEnrollmentSchoolInfo extends React.Component {
<th style={styles.th}>Email</th>
<th style={styles.th}>District</th>
<th style={styles.th}>School</th>
{this.props.workshopSubject === LOCAL_SUMMER && (
<th style={styles.th}>Total Attendance</th>
)}
{this.props.workshopCourse === CSF && (
<th style={styles.th}>Current Role</th>
)}
Expand Down Expand Up @@ -198,5 +207,6 @@ WorkshopEnrollmentSchoolInfo.propTypes = {
accountRequiredForAttendance: PropTypes.bool.isRequired,
onDelete: PropTypes.func.isRequired,
workshopCourse: PropTypes.string.isRequired,
workshopSubject: PropTypes.string
workshopSubject: PropTypes.string.isRequired,
numSessions: PropTypes.number.isRequired
};
1 change: 1 addition & 0 deletions apps/src/code-studio/pd/workshop_dashboard/workshop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ export class Workshop extends React.Component {
workshopCourse={this.state.workshop.course}
workshopSubject={this.state.workshop.subject}
workshopDate={firstSessionDate}
numSessions={this.state.workshop.sessions.length}
enrollments={this.state.enrollments}
onDelete={this.handleDeleteEnrollment}
accountRequiredForAttendance={
Expand Down
2 changes: 1 addition & 1 deletion apps/src/code-studio/soundLibrary.json
Original file line number Diff line number Diff line change
Expand Up @@ -3724,4 +3724,4 @@
"category_male_voiceover/you_win_male"
]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to get soundLibrary.json entirely out of this PR, but understandable if that's tricky at this point.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import WorkshopEnrollmentSchoolInfo from '@cdo/apps/code-studio/pd/workshop_dashboard/components/workshop_enrollment_school_info';
import React from 'react';
import {expect} from 'chai';
import {shallow} from 'enzyme';

describe('Workshop Enrollment School Info', () => {
const fakeRouter = {
createHref() {}
};

const context = {
router: fakeRouter
};

it('shows Total Attendance column for local summer workshop', () => {
let workshopEnrollmentSchoolInfo = shallow(
<WorkshopEnrollmentSchoolInfo
enrollments={[]}
accountRequiredForAttendance={true}
onDelete={() => {}}
workshopCourse="CS Principles"
workshopSubject="5-day Summer"
numSessions={5}
/>,
{context}
);

expect(
workshopEnrollmentSchoolInfo
.find('th')
.filterWhere(col => col.text().includes('Total Attendance'))
).to.have.length(1);
});

it('does not show Total Attendance column for non-local-summer workshop', () => {
let workshopEnrollmentSchoolInfo = shallow(
<WorkshopEnrollmentSchoolInfo
enrollments={[]}
accountRequiredForAttendance={true}
onDelete={() => {}}
workshopCourse="CS Discoveries"
workshopSubject="1-day Academic Year, Units 1 and 2"
numSessions={5}
/>,
{context}
);

expect(
workshopEnrollmentSchoolInfo
.find('th')
.filterWhere(col => col.text().includes('Total Attendance'))
).to.have.length(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I dig it. Thanks for adding additional coverage here!

});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class Api::V1::Pd::WorkshopEnrollmentSerializer < ActiveModel::Serializer
attributes :id, :first_name, :last_name, :email, :district_name, :school, :role, :grades_teaching, :attended_csf_intro_workshop, :csf_course_experience, :csf_courses_planned, :csf_has_physical_curriculum_guide, :user_id, :attended, :pre_workshop_survey
attributes :id, :first_name, :last_name, :email, :district_name, :school, :role,
:grades_teaching, :attended_csf_intro_workshop, :csf_course_experience,
:csf_courses_planned, :csf_has_physical_curriculum_guide, :user_id, :attended,
:pre_workshop_survey, :attendances

def user_id
user = object.resolve_user
Expand All @@ -25,4 +28,8 @@ def pre_workshop_survey
)
end
end

def attendances
object.attendances.count
end
end
1 change: 1 addition & 0 deletions dashboard/test/factories/pd_factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
factory :pd_attendance, class: 'Pd::Attendance' do
association :session, factory: :pd_session
association :teacher
association :enrollment
end

factory :pd_attendance_no_account, class: 'Pd::Attendance' do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'test_helper'

class Api::V1::Pd::WorkshopEnrollmentSerializerTest < ::ActionController::TestCase
test 'serialized workshop enrollment has expected attributes' do
enrollment = create :pd_enrollment
expected_attributes = [
:id, :first_name, :last_name, :email, :district_name, :school, :role,
:grades_teaching, :user_id, :attended, :pre_workshop_survey, :attendances
]

serialized = ::Api::V1::Pd::WorkshopEnrollmentSerializer.new(enrollment).attributes
assert_equal expected_attributes, serialized.keys
end

test 'attendances' do
workshop = create :pd_workshop, num_sessions: 5
enrollment = create :pd_enrollment, workshop: workshop
create :pd_attendance, session: workshop.sessions.first, enrollment: enrollment

serialized = ::Api::V1::Pd::WorkshopEnrollmentSerializer.new(workshop.enrollments.first).attributes
assert_equal enrollment.attendances.count, serialized[:attendances]
end
end