CSC/ECE 517 Fall 2021 - E2126. Refactor account request controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
No edit summary
Line 1: Line 1:
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]
== About Expertiza==
 
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ 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 ===
 
Connor Smith (cpsmith6)
 
Abir Majumder (aamajumd)
 
Joshua Myers (jamyers3)
 
=== Files Involved ===
 
account_request_controller.rb
 
=== Running Tests ===
 
<pre>
  rspec ./spec/controllers/account_request_controller.rb
</pre>
 
== Relevant Methods ==
 
* action_allowed?
* create_approved_user
* create_requested_user_record
 
=== list_review_submission ===
 
This method returns the correct html tag if a review file exist. Otherwise, it should return an empty string when the file does not exist. In the first test, a sudo file created in AssignmentTeam is allowed to find and return a correct html that start with "<a href". In the second test, since the file
does not exist, it returns an empty string.
 
<pre>
    it 'should return correct html a tag' do
      result = helper.list_review_submissions(@participant.id, @team.id, @response_map.id)
      expect(result).to start_with("<a href")
    end
    it 'should return an empty string when the file does not exist' do
      result = helper.list_review_submissions(@participant.id, @team.id, @response_map.id)
    expect(result).to eq('')
</pre>
 
=== list_hyperlink_submission ===
 
This method returns the hyperlink that the student submits. In this unit test, since the student does not submit a hyperlink, which means the comment does not exist, an empty string is expected to return.
 
<pre>
    it 'should return an empty string when comment does not exist' do
      result = helper.list_hyperlink_submission(@response_map.id, @question.id)
      expect(result).to eq('')
    end
</pre>
 
 
 
=== get_css_style_for_calibration_report ===
 
The method transfers the variable diff, the difference between the student's and the instructor's answer into css style. A dictionary is created as dict = {0 => 'c5',1 => 'c4',2 => 'c3',3 => 'c2'}. In the first unit test, "0" set as the the diff is expected to return c5. In the second test, "-1" is a negative integer, so the absolute value is used to return c4. In the third test, since "6" is not in the key of dict, according to the function, it should return c1.
 
<pre>
    it 'should return correct css class' do
      css_class_0 = helper.get_css_style_for_calibration_report(0)
      css_class_1 = helper.get_css_style_for_calibration_report(-1)
      css_class_6 = helper.get_css_style_for_calibration_report(6)
      expect(css_class_0). to eq('c5')
      expect(css_class_1). to eq('c4')
      expect(css_class_6). to eq('c1')
    end
</pre>
 
== Results ==
 
34 out of 34 tests in the review_mapping_helper_spec.rb test file.
 
Our code changes can be viewed [https://github.com/expertiza/expertiza/pull/2094/files here].
 
URL link of video of review_mapping_helper_spec.rb tests running and passing:-  https://drive.google.com/file/d/1OS4yNI0fDGo4TlkOSxuWNgfMZ4D-XU2f/view
 
=== Relevant Links ===
 
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].
 
Our forked Repository can be found [https://github.com/ctripoll/expertiza/tree/beta here].

Revision as of 22:59, 19 October 2021

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

Connor Smith (cpsmith6)

Abir Majumder (aamajumd)

Joshua Myers (jamyers3)

Files Involved

account_request_controller.rb

Running Tests

  rspec ./spec/controllers/account_request_controller.rb

Relevant Methods

  • action_allowed?
  • create_approved_user
  • create_requested_user_record

list_review_submission

This method returns the correct html tag if a review file exist. Otherwise, it should return an empty string when the file does not exist. In the first test, a sudo file created in AssignmentTeam is allowed to find and return a correct html that start with "<a href". In the second test, since the file does not exist, it returns an empty string.

    it 'should return correct html a tag' do
      result = helper.list_review_submissions(@participant.id, @team.id, @response_map.id)
      expect(result).to start_with("<a href")
    end
    it 'should return an empty string when the file does not exist' do
      result = helper.list_review_submissions(@participant.id, @team.id, @response_map.id)
    expect(result).to eq('')

list_hyperlink_submission

This method returns the hyperlink that the student submits. In this unit test, since the student does not submit a hyperlink, which means the comment does not exist, an empty string is expected to return.

    it 'should return an empty string when comment does not exist' do
      result = helper.list_hyperlink_submission(@response_map.id, @question.id)
      expect(result).to eq('')
    end 


get_css_style_for_calibration_report

The method transfers the variable diff, the difference between the student's and the instructor's answer into css style. A dictionary is created as dict = {0 => 'c5',1 => 'c4',2 => 'c3',3 => 'c2'}. In the first unit test, "0" set as the the diff is expected to return c5. In the second test, "-1" is a negative integer, so the absolute value is used to return c4. In the third test, since "6" is not in the key of dict, according to the function, it should return c1.

    it 'should return correct css class' do
      css_class_0 = helper.get_css_style_for_calibration_report(0)
      css_class_1 = helper.get_css_style_for_calibration_report(-1)
      css_class_6 = helper.get_css_style_for_calibration_report(6)
      expect(css_class_0). to eq('c5')
      expect(css_class_1). to eq('c4')
      expect(css_class_6). to eq('c1')
    end

Results

34 out of 34 tests in the review_mapping_helper_spec.rb test file.

Our code changes can be viewed here.

URL link of video of review_mapping_helper_spec.rb tests running and passing:- https://drive.google.com/file/d/1OS4yNI0fDGo4TlkOSxuWNgfMZ4D-XU2f/view

Relevant Links

Main Expertiza Repository can be found here.

Our forked Repository can be found here.