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

Darien classrooms table #74

Merged
merged 7 commits into from
Oct 24, 2017
Merged

Darien classrooms table #74

merged 7 commits into from
Oct 24, 2017

Conversation

srallen
Copy link
Contributor

@srallen srallen commented Oct 19, 2017

This will have to merge after #73 because it is using the program filter for classrooms, so please ignore the changes that pertain to #73 until this is rebased.

This adds a view for the Darien educators page which is basically the classrooms manager which toggles between the table list view or the classroom editor. Darien's table will be slightly different than I2A's:

  • the ability to create and edit assignments which I imagine will open a modal with a form like classroom create/edit does. Right now I just have placeholder buttons for creating and editing an assignment in the markup.
  • The actual data in the table for the assignments. I replaced the export data column for the due date.

I really wanted to try to be clever with determining which classroom table to display by trying out some higher order components, but after puzzling on this for a while I ended up settling with a ternary. The nest of components to get down to the classrooms table is a bit convoluted and I'd really like to try to clean this up at some point as I'm finding it hard to follow myself and I wrote most of it.

Part of the issue is React Router 4's new way of declarative routes, so there are a few components who's primary purpose is to contain the <Switch /> and <Routes /> for whatever nested routes they are.

The other issue is that Darien and I2A share all of the classroom components up until the table, so I couldn't figure out a clever way to have the routes programmatically determine the table since the table itself isn't going to be a route; it's just a child component of the <ClassroomsManagerContainer /> component that is assigned to the /educators/classrooms route. The I2A /educators also doesn't exist on its own; the I2A home page redirects to the educators page since they won't have a student interface.

If you have any good ideas on how to make this better, I'm definitely open to it.

@srallen srallen requested a review from shaunanoordin October 19, 2017 19:40
@srallen
Copy link
Contributor Author

srallen commented Oct 19, 2017

Noting that this is for issue #70

@shaunanoordin
Copy link
Member

I've done a quick review on the user side of things, and here are some observations - although much of what I say may be rendered moot when this PR is rebased.

  • Overall layout & presentation: 👍
    • Also 👍 on the placeholders that will eventually open the Create Assignment modal; that's the path I'd like to go down.
    • Thought: How the Create Assignment modal will be built, though, will need better planning, since Darien's Create Assignment will have a project-specific feature that allows it to communicate with the Map Explorer. (i.e. how can this be generalised?)
  • Quirks:
    • [medium] I can create Classrooms in Darien, but the Classroom won't be listed until I refresh the page.
      • This works properly in I2A, though.
      • Thought: is there some code in I2A that refreshes the Classrooms Manager only after Assignments are auto-created? If so, that may explain why Darien has that quirk.
    • [major] Delete Classroom button doesn't work on Darien. (EDIT: I2A too)

@srallen
Copy link
Contributor Author

srallen commented Oct 20, 2017

This needs a rebase now and delete classroom button sounds like a regression, so I'll work on patching that up. I'll take a look at the request for refreshing the classrooms list too for Darien.

selectClassroom(classroom) {
Actions.classrooms.selectClassroom(classroom);
determineClassroomsTable() {
const ClassroomsTable = this.props.selectedProgram.custom ? DarienClassroomsTable : AstroClassroomsTableContainer;
Copy link
Member

Choose a reason for hiding this comment

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

OK, now I see what you meant when you said "...after puzzling on this for a while I ended up settling with a ternary"

I think this is the way to go, at least for now. Re: "I'd really like to try to clean this up at some point", I'm all for it, but I'm OK to launch something that works first and refactor later. That said...

Thought: I imagine the ideal solution would be to properly plan out a kind of "generic Education Program" system similar to Panoptes' "generic Build-Your-Own Project" system, then plunk the switching code into a central "ProgramsController"/"ProgramsConfigToComponentTranslator" thingy...

switch (this.props.selectedProgram.settings.programType) {
  case "wildlife_camera_trap_classroom": ClassroomsTable = DarienClassroomTable; break;
  case "standard_auto_created_assignments_classroom": ClassroomsTable = AstroClassroomsTableContainer; break;
  ...
}
return ClassroomsTable;

...but that might be a pretty darn deep rabbit hole to go down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good idea, but not worth the time right now even though I dislike what I ended up doing! If another curricula/educational program is added after I2A and the Wildcams, then that's when this should be refactored.

Copy link
Member

Choose a reason for hiding this comment

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

👍

assignmentsStatus={this.props.assignmentsStatus}
classrooms={this.props.classrooms}
match={this.props.match}
maybeDeleteClassroom={this.props.maybeDeleteClassroom}
Copy link
Member

Choose a reason for hiding this comment

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

Unsure: Is this missing deleteClassroom={this.props.deleteClassroom} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybeDeleteClassroom={this.maybeDeleteClassroom} This should open the dialog and this.deleteClassroom is the click handler for confirmation. I missed removing the this.props part here.

render() {
return (
<ClassroomsManager
classrooms={this.props.classrooms}
classroomInstructions={this.props.classroomInstructions}
classroomsStatus={this.props.classroomsStatus}
classroomToDelete={this.state.classroomToDelete}
closeConfirmationDialog={this.closeConfirmationDialog}
deleteClassroom={this.deleteClassroom}
Copy link
Member

Choose a reason for hiding this comment

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

Nyerp this one's bothering me, deleteClassroom is removed here, but I'm assuming it should have been added back/moved to somewhere else. I still can't tell where it's supposed to go, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. I shuffled the classroom delete methods into ClassroomsTableContainer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was my attempt at making sense of component organization and what should be responsible for what. Clearly, it's all still hard to follow 🤷‍♀️

@srallen srallen force-pushed the darien-classrooms-table branch from 2592a33 to 131a743 Compare October 20, 2017 15:43
@srallen
Copy link
Contributor Author

srallen commented Oct 20, 2017

I just rebased, so this should be a bit easier to see the changes specific to this PR.

Copy link
Member

@shaunanoordin shaunanoordin left a comment

Choose a reason for hiding this comment

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

PR Review

  • This PR adds classrooms to the WildCam Darien Program
    screen shot 2017-10-23 at 15 15 12
    The Darien Classrooms (under the Darien > Educator)
  • The Darien Classrooms are significantly different from the baseline I2A Classrooms, notably in that Assignments need to be manually created for each Classroom. (Note: this PR does not include Create Assignment forms yet.)

While the Darien Classroom Manager is in place, the two issues from the previous quick review are still extant.

Issues

  1. When creating a new Classroom in Darien, that Classroom won't appear on the list until the page is refreshed.
  2. User cannot delete Classrooms in either Darien or I2A; the popup doesn't appear after user clicks the X icon.

Status

Changes requested: 2 issues to fix.

However, if either of these fixes are meant to be tackled in a separate PR, please let me know.

@srallen
Copy link
Contributor Author

srallen commented Oct 23, 2017

@shaunanoordin those two issues should now be fixed. I found a bug with classroom creation, too, but I'll save that for another PR.

Copy link
Member

@shaunanoordin shaunanoordin left a comment

Choose a reason for hiding this comment

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

PR Review (Update)

The last update addresses both the issues from the last review - users can now delete Classrooms in both Darien and I2A, and new Classrooms in Darien are reflected properly on the list after creation. Nice work, @srallen ! 👍

Status

LGTM, this PR is good to go! Approving & merging.

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.

2 participants