<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lshan3</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lshan3"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Lshan3"/>
	<updated>2026-08-20T05:22:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142648</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142648"/>
		<updated>2021-12-01T01:36:55Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
This method will send a mail via Mailer when the review score is abnormal. The method should pass the data with the correct format to the Mailer and deliver the mail.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
This method will check if the review is done by a staff, which include TAs and instructors.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
This method will return the data of the repsonse within HTML format, and might invoke several private methods that needs to be test.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
This method is a private method in response model, which will only be called by the display_as_html method. In this method, if the response contains additional commends, it will replace '/n' to '&amp;lt;/br&amp;gt;'.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142647</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142647"/>
		<updated>2021-12-01T01:35:56Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* construct_review_response(code, self_id, show_tags = nil, current_user = nil) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
This method will send a mail via Mailer when the review score is abnormal. The method should pass the data with the correct format to the Mailer and deliver the mail.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
This method will check if the review is done by a staff, which include TAs and instructors.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
This method is a private method in response model, which will only be called by the display_as_html method. In this method, if the response contains additional commends, it will replace '/n' to '&amp;lt;/br&amp;gt;'.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142646</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142646"/>
		<updated>2021-12-01T01:35:41Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* construct_review_response(code, self_id, show_tags = nil, current_user = nil) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
This method will send a mail via Mailer when the review score is abnormal. The method should pass the data with the correct format to the Mailer and deliver the mail.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
This method will check if the review is done by a staff, which include TAs and instructors.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
This method is a private method in response model, which will only be called by the display_as_html method. In this method, if the response contains additional commends, it will replace /n to &amp;lt;/br&amp;gt;.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142645</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142645"/>
		<updated>2021-12-01T01:32:57Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* done_by_staff_participant? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
This method will send a mail via Mailer when the review score is abnormal. The method should pass the data with the correct format to the Mailer and deliver the mail.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
This method will check if the review is done by a staff, which include TAs and instructors.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142644</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142644"/>
		<updated>2021-12-01T01:32:17Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* notify_instructor_on_difference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
This method will send a mail via Mailer when the review score is abnormal. The method should pass the data with the correct format to the Mailer and deliver the mail.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142643</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142643"/>
		<updated>2021-12-01T01:30:32Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* self.calibration_results_info(calibration_id, response_id, assignment_id) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142642</id>
		<title>CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring &amp; Grades</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades&amp;diff=142642"/>
		<updated>2021-12-01T01:29:05Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* delete */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
Our objectives for this project are the following:&lt;br /&gt;
*Develop the files below further to cover missing methods and lines.&lt;br /&gt;
*Write extra tests to cover any edge cases that may need to be considered.&lt;br /&gt;
*Increase the coverage of the spec.&lt;br /&gt;
&lt;br /&gt;
=== Files Involved and original coverage===&lt;br /&gt;
*Grades_controller_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fcontrollers%2Fgrades_controller.rb here]]-86%covered&lt;br /&gt;
*Grades_helper_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fhelpers%2Fgrades_helper.rb here]]-58%covered&lt;br /&gt;
*Response_spec [[https://coveralls.io/builds/43656335/source?filename=app%2Fmodels%2Fresponse.rb here]]-86.4%covered&lt;br /&gt;
&lt;br /&gt;
== Run the file ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  rspec ./spec/helpers/Grades_helper_spec.rb&lt;br /&gt;
  rspec ./spec/controller/Grades_controller_spec.rb&lt;br /&gt;
  rsepc ./spec/model/Response_spec.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage. &lt;br /&gt;
=== Relevant Methods ===&lt;br /&gt;
Grades_controller_spec &lt;br /&gt;
*action_allowed&lt;br /&gt;
*update&lt;br /&gt;
*save_grade_and_comment_for_submission&lt;br /&gt;
*self_review_finished&lt;br /&gt;
&lt;br /&gt;
Grades_helper_spec &lt;br /&gt;
*accordion_title(last_topic, new_topic)&lt;br /&gt;
*has_team_and_metareview&lt;br /&gt;
*view_heatgrid(participant_id, type)&lt;br /&gt;
*penalty&lt;br /&gt;
Response_spec&lt;br /&gt;
*maximum_score&lt;br /&gt;
*email&lt;br /&gt;
*populate_new_response&lt;br /&gt;
*questionnaire_by_answer&lt;br /&gt;
*delete&lt;br /&gt;
*self.calibration_results_info&lt;br /&gt;
*notify_instructor_on_difference&lt;br /&gt;
*done_by_staff_participant?&lt;br /&gt;
*dispaly_as_html&lt;br /&gt;
*construct_review_response&lt;br /&gt;
== GradesController_spec ==&lt;br /&gt;
=== action_allowed ===&lt;br /&gt;
This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_1.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:action.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ac.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== update ===&lt;br /&gt;
In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like &amp;quot;A score of ... has been saved for ...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:update_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_2.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== save_grade_and_comment_for_submission ===&lt;br /&gt;
This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be &amp;quot;$ERROR_INFO&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:save_grade.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:update_1.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== self_review_finished ===&lt;br /&gt;
This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_4.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:self_review.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Problem:&lt;br /&gt;
The self_review_finished method is a private method, difficult to test every scenarios through the public interface.&lt;br /&gt;
&lt;br /&gt;
== GradesHelper_spec ==&lt;br /&gt;
=== accordion_title(last_topic, new_topic) ===&lt;br /&gt;
This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:&lt;br /&gt;
 1. When last_topic is empty, the function should return view which contains the new_topic&lt;br /&gt;
 2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic&lt;br /&gt;
 3. Other situation, the function should return nothing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_8.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:accordion.png|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:accor2.jpg|border|500px]]&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:accord.jpeg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== has_team_and_metareview? ===&lt;br /&gt;
