-
Notifications
You must be signed in to change notification settings - Fork 23
Add new file structure #144
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
base: master
Are you sure you want to change the base?
Conversation
| f.puts string_from_combined_files(subpath) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knmnyn do you have any comments on it?
nguyen-mai-huong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

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.