Conversation
| f.puts string_from_combined_files(subpath) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The above is now done inside app/controllers/assignments_controller.rb
| t.string "full_name" | ||
| t.string "password_digest", default: "$2a$12$BEjX4o6KQ8HsgdP7JV6NEuVygw6U5kaKQrvxk9U3xtotcS92.0BlG" | ||
| t.string "password_digest", default: "$2a$12$I30qed3NhS08Zz7rf.2fy.FEbomtdgXz.4YxtNs7awDjkE3V4EBjy" | ||
| t.boolean "is_admin", default: false, null: false |
There was a problem hiding this comment.
You can ignore this.
| t.boolean "mapbox", default: false | ||
| t.string "fileStructure" | ||
| t.index ["course_id"], name: "index_assignments_on_course_id" | ||
| end |
There was a problem hiding this comment.
This is a new parameter to store whether the user wants to process the uploaded zip file by files or by directory.
| def change | ||
| add_column :assignments, :fileStructure, :string | ||
| end | ||
| end |
There was a problem hiding this comment.
This is a new parameter to store whether the user wants to process the uploaded zip file by files or by directory.
| isMapEnabled = (params[:assignment]["mapbox"] == "Yes")? true : false; | ||
|
|
||
| # to check whether user clicked on optional options | ||
| isOptionalOptionsEnabled = (params[:assignment]["mapbox"] == "Yes")? true : false; |
There was a problem hiding this comment.
please follow Ruby/Rails naming convention.
| @assignment.errors.add :mapfile, "containing mapped student names need to be uploaded if the 'Upload map file' box is ticked" | ||
| elsif !(is_valid_map_or_no_map?(isMapEnabled, params[:assignment]["mapfile"])) | ||
| @assignment.errors.add :mapfile, "containing mapped student names must be a valid csv file" | ||
|
|
There was a problem hiding this comment.
In MVC/Rails, people usually follow "Fat models, skinny controllers" convention for code's readability and maintenance. Fat model is not always maintainable. So, people introduce service layer to do validation or to interact with models.
In this case, it's suggested to have assignment validation service for code segments: is_valid_zip?, is_valid_map_or_no_map? ... and to have a file helper service for code segment: extract_uploaded_files ...
It will help to make the code low coupling, easy to read and maintain.

This PR aims to add a new functionality.
If the user wants the application to recursively search for all the files and compare them with each other (instead of current configuration where files need to be student directories), there is new option called, "By Files" under "File Structure" that allows them to do so. If the uploaded zip submission contains student folders instead, the user can simply select the "By Directory" option.