In this function, we plan to complete cases to cover all the function. The cases include:&lt;br /&gt;
1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2.&lt;br /&gt;
2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1.&lt;br /&gt;
3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_9.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:has_team.jpg|border|1000px]]&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:meta2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:metaview_1.jpg|border|800px]]&lt;br /&gt;
*The comment part is the original code that shows bug:&lt;br /&gt;
[[File:metaview_2.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== view_heatgrid(participant_id, type) ===&lt;br /&gt;
This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view&lt;br /&gt;
So, we plan to check if the return value only contends the certain type of questionnaires.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:viewgrid.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:heat2.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:heatgrid.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
=== penalty ===&lt;br /&gt;
This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:penal_initial.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:penal_pass.jpg|border|500px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:penalty.jpg|border|800px]]&lt;br /&gt;
&lt;br /&gt;
== Response_spec ==&lt;br /&gt;
=== maximum_score ===&lt;br /&gt;
This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_5.jpg]]&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:m_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:max_score.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:max3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== email ===&lt;br /&gt;
This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_6.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:e_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:email.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:emailtest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== populate_new_response ===&lt;br /&gt;
This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:517_project4_7.jpg]]&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:populate.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:p_2.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:populatetest.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_by_answer ===&lt;br /&gt;
In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:q_1.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:questionnaire.jpeg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:ques3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== delete ===&lt;br /&gt;
Before the response is destroyed, its response scores will also be destroyed.&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:d1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:d2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:d3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== self.calibration_results_info(calibration_id, response_id, assignment_id) ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:s1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:s2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:s_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== notify_instructor_on_difference ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:n1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:n2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:n_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== done_by_staff_participant? ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:do1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:do2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:do3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil) ===&lt;br /&gt;
&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:di2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:di3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
=== construct_review_response(code, self_id, show_tags = nil, current_user = nil) ===&lt;br /&gt;
*Initial Coverage:&lt;br /&gt;
[[File:c_1.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Latest Coverage:&lt;br /&gt;
[[File:c_2.jpg|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
*Test Cases Added:&lt;br /&gt;
[[File:c_3.png|border|1000px]]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
[[File:grades_controller_cover.png|border|500px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_helper_cover.jpg|border|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:grades_cover.jpg|border|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Collaborators ===&lt;br /&gt;
*Li Yu Shan (lshan3)&lt;br /&gt;
*Chao Ting Hung (chung4)&lt;br /&gt;
*Chen Ni Liu (cliu43)&lt;br /&gt;
*Kan No Lee (klee32)&lt;br /&gt;
&lt;br /&gt;
=== Relevant Links ===&lt;br /&gt;
Main Expertiza Repository can be found [https://github.com/expertiza/expertiza here].&lt;br /&gt;
&lt;br /&gt;
Our forked Repository can be found [https://github.com/gggho0806/expertiza/tree/beta here].&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140236</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140236"/>
		<updated>2021-10-27T03:59:34Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code-quality-analysis result from Code Climate shows that all cyclomatic complexity was resolved, the main work was to fix the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenarios for get_team_color:''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. color should be red if response_map does not exist &amp;lt;br&amp;gt;&lt;br /&gt;
2. color should be blue if the a review was submitted for each round &amp;lt;br&amp;gt;&lt;br /&gt;
3. color should NOT be blue if the a review was NOT submitted for each round &amp;lt;br&amp;gt;&lt;br /&gt;
4. color should be brown if the review and review_grade exist &amp;lt;br&amp;gt;&lt;br /&gt;
5. color should be green if the submission link is non-existent &amp;lt;br&amp;gt;&lt;br /&gt;
6. color should be green if the submission link is NOT a link to a Expertiza wiki &amp;lt;br&amp;gt;&lt;br /&gt;
7. color should be purple if review were submitted for each round (on time) &amp;lt;br&amp;gt;&lt;br /&gt;
8. color should be purple if submission link has been updated since due date for a specified round &amp;lt;br&amp;gt;&lt;br /&gt;
9. should return green color if the submission link is not present &amp;lt;br&amp;gt;&lt;br /&gt;
10. should return green color if the assignment was not submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
11. should return purple color if the assignment was submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenarios for check_submission_state:''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. should return green color if the submitted link is not a wiki link &amp;lt;br&amp;gt;&lt;br /&gt;
2. should return green color if the submission link is not present &amp;lt;br&amp;gt;&lt;br /&gt;
3. should return green color if the assignment was not submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
4. should return purple color if the assignment was submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing ====&lt;br /&gt;
# Click &amp;quot;manage...&amp;quot; from the tabs above the webpage&lt;br /&gt;
# Select assignments from the dropdown list&lt;br /&gt;
# select the view reports icon from each created assignments&lt;br /&gt;
# click on view button to view different status of different conditions (can create additional assignments with shorter due date intervals, submit new works, and reviews to it)&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140235</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140235"/>
		<updated>2021-10-27T03:59:14Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code-quality-analysis result from Code Climate shows that all cyclomatic complexity was resolved, the main work was to fix the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test Plan ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenarios for get_team_color:''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. color should be red if response_map does not exist &amp;lt;br&amp;gt;&lt;br /&gt;
2. color should be blue if the a review was submitted for each round &amp;lt;br&amp;gt;&lt;br /&gt;
3. color should NOT be blue if the a review was NOT submitted for each round &amp;lt;br&amp;gt;&lt;br /&gt;
4. color should be brown if the review and review_grade exist &amp;lt;br&amp;gt;&lt;br /&gt;
5. color should be green if the submission link is non-existent &amp;lt;br&amp;gt;&lt;br /&gt;
6. color should be green if the submission link is NOT a link to a Expertiza wiki &amp;lt;br&amp;gt;&lt;br /&gt;
7. color should be purple if review were submitted for each round (on time) &amp;lt;br&amp;gt;&lt;br /&gt;
8. color should be purple if submission link has been updated since due date for a specified round &amp;lt;br&amp;gt;&lt;br /&gt;
9. should return green color if the submission link is not present &amp;lt;br&amp;gt;&lt;br /&gt;
10. should return green color if the assignment was not submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
11. should return purple color if the assignment was submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenarios for check_submission_state:''' &amp;lt;br&amp;gt;&lt;br /&gt;
1. should return green color if the submitted link is not a wiki link &amp;lt;br&amp;gt;&lt;br /&gt;
2. should return green color if the submission link is not present &amp;lt;br&amp;gt;&lt;br /&gt;
3. should return green color if the assignment was not submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
4. should return purple color if the assignment was submitted within the round &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Manual Testing ====&lt;br /&gt;
# Click &amp;quot;manage...&amp;quot; from the tabs above the webpage&lt;br /&gt;
# Select assignments from the dropdown list&lt;br /&gt;
# select the view reports icon from each created assignments&lt;br /&gt;
# click on view button to view different status of different conditions (can create additional assignments with shorter due date intervals and submit new works and reviews to it)&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140151</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140151"/>
		<updated>2021-10-27T00:16:50Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Modifications in review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code-quality-analysis result from Code Climate shows that all cyclomatic complexity was resolved, the main work was to fix the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140150</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140150"/>
		<updated>2021-10-27T00:16:19Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* E2125. Refactor review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code-quality-analysis result from Code Climate shows that all cyclomatic complexity was resolved, the main work was to fix the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140149</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140149"/>
		<updated>2021-10-27T00:15:46Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* E2125. Refactor review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code-quality-analysis result from Code Climate shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140148</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140148"/>
		<updated>2021-10-27T00:15:31Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* E2125. Refactor review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since the code quality analysis result from Code Climate shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140147</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140147"/>
		<updated>2021-10-27T00:14:18Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Peer Review Credentials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140146</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140146"/>
		<updated>2021-10-27T00:13:37Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140145</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140145"/>
		<updated>2021-10-27T00:13:24Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&amp;lt;pre&amp;gt; allow(Net::HTTP).to receive(:get_response).and_return(obj)(&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140144</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140144"/>
		<updated>2021-10-27T00:12:20Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Under the column &amp;quot;Team Reviewed&amp;quot;, color brown indicates that a score is given to the reviewer (including zero), and color blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140143</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140143"/>
		<updated>2021-10-27T00:11:04Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Modifications in review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
=====Example=====&lt;br /&gt;
Brown indicates that a score is given to the reviewer (including zero). Blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140142</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140142"/>
		<updated>2021-10-27T00:10:02Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Modifications in review_mapping_helper.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
‎&amp;lt;br /&amp;gt;&lt;br /&gt;
Example: Brown indicates that a score is given to the reviewer (including zero). Blue indicates that a score havnen't given to the reviewer.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_mapping_example.png]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_mapping_example.png&amp;diff=140141</id>
		<title>File:Review mapping example.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_mapping_example.png&amp;diff=140141"/>
		<updated>2021-10-27T00:05:48Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140140</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140140"/>
		<updated>2021-10-26T23:58:24Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* get_team_color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. Related pages can be found in &amp;quot;manages... -&amp;gt; assignments -&amp;gt; view reports -&amp;gt; view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140139</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140139"/>
		<updated>2021-10-26T23:52:44Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* obtain_team_color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;def obtain_team_color(response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
  color = []&lt;br /&gt;
  (1..@assignment.num_review_rounds).each do |round|&lt;br /&gt;
    check_submission_state(response_map, assignment_created, assignment_due_dates, round, color)&lt;br /&gt;
  end&lt;br /&gt;
  color[-1]&lt;br /&gt;
end &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140138</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140138"/>
		<updated>2021-10-26T23:50:39Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* obtain_team_color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary check on old submissions.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140137</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140137"/>
		<updated>2021-10-26T23:49:31Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* get_team_color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. There are five different states:‎&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Review_status_color.jpg]]&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_status_color.jpg&amp;diff=140136</id>
		<title>File:Review status color.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Review_status_color.jpg&amp;diff=140136"/>
		<updated>2021-10-26T23:46:44Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140135</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140135"/>
		<updated>2021-10-26T23:45:00Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* get_team_color */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
This method is to determine the state of reviewers review on each team. There are five different states:&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140133</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140133"/>
		<updated>2021-10-26T23:42:54Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
==== E2125. Refactor review_mapping_helper.rb ====&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring.&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140132</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140132"/>
		<updated>2021-10-26T23:42:10Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
E2125. Refactor review_mapping_helper.rb&lt;br /&gt;
* Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140131</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140131"/>
		<updated>2021-10-26T23:41:54Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
E2125. Refactor review_mapping_helper.rb&lt;br /&gt;
Files involved: review_mapping_helper.rb&lt;br /&gt;
* What is wrong:&lt;br /&gt;
** The review_mapping_helper.rb has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. Cyclomatic complexity of most of the methods is way too high as per the standard defined in the Code Climate.&lt;br /&gt;
* What needs to be done:&lt;br /&gt;
# Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.&lt;br /&gt;
# Read about cyclomatic complexity here.&lt;br /&gt;
# Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas and space or lack of it and assigning branching condition.&lt;br /&gt;
Write test cases of any new code written. Test the existing functionality after refactoring&lt;br /&gt;
&lt;br /&gt;
However, since in code climate it shows that all cyclomatic complexity was resolved, our main work was fixing the logic of the method &amp;quot;get_team_color&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140123</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140123"/>
		<updated>2021-10-26T23:31:59Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
Example test case:&lt;br /&gt;
&amp;lt;pre&amp;gt; it 'color should be purple if submission link has been updated since due date for a specified round' do&lt;br /&gt;
      # deadline_right inspired from bookmark_review_spec&lt;br /&gt;
      allow(Net::HTTP).to receive(:get_response).and_return({'last-modified' =&amp;gt; DateTime.now.in_time_zone})&lt;br /&gt;
      create(:deadline_right, name: 'No')&lt;br /&gt;
      create(:deadline_right, name: 'Late')&lt;br /&gt;
      create(:deadline_right, name: 'OK')&lt;br /&gt;
&lt;br /&gt;
      response_map_with_reviewee = create(:review_response_map, reviewer: @reviewer, reviewee: @reviewee_with_assignment)&lt;br /&gt;
&lt;br /&gt;
      create(:submission_record, assignment_id: @assignment.id, team_id: @reviewee_with_assignment.id, operation: 'Submit Hyperlink',&lt;br /&gt;
        content: 'https://wiki.archlinux.org/', created_at: DateTime.now.in_time_zone - 7.day)&lt;br /&gt;
&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 1, due_at: DateTime.now.in_time_zone - 5.day)&lt;br /&gt;
      create(:assignment_due_date, assignment: @assignment, parent_id: @assignment.id, round: 2, due_at: DateTime.now.in_time_zone + 6.day)&lt;br /&gt;
&lt;br /&gt;
      create(:response, response_map: response_map_with_reviewee)&lt;br /&gt;
&lt;br /&gt;
      color = get_team_color(response_map_with_reviewee)&lt;br /&gt;
      expect(color).to eq('purple')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140120</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=140120"/>
		<updated>2021-10-26T23:25:36Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
# In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
# The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
# Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=139941</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=139941"/>
		<updated>2021-10-24T03:26:45Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: /* Progress */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
1. In method get_team_color(response_map) in review mapping helper.rb: Only checking if the record exist is not enough, because all mapping records pre-exist with empty scores in it. &lt;br /&gt;
2. The for loop for checking multiple submission stage is unnecesasry, so we removed obtain_team_color and call check_submission_state directly. &lt;br /&gt;
3. Stubbing NET::HTTP to fix test cases that originally failed if calling the method get_link_updated_at.&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=139940</id>
		<title>CSC/ECE 517 Fall 2021 - E2125. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2125._Refactor_review_mapping_helper.rb&amp;diff=139940"/>
		<updated>2021-10-24T03:06:19Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
== E2125. Refactor review mapping helper.rb ==&lt;br /&gt;
This page describes the Expertiza based OSS project.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source project contributed by both the students and the faculty at NCSU. It is developed on Ruby-on-Rails and software to create reusable learning objects through peer review. Expertiza allows the instructor to create new assignments, customize new or existing assignments, and create a topic list for students to sign up. It also supports students to form teams for team projects and allows submission with almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
=== Modifications in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
===== get_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
The original code will not return the correct color, because when it is checking the grade for the reviewer, it is not checking the correct variable. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; def get_team_color(response_map)&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_created = @assignment.created_at&lt;br /&gt;
&lt;br /&gt;
    # Storing redundantly computed value in a variable&lt;br /&gt;
    assignment_due_dates = DueDate.where(parent_id: response_map.reviewed_object_id)&lt;br /&gt;
&lt;br /&gt;
    # Returning colour based on conditions&lt;br /&gt;
    if Response.exists?(map_id: response_map.id)&lt;br /&gt;
      if !response_map.try(:reviewer).try(:review_grade).grade_for_reviewer.nil?&lt;br /&gt;
        'brown'&lt;br /&gt;
      elsif response_for_each_round?(response_map)&lt;br /&gt;
        'blue'&lt;br /&gt;
      else&lt;br /&gt;
        check_submission_state(response_map, assignment_created, assignment_due_dates, @assignment.num_review_rounds)&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      'red'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== check_submission_state =====&lt;br /&gt;
&lt;br /&gt;
This method checks whether the team submit the project on time or not. (If there are no submission or the submission is not on time, it is reasonable that the reviewer cannot review the project).&lt;br /&gt;
In addition, the submission time of a link should be checked by the last modified time of the webpage, not the moment the link itself is submitted.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def check_submission_state(response_map, assignment_created, assignment_due_dates, round)&lt;br /&gt;
    if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      'purple'&lt;br /&gt;
    else&lt;br /&gt;
      link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates)&lt;br /&gt;
      if link.nil? or (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future&lt;br /&gt;
        'green'&lt;br /&gt;
      else&lt;br /&gt;
        link_updated_at = get_link_updated_at(link)&lt;br /&gt;
        link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== obtain_team_color =====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This method has been removed because it is running unnecessary loop.&lt;br /&gt;
&lt;br /&gt;
=== Testing Details in review_mapping_helper.rb ===&lt;br /&gt;
&lt;br /&gt;
==== RSpec ====&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
All 32 test cases are currently passing.&lt;br /&gt;
&lt;br /&gt;
=== Progress ===&lt;br /&gt;
This project is currently in progress. This page will be updated accordingly.&lt;br /&gt;
&lt;br /&gt;
=== Peer Review Credentials ===&lt;br /&gt;
Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
Password: password&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139366</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139366"/>
		<updated>2021-10-20T13:54:14Z</updated>

		<summary type="html">&lt;p&gt;Lshan3: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - {$num}. {$desc.title}]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;/div&gt;</summary>
		<author><name>Lshan3</name></author>
	</entry>
</feed>