Coursemology/coursemology.org — pull request #237 by weiqingtoh (2014-10-02 16:40:43+00:00)
Title: Implemented multiple dependencies - Missions and Trainings can now be dependent on each other

## Mini-message
I apologise if this is such a large PR - only after reading recent PRs I realised that doing it in small batches would be better. I will do that for the future PRs.

## Summary of Changes
**Before:** Missions could only be dependent on other missions
**After:** This PR allows any assessment (mission or training) to be dependent on another assessment. Each assessment can have multiple dependencies.

### List of Stuff Changed (at Code Level)
- For assessments, dependent_on and required_for are now "has_and_belongs_to_many" relation, under the join table assessment_dependency
- Updated all old method calls to handle the new dependent_on and required for relation
- Database migration to migrate existing dependent assessments into join table, and drop dependent_id off assessments table.
- Dynamic forms for users to add and remove dependencies on the fly - used Cocoon for this. This is only implemented when editing one assessment at a time. *At the trainings and missions overview page, a multiple selection is still used.*
- Refactored can_start? method in assessment model - created method get_dependent_assessment to return uncompleted dependent assessments in an array else nil.
- Updated the assessments' access denied page to reflect dependent assessments

*Sample Pic of Form:*
![screen shot 2014-10-03 at 12 37 13 am](https://cloud.githubusercontent.com/assets/4353853/4494506/9183310a-4a52-11e4-8435-67cb93f94e0c.png)