User talk:Zli36

From Expertiza_Wiki
Revision as of 18:25, 28 October 2016 by Zli36 (talk | contribs) (Created page with "==E1675.Timestamp for student file & hyperlink submissions == This page provides a description of the Expertiza based OSS project. __TOC__ ===About Expertiza=== [http://ex...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the 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 controll 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


Automated Testing using RSPEC

The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed "rpec spec" command as shown below.

user-expertiza $rspec spec
.
.
.
Finished in 5.39 seconds (files took 25.33 seconds to load)
66 examples, 0 failures

Randomized with seed 19254
.
.

Testing from UI

Following are a few testcases with respectto our code changes that can be tried from UI: 1. To go to versions index page, type in the following url after logging in:

  http://152.46.16.81:3000/versions

2. After logging in as student/instructor or admin : Try accessing the new, create, edit, update actions. These actions are not allowed to any of the users.

  http://152.46.16.81:3000/versions/new
  This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.

3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:

  http://152.46.16.81:3000/versions/search

4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.

References

  1. Expertiza on GitHub
  2. GitHub Project Repository Fork
  3. The live Expertiza website
  4. Demo link
  5. Expertiza project documentation wiki
  6. Rspec Documentation
  7. Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin