User talk:Zli36
E1675.Timestamp for student file & hyperlink submissions
This page provides a description of the Expertiza based OSS project.
About Expertiza
Expertiza is an open source project based on Ruby on Rails framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.
Problem Statement
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.
Task Goals
What needs to be done:
- Record the timestamps for file/hyperlink submissions.
- Add code to keep all those time stamps tracked and updated.
- Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.
- Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).
- After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.
- Create tests to make sure the test coverage increase.
Program Design
We created a set of new controller, model and views to finish the function for timestamps. We added a model named SubmissionRecord that contains the following attributes.
- Hyperlink - hyperlink that could be uploaded - String.
- Upload File - file that could be uploaded - File.
- Team id - id that links the model to the team that created it. - Integer.
- Created at - timestamp for time of creation.
- Operation - Description of what occured, create, update and delete.
- User - User who change the status of current table Get this from current user id.
- Content - String, the file name or the hyperlink.
Implementation
Action_allowed
- In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.
def action_allowed? if params[:action] == 'edit' || params[:action] == 'update' assignment = Assignment.find(params[:id]) return true if ['Super-Administrator', 'Administrator'].include? current_role_name return true if assignment.instructor_id == current_user.id return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) && (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first) return true if assignment.course_id && Course.find(assignment.course_id).instructor_id == current_user.id return false else ['Super-Administrator', 'Administrator', 'Instructor', 'Teaching Assistant'].include? current_role_name end end
Submit Hyperlink & File
- After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.
def submit_hyperlink @participant = AssignmentParticipant.find(params[:id]) return unless current_user_id?(@participant.user_id) team = @participant.team team_hyperlinks = team.hyperlinks if team_hyperlinks.include?(params['submission']) flash[:error] = "You or your teammate(s) have already submitted the same hyperlink." else begin team.submit_hyperlink(params['submission']) @participant.update_resubmit_times #create a submission record @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: "Submit Hyperlink") @submission_record.save rescue flash[:error] = "The URL or URI is not valid. Reason: #{$ERROR_INFO}" end undo_link("The link has been successfully submitted.") end redirect_to action: 'edit', id: @participant.id end
#create a submission record assignment = Assignment.find(participant.parent_id) team = participant.team @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: "Submit File") @submission_record.save
Remove Hyperlink or File
- When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.
#create a submission record @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: "Remove Hyperlink") @submission_record.save
def delete_selected_files #create a submission record assignment = Assignment.find(participant.parent_id) team = participant.team @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: "Remove File") @submission_record.save filename = params[:directories][params[:chk_files]] + "/" + params[:filenames][params[:chk_files]] FileUtils.rm_r(filename) end
View Submission Record
- In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.
<% if record.operation == "Submit Hyperlink" %> <td><a href="<%= record.content %>" target="_blank"><%= record.content %></a><br/></td> <% else %> <td><%= record.content %></td> <% end %> <td><%= record.created_at %></td>
Parameter Passed
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.
<%= link_to "Show Submission Records", submission_records_path(team_id: team.id) %>(View:list_submission) @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)
Automated Testing using RSPEC
Testing from UI
References
- Expertiza on GitHub
- GitHub Project Repository Fork
- The live Expertiza website
- Expertiza project documentation wiki
- Rspec Documentation
- Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin