CSC/ECE 517 Fall 2016/E1675. Timestamp for student file & hyperlink submissions: Difference between revisions
No edit summary |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
===About Expertiza=== | ===About Expertiza=== | ||
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza | [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza is a 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=== | ===Problem Statement=== | ||
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for | In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for student's submission. In this project we were required to keep track of timestamp records for student's submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks, those activities were also recorded. | ||
Line 28: | Line 29: | ||
===Program Design === | ===Program Design === | ||
We created a set of new controller, model and views to | We created a set of new controller, model and views to implement the functionality of timestamps. | ||
We added a model named SubmissionRecord that contains the following attributes. | We added a model named SubmissionRecord that contains the following attributes. | ||
Line 35: | Line 36: | ||
* Team id - id that links the model to the team that created it. - Integer. | * Team id - id that links the model to the team that created it. - Integer. | ||
* Created at - timestamp for time of creation. | * Created at - timestamp for time of creation. | ||
* Operation - Description of | * Operation - Description of operation performed. - create, update and delete. | ||
* User - User who change the status of current table Get this from current user id. | * User - User who change the status of current table Get this from current user id. | ||
* Content - String, the file name or the hyperlink. | * Content - String, the file name or the hyperlink. | ||
Line 45: | Line 45: | ||
=====Action_allowed===== | =====Action_allowed===== | ||
* In present code, the application has | * In present code, the application has the control to decide which kind of user could have access to the specific page. In order to let the instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Below is reference code : | ||
<pre> | <pre> | ||
def action_allowed? | def action_allowed? | ||
Line 66: | Line 66: | ||
=====Submit Hyperlink & File ===== | =====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 | * After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we implemented this feature using the previous functionality already existent in the submitted_content controller/model. This page had information about the hyperlinks and files which were previously submitted by the student. We add functionality to fill in submission_record table once a hyperlink or file is submitted. Below is a code snippet for reference : | ||
<pre> | <pre> | ||
Line 102: | Line 102: | ||
@submission_record.save | @submission_record.save | ||
</pre> | </pre> | ||
===== Remove Hyperlink or File===== | ===== Remove Hyperlink or File===== | ||
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. | * When students want to delete their hyperlinks or files which they had submitted before, the data in submission_record table should not disappear. We wanted to save all the operations made by the team. As a result, we added specific functionality in the existing delete function to reserve the data in submission_record table. | ||
<pre> | <pre> | ||
#create a submission record | #create a submission record | ||
Line 126: | Line 124: | ||
=====View Submission Record ===== | =====View Submission Record ===== | ||
* In order to make the | * In order to make the student submitted hyperlinks clickable, we check if the operation performed is 'Submit Hyperlink' in database. | ||
<pre> | <pre> | ||
<% if record.operation == "Submit Hyperlink" %> | <% if record.operation == "Submit Hyperlink" %> | ||
Line 137: | Line 135: | ||
</pre> | </pre> | ||
===Parameter Passing=== | ====Parameter Passing==== | ||
We utilize the params hash from the previous view called List_submissions. We then use a | We utilize the params hash from the previous view called List_submissions. We then use a WHERE SQL query that matches the team_id from the submissions record table. | ||
<pre> | <pre> | ||
Line 145: | Line 143: | ||
</pre> | </pre> | ||
===Automated Testing using RSPEC=== | ===Automated Testing using RSPEC=== | ||
Line 177: | Line 176: | ||
end | end | ||
</pre> | </pre> | ||
Controllers were tested to make sure the rendering, redirection and views are proper. | |||
===Testing from UI=== | ===Testing from UI=== | ||
Steps for testing the project using the User Interface. | |||
*As an instructor, go to manage assignments. | |||
*Click on submissions view of an assignment. | |||
*You will see all the items submissions. | |||
*Click on "Show Submission Records". | |||
*You will see a history of the submission along with the timestamps for each submission. | |||
*You can also see when the submission was added, updated and removed. | |||
*Visit below video link to see an interactive demo. | |||
*[https://youtu.be/cGXu1YPG0Ec Demo link] | |||
===References=== | ===References=== | ||
Line 189: | Line 199: | ||
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki] | #[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki] | ||
#[https://relishapp.com/rspec Rspec Documentation] | #[https://relishapp.com/rspec Rspec Documentation] | ||
#Clean Code: A | #Clean Code: A Handbook of Agile Software Craftsmanship. Author: Robert C Martin |
Latest revision as of 07:51, 2 December 2017
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 is a 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 student's submission. In this project we were required to keep track of timestamp records for student's submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks, those activities were also 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 implement the functionality of 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 operation performed. - 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 the control to decide which kind of user could have access to the specific page. In order to let the instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Below is reference code :
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 implemented this feature using the previous functionality already existent in the submitted_content controller/model. This page had information about the hyperlinks and files which were previously submitted by the student. We add functionality to fill in submission_record table once a hyperlink or file is submitted. Below is a code snippet for reference :
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 which they had submitted before, the data in submission_record table should not disappear. We wanted to save all the operations made by the team. As a result, we added specific functionality in the existing 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 student submitted hyperlinks clickable, we check if the operation performed 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 Passing
We utilize the params hash from the previous view called List_submissions. We then use a WHERE SQL 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
The testing for this project has been done using several advanced ruby features. Below are a few of the features which were used :
Using these techniques, the project was thoroughly tested.
Models were tested for their validation. We had to verify each of the parameters which we received in our model. This was done by developing a Ruby Factory which had sample data. This sample data was fed into the models. Using RSpec, we then checked for validity for each of the parameters received in the models. This validity check is important since this information is prerequisite for having a perfectly working controller and view.
Below is a code snippet which describes the testing methodology.
require 'rails_helper' describe SubmissionRecord do it 'is invalid without a team id' do expect(build(:submission_record, team_id: nil)).to_not be_valid end it 'is invalid without an operation' do expect(build(:submission_record, operation: nil)).to_not be_valid end it 'is invalid without a user' do expect(build(:submission_record, user: nil)).to_not be_valid end it 'is invalid without an assignment id' do expect(build(:submission_record, assignment_id: nil)).to_not be_valid end it 'is invalid without an operation' do expect(build(:submission_record, operation: nil)).to_not be_valid end end
Controllers were tested to make sure the rendering, redirection and views are proper.
Testing from UI
Steps for testing the project using the User Interface.
- As an instructor, go to manage assignments.
- Click on submissions view of an assignment.
- You will see all the items submissions.
- Click on "Show Submission Records".
- You will see a history of the submission along with the timestamps for each submission.
- You can also see when the submission was added, updated and removed.
- Visit below video link to see an interactive demo.
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