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

Default assignments on classroom join #73

Merged
merged 5 commits into from
Nov 13, 2017

Conversation

zwolf
Copy link
Member

@zwolf zwolf commented Nov 1, 2017

For "custom" (Wildcam-style, custom assignment) programs, teachers create assignments before or after a classroom is joined and then assign them to students. However, for non-custom (i2a) programs, the order of operations will look more like this:

  1. Teacher creates classroom
  2. Default assignments are automatically generated by the i2a frontend.
  3. Stutent attempts to join classroom and is automatically assigned each of the classroom's assignments.

This PR adds that check, based on the program's custom attribute, and assigns them if it is false. Programs are now required by all classroom requests and are an included association in the classroom factory.

For "custom" (Wildcam-style, custom assignment) programs, teachers create assignments before or after a classroom is joined and then assign them to students. However, for non-custom (i2a) programs, the order of operations will look more like this:

1) Teacher creates classroom
2) Default assignments are automatically generated by the i2a frontend.
3) Stutent attempts to join classroom and is automatically assigned each of the classroom's assignments.

This PR adds that check, based on the program's `custom` attribute, and assigns them if it is false.
@zwolf zwolf requested a review from marten November 1, 2017 21:05
it "adds the user to all assignments" do
outcome = described_class.run!(current_user: current_user, client: client,
id: classroom.id, join_token: classroom.join_token)
expect(standard_assignment.student_users.map {|su| su.user_id }).to include(current_user.id)

Choose a reason for hiding this comment

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

Pass &:user_id as an argument to map instead of a block.

let!(:custom_assignment) { create(:assignment, classroom: custom_classroom) }

it "doesn't affect assignments" do
expect{

Choose a reason for hiding this comment

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

Parenthesize the param change{ custom_assignment.student_users } to make sure that the block will be associated with the change method call.

Copy link
Member Author

Choose a reason for hiding this comment

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

seems like a known rubocop bug (rubocop/rubocop#4198), updating might fix.

response = join_panoptes_group(classroom)

if response
classroom.students << current_user
add_user_to_assignments if !classroom.program.custom?

Choose a reason for hiding this comment

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

Favor unless over if for negative conditions.

@zwolf
Copy link
Member Author

zwolf commented Nov 6, 2017

I incorporated a couple older, unmerged PRs related to classroom requests requiring programs. Should be ready for review now, though, @marten.

@srallen
Copy link
Contributor

srallen commented Nov 7, 2017

Just so you all know the timeline for this, we're tentatively planning on deploying the education api to production the first week of December while @zwolf and I are in Oxford. I'm out the third week of Nov (in about a week and a half) and I'm depending on this feature to finish the remaining I2A front end features. Getting this reviewed sooner than later would be very helpful. Thanks.

@zwolf
Copy link
Member Author

zwolf commented Nov 9, 2017

@marten mind taking a quick look at this?

@zwolf zwolf merged commit f2135c9 into zooniverse:master Nov 13, 2017
@zwolf zwolf deleted the autojoin-assignments branch November 13, 2017 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants