CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb

From Expertiza_Wiki
Jump to navigation Jump to search

About Expertiza

Expertiza is an open source project based on Ruby on Rails framework that supports submission across different document types, including theURLs and wiki pages. It allows the instructor not only to create and customize new or existing assignments but also 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.


Description about project

This page is a description of Expertiza OSS project E2132 which is adding unit tests for review_mapping_helper.rb. The ReviewMappingHelper works as a class that is responsible for mapping reviews and feedback to assignment teams and reviewers. Also, This helper class reports of the status of project reviews.

Team

Chen-Ni Liu (cliu43) Shao-Yo Chao (schao2) Fu-Jen Yen (fyen)

Files Involved

review_mapping_helper.rb

review_mapping_helper_spec.rb

Running Tests

  rspec spec/helpers/review_mapping_helper_spec.rb

Relevant Methods

  • response_for_each_round?
  • submitted_within_round?
  • submitted_hyperlink
  • get_team_reviewed_link_name
  • sort_reviewer_by_review_volume_desc
  • list_review_submission
  • list_hyperlink_submission
  • get_certain_review_and_feedback_response_map
  • get_css_style_for_calibration_report

response_for_each_round?

This method checks the response record if the assignment is submitted on time,



submitted_within_round?

This method checks the record if the assignment is submitted on time, that is, before due date. Setting up two submissions on two different due date, so in the unit test there would be four situations to discuss. If all the works are submitted on time, the response is expected to be true. Otherwise, the response depends on the last submission's status.


submitted_hyperlink

This method returns the hyperlink that is submitted on time. For one assignment, it returns the hyperlink that is submitted before due date. For multiple assignments, no matter how many assignments are submitted on time, it shows the hyperlink of the last submission that is submitted on time.

    it 'should return https://wiki.archlinux.org/123 if works was submitted on time' do
      create(:deadline_right, name: 'No')
      create(:deadline_right, name: 'Late')
      create(:deadline_right, name: 'OK')
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 12.day)
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/123', created_at: DateTime.now.in_time_zone - 7.day)
      create(:response, response_map: @response_map)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 10.day)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone - 5.day)

      assignment_created = @assignment.created_at
      assignment_due_dates = DueDate.where(parent_id: @response_map.reviewed_object_id)

      hyper_link = submitted_hyperlink(@round, @response_map, assignment_created, assignment_due_dates)
      expect(hyper_link).to eq('https://wiki.archlinux.org/123')
    end

    it 'should return https://wiki.archlinux.org/123 if only a work was submitted on time' do
      create(:deadline_right, name: 'No')
      create(:deadline_right, name: 'Late')
      create(:deadline_right, name: 'OK')
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 8.day)
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/123', created_at: DateTime.now.in_time_zone - 6.day)
      create(:response, response_map: @response_map)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 10.day)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone - 5.day)

      assignment_created = @assignment.created_at
      assignment_due_dates = DueDate.where(parent_id: @response_map.reviewed_object_id)

      hyper_link = submitted_hyperlink(@round, @response_map, assignment_created, assignment_due_dates)
      expect(hyper_link).to eq('https://wiki.archlinux.org/123')
    end

    it 'should return https://wiki.archlinux.org/ if only a work was submitted on time' do
      create(:deadline_right, name: 'No')
      create(:deadline_right, name: 'Late')
      create(:deadline_right, name: 'OK')
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 12.day)
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/123', created_at: DateTime.now.in_time_zone - 4.day)
      create(:response, response_map: @response_map)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 10.day)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone - 5.day)

      assignment_created = @assignment.created_at
      assignment_due_dates = DueDate.where(parent_id: @response_map.reviewed_object_id)

      hyper_link = submitted_hyperlink(@round, @response_map, assignment_created, assignment_due_dates)
      expect(hyper_link).to eq('https://wiki.archlinux.org/')
    end


    it 'should return https://wiki.archlinux.org/ if only a work was Submit Hyperlink' do
      create(:deadline_right, name: 'No')
      create(:deadline_right, name: 'Late')
      create(:deadline_right, name: 'OK')
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Submit Hyperlink', content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 12.day)
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee.id, operation: 'Not Submit Hyperlink', content: 'https://wiki.archlinux.org/123', created_at: DateTime.now.in_time_zone - 6.day)
      create(:response, response_map: @response_map)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 10.day)
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone - 5.day)

      assignment_created = @assignment.created_at
      assignment_due_dates = DueDate.where(parent_id: @response_map.reviewed_object_id)

      hyper_link = submitted_hyperlink(@round, @response_map, assignment_created, assignment_due_dates)
      expect(hyper_link).to eq('https://wiki.archlinux.org/')
    end

get_team_reviewed_link_name

This method checks if the max_team_size is 1 or not and gives appropriate team reviewed link name. Given the input max_team_size, response, reviewee_id, ip_address, if the team size is 1, it is expected to get the return of the student's name. If not, it is expected to return "Team 1".

    it 'should return (Team_1) if max_team_size = 3' do
      max_team_size = 3
      @response = create(:response, response_map: @response_map)
      ip_address = '0.0.0.0'
      reviewed_team_name = get_team_reviewed_link_name(max_team_size, @response, @reviewee.id, ip_address)
      expect(reviewed_team_name).to eq('(Team_1)')
    end

    it 'should return (Team_1) if max_team_size = 2' do
      max_team_size = 2
      @response = create(:response, response_map: @response_map)
      ip_address = '0.0.0.0'
      reviewed_team_name = get_team_reviewed_link_name(max_team_size, @response, @reviewee.id, ip_address)
      expect(reviewed_team_name).to eq('(Team_1)')
    end

    it 'should return (Adam) if max_team_size = 1' do
      max_team_size = 1
      student = create(:student, fullname: 'Adam')
      create(:team_user, user: student, team: @reviewee)

      @response = create(:response, response_map: @response_map)
      ip_address = '0.0.0.0'
      reviewed_team_name = get_team_reviewed_link_name(max_team_size, @response, @reviewee.id, ip_address)
      expect(reviewed_team_name).to eq('(Adam)')
    end

    it 'should return (Team_1) if max_team_size = 0' do
      max_team_size = 0
      @response = create(:response, response_map: @response_map)
      ip_address = '0.0.0.0'
      reviewed_team_name = get_team_reviewed_link_name(max_team_size, @response, @reviewee.id, ip_address)
      expect(reviewed_team_name).to eq('(Team_1)')
    end

sort_reviewer_by_review_volume_desc

This method sorts the reviewer depending on the length of the content of the review. It is sorted in descent order, and follows the order of create if the length of the reviews are the same.

it 'the order should be 2-3-1 if the order of comment volume is 2 > 3 > 1' do
      @response_1 = create(:response, response_map: @response_map_1, additional_comment: 'good')
      @response_2 = create(:response, response_map: @response_map_2, additional_comment: 'Good job with clear code')
      @response_3 = create(:response, response_map: @response_map_3, additional_comment: 'goodclear code')

      @reviewers = Array[@reviewer_1, @reviewer_2, @reviewer_3]
      @reviewers_for_test = Array[@reviewer_2, @reviewer_3, @reviewer_1]

      sort_reviewer_by_review_volume_desc
      expect(@reviewers).to eq(@reviewers_for_test)
    end

    it 'the order should be 2-1-3 if the comment volume is 2 > 1 = 3' do
      @response_1 = create(:response, response_map: @response_map_1, additional_comment: 'good job')
      @response_2 = create(:response, response_map: @response_map_2, additional_comment: 'Good job with clear code')
      @response_3 = create(:response, response_map: @response_map_3, additional_comment: 'clear code')

      @reviewers = Array[@reviewer_1, @reviewer_2, @reviewer_3]
      @reviewers_for_test = Array[@reviewer_2, @reviewer_1, @reviewer_3]

      sort_reviewer_by_review_volume_desc
      expect(@reviewers).to eq(@reviewers_for_test)
    end

    it 'the order should be 1-2-3 if the comment volume is 1 = 2 = 3' do
      @response_1 = create(:response, response_map: @response_map_1, additional_comment: 'good job')
      @response_2 = create(:response, response_map: @response_map_2, additional_comment: 'clear code')
      @response_3 = create(:response, response_map: @response_map_3, additional_comment: 'nice bro')

      @reviewers = Array[@reviewer_1, @reviewer_2, @reviewer_3]
      @reviewers_for_test = Array[@reviewer_1, @reviewer_2, @reviewer_3]

      sort_reviewer_by_review_volume_desc
      expect(@reviewers).to eq(@reviewers_for_test)
    end