Skip to content

Conversation

@Riyas97
Copy link
Contributor

@Riyas97 Riyas97 commented Apr 27, 2022

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.

Screenshot from 2022-04-27 16-32-03

f.puts string_from_combined_files(subpath)
}
}

Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@nguyen-mai-huong nguyen-mai-huong requested a review from knmnyn May 2, 2022 09:23
isMapEnabled = (params[:assignment]["mapbox"] == "Yes")? true : false;

# to check whether user clicked on optional options
isOptionalOptionsEnabled = (params[:assignment]["mapbox"] == "Yes")? true : false;
Copy link
Contributor

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"

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

@nguyen-mai-huong nguyen-mai-huong left a comment

Choose a reason for hiding this comment

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

  • How does this change affect integrating with LumiNUS?

  • Please correct me if my testing was not correct. I chose "By Files", and it seemed to me that skeleton file was treated as a submission.

file-structure-testing

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.

4 participants