Archive for December, 2013
The problem: grade spreadsheet columns were being sorted by name instead of maintaining the order they were added in.
Knowing nothing about Ruby, this seemed like a simple task. Preserving rubric orders was already being done. It should just be a matter of saying ‘update the database in the same order you get it’, right?
Wrong. The controller receives the parameters to update the grade entry form as a hash, :params, which is unordered. So to update the database in the right order, we are going to have to decide in the view what the order should be so that it can be sent with the params.
But before working on that, maybe we can see how rubrics get their order. It turns out that rubrics get added to already created assignments (first difference) and that they are created one at a time (second difference). Their ordering is therefore much simpler because the parent is already in the database, and then it is just a matter of saving each one individually, making sure to fill in the required attributes (name and weight) before saving. This means you can just save each new rubric with a position that is either 1 more than the previous max position, or 0 if it is the first rubric for the assignment. Unfortunately, using this method for the grade entry forms would make their creation a lot more tedious than is necessary, so this idea was scrapped.
The final solution was as follows:
- Create a migration that adds a new attribute ‘position’ to GradeEntryItems. Update GradeEntryForms to order their GradeEntryItems by position.
- The ‘add_grade_entry_item_link’ method in grade_entry_form_helper.rb is already setting the key of the new columns to be added as ‘new_####’ where #### is the timestamp. This is sent in the POST params to the grade_entry_form_controller.rb for the create and update methods.
- Create a new method ‘update_grade_entry_form_params’ in grade_entry_form_helper.rb that sorts by name all of the columns that don’t already have a position. This will put all the new columns in order because they are named by timestamp. Then based on the current highest position, it adds a position to all new columns.
- In grade_entry_form_controller.rb, create and update either successfully update the model with the new params or it fail because there was an error during validation. If an error occurs, the view reloads with the old columns in the proper order (because GradeEntryForm returns them sorted by position) but the new columns in random order. Therefore, create a new method ‘sort_items_by_position’ in grade_entry_form_helper.rb so that the view can display the forms for the items in the proper order.
- When displaying the current columns in the view, I also added that it updated each item’s position so that if any columns were deleted previously, the current ones would fill in the gaps left by them. This doesn’t ensure continuous positions completely, but the only gaps in position are now only from one round of deletions and not every round of deletions.
It was more complicated than it first seemed, but the final solution seems to work pretty well!
- Worked on implementing add user method in git_repository.rb. This deals with the authentication problems we were expecting to have so I haven’t been able to complete it yet.
- Documentation for the gitolite gem is hard to find, and what I did manage to find wasn’t very helpful.
- Figure out how to use gitolite
- Once the add user method is done using gitolite, the remove user, get permissions and set permissions methods should be fairly easy.
- Got the initialize function in GitRevision Class behaving exactly the same as the initialize function in the SubversionRevision class does.
- Been working on the file path issue, committing and setting objects for a given file path is a trivial. Retrieving a file or object from a given path has been confusing, Rugged documentation is not clear.
- Started playing around with Rugged tree objects and index object to see if I can get the files for a given path, I think index objects will work.
- Discovered a potential issue with Markus git client, what happens when Markus encounters a merge conflict whena student adds files through the web client? Force push files to repo?
- Rugged documentation is pretty useless, and there are few working examples online of implementation.
- Retrieving files given a path is undocumented.
- Figure out this file path business, specifically retrieving files given a file path.
- Even though I plan on continuing to contribute to Markus, I’m going to clean up and document my code thoroughly in case future students need to work on/with it.
- Fully implement GitRevision class.
- Worked with Jeremy and confirmed the commit of issue-1211
- Fixed issue-1001
- not being familiar with the test framework stuff cost me a bit of time with issue-1211
- review the issue I resolved and make sure the solutions are complete and clear
- Ensure the blog post about the Summaries page which is my major contribution this term conveys everything
- Fixed Issue-100 and sent pull request
- Lots of pieces in the grade entry forms are broken. Especially updating grades, pagination, and navigation. This made it hard to test.
- I also spent many fruitless hours looking into these bugs briefly before deciding to just keep going and finish the issue.
- Either work on those bugs that I found this week or do something else that is more important
- Write a blog post about either this week’s work or the stuff on grade entry item ordering
- Create and give a presentation on the project for my school’s UCOSP requirements