<?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=Smeneze</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=Smeneze"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Smeneze"/>
	<updated>2026-07-25T04:41:06Z</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_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128558</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128558"/>
		<updated>2019-11-11T07:25:13Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of search attributes for a given entity along with a list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;User&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Assignment&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#assignment_name&lt;br /&gt;
#assignee_username&lt;br /&gt;
#assignee_name&lt;br /&gt;
#due_date_before&lt;br /&gt;
#due_date_after&lt;br /&gt;
#created_before&lt;br /&gt;
#created_after&lt;br /&gt;
&lt;br /&gt;
*Modified files&lt;br /&gt;
#app/models/assignment_node.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Questionnaire&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#name&lt;br /&gt;
#text&lt;br /&gt;
#course&lt;br /&gt;
#assignment&lt;br /&gt;
*Modified files&lt;br /&gt;
#app/models/questionnaire_node.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#team&lt;br /&gt;
#text&lt;br /&gt;
#min_score&lt;br /&gt;
#max_score&lt;br /&gt;
*Modified files&lt;br /&gt;
#app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
#app/controllers/review_mapping_controller.rb&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128557</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128557"/>
		<updated>2019-11-11T07:24:42Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of search attributes for a given entity along with a list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;User&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Assignment&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#assignment_name&lt;br /&gt;
#assignee_username&lt;br /&gt;
#assignee_name&lt;br /&gt;
#due_date_before&lt;br /&gt;
#due_date_after&lt;br /&gt;
#created_before&lt;br /&gt;
#created_after&lt;br /&gt;
&lt;br /&gt;
*Modified files&lt;br /&gt;
#app/models/assignment_node.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Questionnaire&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#name&lt;br /&gt;
#text&lt;br /&gt;
#course&lt;br /&gt;
#assignment&lt;br /&gt;
*Modified files&lt;br /&gt;
1.app/models/questionnaire_node.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#team&lt;br /&gt;
#text&lt;br /&gt;
#min_score&lt;br /&gt;
#max_score&lt;br /&gt;
*Modified files&lt;br /&gt;
#app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
#app/controllers/review_mapping_controller.rb&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128556</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128556"/>
		<updated>2019-11-11T07:21:11Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;User&amp;lt;/b&amp;gt;&lt;br /&gt;
*Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128555</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128555"/>
		<updated>2019-11-11T07:20:43Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128554</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128554"/>
		<updated>2019-11-11T07:20:11Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
**Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128553</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128553"/>
		<updated>2019-11-11T07:19:07Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
***username&lt;br /&gt;
***user_id&lt;br /&gt;
***fullname&lt;br /&gt;
***email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
**app/views/users/list.html.erb&lt;br /&gt;
**app/controllers/users_controller.rb&lt;br /&gt;
**app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128552</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128552"/>
		<updated>2019-11-11T07:18:52Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
***username&lt;br /&gt;
***user_id&lt;br /&gt;
***fullname&lt;br /&gt;
***email&lt;br /&gt;
&lt;br /&gt;
*Files to be modified:&lt;br /&gt;
***app/views/users/list.html.erb&lt;br /&gt;
***app/controllers/users_controller.rb&lt;br /&gt;
***app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128551</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128551"/>
		<updated>2019-11-11T07:18:32Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is the list of attributes that would be searched for a given entity and the list of files that would altered in the process.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
***username&lt;br /&gt;
***user_id&lt;br /&gt;
***fullname&lt;br /&gt;
***email&lt;br /&gt;
&lt;br /&gt;
**Files to be modified:&lt;br /&gt;
***app/views/users/list.html.erb&lt;br /&gt;
***app/controllers/users_controller.rb&lt;br /&gt;
***app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128548</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128548"/>
		<updated>2019-11-11T07:11:56Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore in order to develop the search functionality, changes are required in all the three layers.&lt;br /&gt;
&lt;br /&gt;
View : Changes in view are changes added to UI, and it is used to pass search parameters to controller&lt;br /&gt;
Controller : Parses the changes from UI, essentially takes params[] hash.&lt;br /&gt;
Model : Bulk of search logic is implemented here, once the model gets the parameters for the search ( hash ), the query is incrementally built using all the params and then executed to get the list of objects.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
#username&lt;br /&gt;
#user_id&lt;br /&gt;
#fullname&lt;br /&gt;
#email&lt;br /&gt;
&lt;br /&gt;
Files to be modified:&lt;br /&gt;
#app/views/users/list.html.erb&lt;br /&gt;
#app/controllers/users_controller.rb&lt;br /&gt;
#app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128547</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128547"/>
		<updated>2019-11-11T07:09:17Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore in order to develop the search functionality, changes are required in all the three layers.&lt;br /&gt;
&lt;br /&gt;
View : Changes in view are changes added to UI, and it is used to pass search parameters to controller&lt;br /&gt;
Controller : Parses the changes from UI, essentially takes params[] hash.&lt;br /&gt;
Model : Bulk of search logic is implemented here, once the model gets the parameters for the search ( hash ), the query is incrementally built using all the params and then executed to get the list of objects.&lt;br /&gt;
&lt;br /&gt;
*User&lt;br /&gt;
**Search fields&lt;br /&gt;
username&lt;br /&gt;
name&lt;br /&gt;
email&lt;br /&gt;
Modified files:&lt;br /&gt;
app/views/users/list.html.erb&lt;br /&gt;
app/controllers/users_controller.rb&lt;br /&gt;
app/models/user.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
UsersController#list : Parses the username, name and email from the params hash.&lt;br /&gt;
User#get_user_list : Model returns list of users to the view, changes in this function uses regex to filter out the entries that do not match search params.&lt;br /&gt;
[edit]Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128546</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128546"/>
		<updated>2019-11-11T07:05:30Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/questionnaire/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore in order to perform search every entity required changes in all the three layers&lt;br /&gt;
&lt;br /&gt;
View : Changes in view are changes added to UI, and it is used to pass search parameters to controller&lt;br /&gt;
Controller : Parses the changes from UI, essentially takes params[] hash.&lt;br /&gt;
Model : Bulk of search logic is implemented here, once the model gets the parameters for the search ( hash ), the query is incrementally built using all the params and then executed to get the list of objects.&lt;br /&gt;
User changes have been handled differently than for Questionnaire, Assignments and Review because Users follows the traditional RoR scheme, where as others user React for UI. React based View changes are in app/assets/javascripts/tree_display.jsx.&lt;br /&gt;
&lt;br /&gt;
[edit]User&lt;br /&gt;
Search fields&lt;br /&gt;
username&lt;br /&gt;
name&lt;br /&gt;
email&lt;br /&gt;
Modified files:&lt;br /&gt;
app/views/users/list.html.erb&lt;br /&gt;
app/controllers/users_controller.rb&lt;br /&gt;
app/models/user.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
UsersController#list : Parses the username, name and email from the params hash.&lt;br /&gt;
User#get_user_list : Model returns list of users to the view, changes in this function uses regex to filter out the entries that do not match search params.&lt;br /&gt;
[edit]Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128545</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128545"/>
		<updated>2019-11-11T07:04:47Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
#localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
#localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore in order to perform search every entity required changes in all the three layers&lt;br /&gt;
&lt;br /&gt;
View : Changes in view are changes added to UI, and it is used to pass search parameters to controller&lt;br /&gt;
Controller : Parses the changes from UI, essentially takes params[] hash.&lt;br /&gt;
Model : Bulk of search logic is implemented here, once the model gets the parameters for the search ( hash ), the query is incrementally built using all the params and then executed to get the list of objects.&lt;br /&gt;
User changes have been handled differently than for Questionnaire, Assignments and Review because Users follows the traditional RoR scheme, where as others user React for UI. React based View changes are in app/assets/javascripts/tree_display.jsx.&lt;br /&gt;
&lt;br /&gt;
[edit]User&lt;br /&gt;
Search fields&lt;br /&gt;
username&lt;br /&gt;
name&lt;br /&gt;
email&lt;br /&gt;
Modified files:&lt;br /&gt;
app/views/users/list.html.erb&lt;br /&gt;
app/controllers/users_controller.rb&lt;br /&gt;
app/models/user.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
UsersController#list : Parses the username, name and email from the params hash.&lt;br /&gt;
User#get_user_list : Model returns list of users to the view, changes in this function uses regex to filter out the entries that do not match search params.&lt;br /&gt;
[edit]Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128544</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128544"/>
		<updated>2019-11-11T07:04:05Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
The search feature could be implemented in a more RESTful manner by adding it to individual models rather than implementing it as a single controller.&lt;br /&gt;
&lt;br /&gt;
If we followed this approach the search query would be as follows:&lt;br /&gt;
localhost:port/user/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
localhost:port/assignment/search?name=&amp;lt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Therefore in order to perform search every entity required changes in all the three layers&lt;br /&gt;
&lt;br /&gt;
View : Changes in view are changes added to UI, and it is used to pass search parameters to controller&lt;br /&gt;
Controller : Parses the changes from UI, essentially takes params[] hash.&lt;br /&gt;
Model : Bulk of search logic is implemented here, once the model gets the parameters for the search ( hash ), the query is incrementally built using all the params and then executed to get the list of objects.&lt;br /&gt;
User changes have been handled differently than for Questionnaire, Assignments and Review because Users follows the traditional RoR scheme, where as others user React for UI. React based View changes are in app/assets/javascripts/tree_display.jsx.&lt;br /&gt;
&lt;br /&gt;
[edit]User&lt;br /&gt;
Search fields&lt;br /&gt;
username&lt;br /&gt;
name&lt;br /&gt;
email&lt;br /&gt;
Modified files:&lt;br /&gt;
app/views/users/list.html.erb&lt;br /&gt;
app/controllers/users_controller.rb&lt;br /&gt;
app/models/user.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
UsersController#list : Parses the username, name and email from the params hash.&lt;br /&gt;
User#get_user_list : Model returns list of users to the view, changes in this function uses regex to filter out the entries that do not match search params.&lt;br /&gt;
[edit]Assignment&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
assignee_username&lt;br /&gt;
assignee_name&lt;br /&gt;
due_date_before&lt;br /&gt;
due_date_after&lt;br /&gt;
created_before&lt;br /&gt;
created_after&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/assignment_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#initialize_fnode_update_children&lt;br /&gt;
TreeDisplayController#update_fnode_children&lt;br /&gt;
AssignmentNode.get&lt;br /&gt;
[edit]Questionnaire&lt;br /&gt;
Search fields&lt;br /&gt;
name&lt;br /&gt;
text&lt;br /&gt;
course&lt;br /&gt;
assignment&lt;br /&gt;
Modified files&lt;br /&gt;
app/assets/javascripts/tree_display.jsx&lt;br /&gt;
app/controllers/tree_display_controller.rb&lt;br /&gt;
app/models/questionnaire_node.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
TreeDisplayController#get_tmp_res&lt;br /&gt;
QuestionnaireNode.get&lt;br /&gt;
[edit]Review&lt;br /&gt;
Search fields&lt;br /&gt;
team&lt;br /&gt;
text&lt;br /&gt;
min_score&lt;br /&gt;
max_score&lt;br /&gt;
Modified files&lt;br /&gt;
app/views/review_mapping/_searchbox.html.erb&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/helpers/summary_helper.rb&lt;br /&gt;
Modified functions&lt;br /&gt;
ReviewMappingController#response_report&lt;br /&gt;
SummaryHelper#summarize_reviews_by_reviewees&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128543</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128543"/>
		<updated>2019-11-11T06:55:50Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128542</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128542"/>
		<updated>2019-11-11T06:55:34Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Solution: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source application running on Ruby on Rails. It is used for management of courses and the assignments for respective courses, by the faculties and the students. The manage content section of the application has different views which displays information about the users, courses, assignments, questionnaires, and reviews. The application should have a fully functional search functionality throughout the views, so that a user can search any type of data with ease, on the basis of any number of parameters depending on his requirements. Users should be searched on the basis of one more parameters which include name, full name, email, etc. Similarly, assignments should be searched on the basis of name, created date, updated date, etc. However, the search functionality in the existing application is constrained to just a single parameter for users and assignments. Questionnaires management does not have a search functionality implemented as yet. This project works on improving the search functionality of Expertiza, by adding search bars if not present, introducing advanced search feature where user can search on the basis of more than one parameters and making the search functionality appear more elegant.&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
[[File:UseCaseExpertizaSearch.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
===Search for User:===&lt;br /&gt;
&lt;br /&gt;
In the current system workflow, we found that the user is unable to search in the Manage Users view. In the proposed workflow, we plan to enable the user to search by all the columns in the UI viz. Name, Full name, Email Address, Role, Parent by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Users&lt;br /&gt;
:#Type the search string in the search box available on the UI and select the column to search for from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the specified criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Assignments:===&lt;br /&gt;
&lt;br /&gt;
In the current system implementation, searching via the name of the assignment is supported with partial or complete assignment name. However, the search is case sensitive. In the proposed system, the user will be able to search for an assignment using additional filters such as Creation Date and Updated Date along with Assignment Name. The user will also be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Assignments&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Questionnaires:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Questionnaires. The proposed system will implement a search functionality for searching via the name of the questionnaire, the text in the questions within a questionnaire, date of creation, and date updated by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
To search for an assignment by Creation Date, the user will be prompted with a calendar where he can select a date and all the assignments created on or before the selected date will be displayed. &lt;br /&gt;
&lt;br /&gt;
To apply multiple filters, user can tap on the Advanced Search button available, adjacent to the Search button; a hidden div will then be rendered below containing textboxes for all the columns. All assignments that were created before the selected date for Creation Date or Updated Date columns and the ones that match other filters will be returned. A empty list will be returned if the search criteria doesn't match any records in the database. The questionnaires will be grouped on the basis of their courses and will be expanded when clicked.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#Go to Manage &amp;gt; Questionnaires&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
===Search for Reviews:===&lt;br /&gt;
&lt;br /&gt;
The existing system does not have a search functionality under Reviews. The proposed system will implement a search functionality for searching using the attributes like team name, score, reviewer, comment etc. by entering a partial or a complete text that matches with the particular field. We will also allow searching for fields irrespective of the case of the searched string. The user will be able to apply multiple filters at a time and the output of the query will match all the filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
The user will be able to apply multiple filters at a time and the output of the query will match all filters applied. If no results are found, an empty list will be returned.&lt;br /&gt;
&lt;br /&gt;
Steps to reproduce the proposed workflow:&lt;br /&gt;
:#Log in to expertiza to view the home page&lt;br /&gt;
:#&lt;br /&gt;
:#Type the search criteria in the available search criteria and select the appropriate field from the dropdown.&lt;br /&gt;
:#To perform search based on multiple filters, the user can tap on the Advanced Search button adjacent to the Search button, the view renders a hidden div containing textboxes for all the columns, allowing the user to search based on multiple columns.&lt;br /&gt;
:#All the entries that match the given criteria will be returned.&lt;br /&gt;
:#An empty list is returned if the search criteria doesn't match any valid records in the database.&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
Below is the simplified version of the ER diagram which displays the relationships between the entity sets. Team_users and assignment_questionnaires are many to many relationships which are implemented in table format as show below.&lt;br /&gt;
&lt;br /&gt;
[[File:ER diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Relevant Tables===&lt;br /&gt;
[[File:User table.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screen Shot 2018-11-20 at 11.42.06 PM.png|center]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;br /&gt;
=== Automated Tests ===&lt;br /&gt;
Automated tests in RSpec will be added as we implement the search functionality for each modified file. Most of the tests added will be unit tests that cover the use cases for each flow and changes made in the model as per the requirement description.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Test Details:====&lt;br /&gt;
=====User Model ( spec/models/user_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by user name that does not exist&lt;br /&gt;
# Search by user email&lt;br /&gt;
# Search by user email that does not exist&lt;br /&gt;
# Search by user email containing a substring&lt;br /&gt;
# Search by user full name&lt;br /&gt;
# Search by user full name is empty&lt;br /&gt;
# Search by user name and email&lt;br /&gt;
# Search for assignments participated&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Assignment Model ( spec/models/assignment_spec.rb )=====&lt;br /&gt;
# Search by user name&lt;br /&gt;
# Search by institution&lt;br /&gt;
# Search by creation date&lt;br /&gt;
# Search by updated date&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Rubrics=====&lt;br /&gt;
# Search by name&lt;br /&gt;
# Search by courses used in&lt;br /&gt;
# Search by assignments used in&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Reviews=====&lt;br /&gt;
# Search all reviews of a particular team’s work for particular scores or text strings.  &lt;br /&gt;
# Search by score&lt;br /&gt;
# Search by text comment length&lt;br /&gt;
# Search by reviewer and reviewee&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Manual Tests ===&lt;br /&gt;
=====Search for User=====&lt;br /&gt;
# Setup: create a user with name=&amp;quot;student&amp;quot; and userId=&amp;quot;5000&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; in textbox enters name=&amp;quot;student&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action: Instructor clicks on manage - &amp;gt; users -&amp;gt; advanced search-&amp;gt;clicks on checkbox student id and enters &amp;quot;5000&amp;quot; and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response: Relevant details of student, name=&amp;quot;student&amp;quot; is displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Assignments=====&lt;br /&gt;
# Setup create an assignment with name=&amp;quot;assignment&amp;quot; and set a due date&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments, in textbox enter &amp;quot;assignment&amp;quot; in relevant tab&amp;lt;br&amp;gt; &lt;br /&gt;
# Response : Relevant assignment should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Instructor clicks on Manage -&amp;gt; Assignments-&amp;gt; drop down and apply filters for due date and enter date and click &amp;quot;ok&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Relevant assignments should be displayed&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Questionnaires=====&lt;br /&gt;
# Setup : Create a Questionnaire, add questions to it&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, in text box enter text&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor,  Manage -&amp;gt; Questionnaires, click advanced search and check creation date and enter value&amp;lt;br&amp;gt;&lt;br /&gt;
# Response : Questionnaires matching text are shown&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
=====Search for Reviews=====&lt;br /&gt;
# Setup : Setup review for an assignment, login as student and then add review &amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Log in as instructor, Manage -&amp;gt; Assignments, Click on Review Report icon on corresponding assignment&amp;lt;br&amp;gt;&lt;br /&gt;
# Result : Review should be seen&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
# Action : Click Advanced search, check review by text  and enter text&amp;lt;br&amp;gt;  &lt;br /&gt;
# Result : Matching review should be visible&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128322</id>
		<title>CSC/ECE 517 Fall 2019 - E1987. Improving search facility in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1987._Improving_search_facility_in_Expertiza&amp;diff=128322"/>
		<updated>2019-11-11T00:21:07Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction:==&lt;br /&gt;
&lt;br /&gt;
The Expertiza application running on Ruby on Rails is used for a variety of purposes by students and faculty members. There are many pages that display information about students, assignments, rubrics and reviews. The information is displayed with attributes like name, ID, due date etc. This project works on improving the search facility by adding search criteria in existing search bars, making it look elegant and adding search bars if not present.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Definition:==&lt;br /&gt;
&lt;br /&gt;
#An instructor or administrator can search for a user by name, user-ID, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for assignments by name, due date, or other characteristics.&lt;br /&gt;
#An instructor should be able to search for rubrics (or other questionnaires) by name, or by the courses or assignments they have been used in.&lt;br /&gt;
##For the instructor, there also needs to be a way to quickly find rubrics (and other questionnaires) that have been used in a single course.  It should be possible to search or click somewhere to bring up a list of questionnaires used in the course, expanding only the applicable questionnaires in the list of questionnaires.&lt;br /&gt;
##One should also be able to search for questionnaires by words used in questions that belong to the questionnaires.&lt;br /&gt;
#There should be a way to search all reviews of a particular team’s work for particular scores or text strings.  Reviews should be able to be filtered by score, text comment length, reviewer and reviewee.&lt;br /&gt;
#An instructor or administrator should be able to search for all the assignments that a particular user has participated in.&lt;br /&gt;
#If more than one criteria needs to be specified, there should be an 'Advanced Search' button.&lt;br /&gt;
&lt;br /&gt;
==Proposed Solution:==&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
&lt;br /&gt;
==Proposed Code Changes==&lt;br /&gt;
&lt;br /&gt;
==Database Design==&lt;br /&gt;
&lt;br /&gt;
==Test Plan: ==&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127898</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127898"/>
		<updated>2019-11-07T03:15:33Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Project Description==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Current Implementation==&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to a student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Process resize.png]]&lt;br /&gt;
[[File:Issue.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The is_reviews_allowed method checks the number of reviews assigned to a student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then it returns False.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The check_outstanding_reviews checks the number of outstanding assignment reviews a user can have at a time. The check_outstanding_reviews keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_reviews returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127887</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127887"/>
		<updated>2019-11-07T03:11:23Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Current Implementation==&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to a student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Process resize.png]]&lt;br /&gt;
[[File:Issue.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to a student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and no topic is selected by reviewer' do&lt;br /&gt;
      it 'shows an error message and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        allow(assignment).to receive(:can_choose_topic_to_review?).and_return(true)&lt;br /&gt;
        params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(flash[:error]).to eq('No topic is selected.  Please go back and select a topic.')&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when number of reviews are less than the assignment policy' do&lt;br /&gt;
      it 'redirects to student review page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:where).with(reviewer_id: 1, reviewed_object_id: 1 )&lt;br /&gt;
                                  .and_return([])&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
        params = {&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            reviewer_id: 1,&lt;br /&gt;
            topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when number of reviews are greater than the assignment policy' do&lt;br /&gt;
      it 'shows a flash error and redirects to student review page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:where).with(reviewer_id: 1, reviewed_object_id: 1 )&lt;br /&gt;
                                        .and_return([1,2,3])&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
        params = {&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            reviewer_id: 1,&lt;br /&gt;
            topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
        expect(flash[:error]).to be_present&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user has outstanding reviews less than assignment policy'  do&lt;br /&gt;
      it 'redirects to student review page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:where).with(reviewer_id: 1, reviewed_object_id: 1 )&lt;br /&gt;
                                        .and_return(:review_response_map)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
        allow(assignment).to receive(:max_outstanding_reviews).and_return(0)&lt;br /&gt;
&lt;br /&gt;
        params = {&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            reviewer_id: 1,&lt;br /&gt;
            topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when user has outstanding reviews greater than assignment policy'  do&lt;br /&gt;
      it 'redirects to student review page and shows flash error' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:where).with(reviewer_id: 1, reviewed_object_id: 1 )&lt;br /&gt;
                                        .and_return(:review_response_map)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
        allow(assignment).to receive(:max_outstanding_reviews).and_return(3)&lt;br /&gt;
&lt;br /&gt;
        params = {&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            reviewer_id: 1,&lt;br /&gt;
            topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(flash[:error]).to be_present&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&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;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127886</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127886"/>
		<updated>2019-11-07T03:10:30Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Problems in Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Current Implementation==&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to a student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Process resize.png]]&lt;br /&gt;
[[File:Issue.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to a student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127865</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127865"/>
		<updated>2019-11-07T03:04:40Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to a student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Process resize.png|frame|left|Main page]]&lt;br /&gt;
[[File:Issue.png|frame|right|Current Implementation Issue]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to a student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127852</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127852"/>
		<updated>2019-11-07T02:59:59Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue.png|frame|centre|Current Implementation Issue]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to a student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127849</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127849"/>
		<updated>2019-11-07T02:59:11Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Problems in Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127848</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127848"/>
		<updated>2019-11-07T02:58:31Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews assigned to a student. There is a check in the UI, but one could evade the limit by typing in a URL to make the same post request. One can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Issue.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127839</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127839"/>
		<updated>2019-11-07T02:54:24Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
====Issue 1====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
====Issue 2====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
====Issue 3====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127834</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127834"/>
		<updated>2019-11-07T02:49:28Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open-source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project, in particular intends that the students collaborate and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open-source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently, there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough reviews for that assignment before getting a new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on the maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to the review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127831</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127831"/>
		<updated>2019-11-07T02:43:20Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough number of reviews for that assignment before getting new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127829</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127829"/>
		<updated>2019-11-07T02:41:32Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough number of reviews for that assignment before getting new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127828</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127828"/>
		<updated>2019-11-07T02:40:10Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough number of reviews for that assignment before getting new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
  @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
  assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127827</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127827"/>
		<updated>2019-11-07T02:39:29Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough number of reviews for that assignment before getting new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127822</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127822"/>
		<updated>2019-11-07T02:36:34Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy. Also, there is no check to see if the user has submitted enough number of reviews for that assignment before getting new review.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127818</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127818"/>
		<updated>2019-11-07T02:34:09Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Files modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
=====Issue 1=====&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
=====Issue 2=====&lt;br /&gt;
*There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
=====Issue 3=====&lt;br /&gt;
*There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where a new check was added. This check fetches the number of reviews done by a student currently from ReviewResponseMap table. To adapt to those changes, two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127788</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127788"/>
		<updated>2019-11-07T02:10:56Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submissions even if the current outstanding ones are pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127787</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127787"/>
		<updated>2019-11-07T02:10:27Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
*There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submission even if the current outstanding ones are still pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127785</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127785"/>
		<updated>2019-11-07T02:10:04Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1: No limitation on maximum number of peer reviews.&amp;lt;/b&amp;gt;&lt;br /&gt;
There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2: No check on duplicate submissions&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3: There is no check on the number of outstanding reviews&amp;lt;/b&amp;gt;&lt;br /&gt;
*A user can request for submission even if the current outstanding ones are still pending&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127781</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127781"/>
		<updated>2019-11-07T02:06:38Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1:&amp;lt;/b&amp;gt;&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127780</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127780"/>
		<updated>2019-11-07T02:06:03Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Problems in Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1:&amp;lt;/b&amp;gt;&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127779</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127779"/>
		<updated>2019-11-07T02:05:50Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* List of Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==Problems in Current Implementation==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 1:&amp;lt;/b&amp;gt;&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 2:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
&amp;lt;b&amp;gt;Problem 3:&amp;lt;/b&amp;gt;&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127772</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127772"/>
		<updated>2019-11-07T02:04:07Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are less than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically.&lt;br /&gt;
::::2. Redirect to Student review page.&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy: &amp;lt;pre&amp;gt;context 'when number of reviews are greater than the assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Redirect to Student review page.&lt;br /&gt;
::::2. Show Flash Error. [flash[:error] = &amp;quot;You cannot do more reviews when you have &amp;quot;+ assignment.max_outstanding_reviews + &amp;quot;reviews to do&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
All the test cases have been automated in the review_mapping_controller_spec File&lt;br /&gt;
&lt;br /&gt;
::1. Student has pending reviews less than assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews less than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy [default 2 pending reviews at most]: &amp;lt;pre&amp;gt;context 'when user has outstanding reviews greater than assignment policy'&amp;lt;/pre&amp;gt;&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127763</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127763"/>
		<updated>2019-11-07T02:00:02Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127761</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127761"/>
		<updated>2019-11-07T01:59:34Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
===Issue 2===&lt;br /&gt;
 There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
===Issue 3===&lt;br /&gt;
There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127759</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127759"/>
		<updated>2019-11-07T01:58:46Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Issues Presented */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
&lt;br /&gt;
===Issue 2===&lt;br /&gt;
&lt;br /&gt;
===Issue 3===&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127758</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127758"/>
		<updated>2019-11-07T01:58:29Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Issue 1===&lt;br /&gt;
&lt;br /&gt;
===Issue 2===&lt;br /&gt;
&lt;br /&gt;
===Issue 3===&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
* There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
::1. Student has done reviews less than assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
::2. Student has done reviews more than the assignment policy:&lt;br /&gt;
::::1. Assign Review Dynamically&lt;br /&gt;
::::2. Redirect to Student review page&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127755</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127755"/>
		<updated>2019-11-07T01:56:49Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
* There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127753</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127753"/>
		<updated>2019-11-07T01:56:34Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
* There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127752</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127752"/>
		<updated>2019-11-07T01:55:12Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if a student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
* There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127749</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127749"/>
		<updated>2019-11-07T01:51:20Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Issues Presented */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
* There is no check on the number of outstanding reviews a user can have.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127746</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127746"/>
		<updated>2019-11-07T01:48:32Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127745</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127745"/>
		<updated>2019-11-07T01:48:17Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127744</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127744"/>
		<updated>2019-11-07T01:47:40Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time. The code for the same has been implemented in the review_mappings_controller.rb where the user would be allowed to request for a new submission depending on the value returned by the check_outstanding_reviews method. &lt;br /&gt;
&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127737</id>
		<title>CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug&amp;diff=127737"/>
		<updated>2019-11-07T01:41:20Z</updated>

		<summary type="html">&lt;p&gt;Smeneze: /* Proposed Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==&amp;lt;b&amp;gt;E1956. There is no shortcut to get free review points: Review Assignment Bug&amp;lt;/b&amp;gt;==&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
E1956. There is no shortcut to get free review points: Review Assignment Bug&lt;br /&gt;
===Background===&lt;br /&gt;
Each assignment contains an assignment policy. We can generally submit n reviews according to assignment policy. For an assignment with topics, a student has an option to choose a submission to review or can say “I don’t care” and the system chooses any available topic for review. &lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
&lt;br /&gt;
This project in particular intends that the students collaborate with each other and work on making enhancements to the code base by applying the concepts of Rails,RSpec, DRY code,Test driven development etc. This provides an opportunity for students to contribute to an open source project and learn further about software deployment etc.&lt;br /&gt;
&lt;br /&gt;
Currently there is no check in the backend that limits the number of reviews a student can be assigned. Students can get more peer reviews than assignment policy.&lt;br /&gt;
&lt;br /&gt;
====Proposed Changes====&lt;br /&gt;
* The assign_review_dynamically method was previously not keeping a track of the number of assignments reviewed by a student. &lt;br /&gt;
The code, in order to assign reviews in a dynamic fashion has been implemented in the review_mappings_controller.rb. The method assign_review_dynamically, checks initially if student has selected a topic for which he wants a review or if the &amp;quot;I don't care&amp;quot; option is selected. Based on the selection the method would then select a submission which is&lt;br /&gt;
::1. Not assigned previously to given student&lt;br /&gt;
::2. Is not his own submission&lt;br /&gt;
* The assign_review_dynamically method also does not keep a check on the number of outstanding submissions that a student can have at any time.&lt;br /&gt;
&lt;br /&gt;
However, since the code did not have a check for how many reviews already are allocated to a given student, one could easily bypass the review limit by sending the same post request again and again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;ReviewResponseMap:&amp;lt;/b&amp;gt;&lt;br /&gt;
::Creates a mapping from the student to assigned submission for reviewing as soon as assign_review_dynamically assigns a submission to student for review.&lt;br /&gt;
&lt;br /&gt;
We decided to get all the reviews assigned to given student from ReviewResponseMap (where(reviewer_id: reviewer.id)) and then check if the size of the reviews assigned to the given reviewer is more than the maximum value allocated for the assignment and creates a flash error if the maximum review limit is exceded.&lt;br /&gt;
&lt;br /&gt;
==List of Changes==&lt;br /&gt;
===Issues Presented===&lt;br /&gt;
*The number of reviews done by any student is not checked in the back-end with the maximum number of submissions allowed as per the assignment policy.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student.&lt;br /&gt;
&lt;br /&gt;
===Current Implementation===&lt;br /&gt;
&lt;br /&gt;
* No limitation on maximum number of peer reviews.&lt;br /&gt;
::There is no check in the backend that limits the number of reviews a student can be assigned.  There is a check in the UI, but you could evade the limit by typing in a URL to make the same post request. You can also evade it by clicking multiple times on &amp;quot;Request a review for submission&amp;quot; button in UI.&lt;br /&gt;
* There is no check to see if the submission is already assigned to the student (on consulting the TA, it was made known that the feature was working correctly without editing any of the code and thus no refactoring was performed for this task).&lt;br /&gt;
* If the same request is re-sent, the system adds the same submission for review a second time.&lt;br /&gt;
* There is no check on the number of outstanding reviews that a user can have at any time.&lt;br /&gt;
&lt;br /&gt;
[[File:Merged.png]]&lt;br /&gt;
&lt;br /&gt;
==Proposed Implementation==&lt;br /&gt;
&lt;br /&gt;
===Files modified===&lt;br /&gt;
'''review_mapping_controller_spec.rb'''&lt;br /&gt;
* Change has been done in the implementation of review_mapping_controller.rb where new check was added. This check fetches number of reviews done by the student currently from ReviewResponseMap table. To adapt to those changes two new mocks were added to review_mapping_controller_spec.rb. &lt;br /&gt;
* ReviewResponseMap is mocked to return 0. This is the number of reviews that a student has done so far.&lt;br /&gt;
* Assignment is mocked to return 1 as number of reviews allowed for the assignment. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when assignment has topics and a topic is selected by reviewer' do&lt;br /&gt;
      it 'assigns reviewer dynamically and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(true)&lt;br /&gt;
        topic = double('SignUpTopic')&lt;br /&gt;
        allow(SignUpTopic).to receive(:find).with('1').and_return(topic)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically).with(participant, topic).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
	allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when assignment does not have topics' do&lt;br /&gt;
      it 'runs another algorithms and redirects to student_review#list page' do&lt;br /&gt;
        allow(assignment).to receive(:topics?).and_return(false)&lt;br /&gt;
        team1 = double('AssignmentTeam')&lt;br /&gt;
        team2 = double('AssignmentTeam')&lt;br /&gt;
        teams = [team1, team2]&lt;br /&gt;
        allow(assignment).to receive(:candidate_assignment_teams_to_review).with(participant).and_return(teams)&lt;br /&gt;
        allow(teams).to receive_message_chain(:to_a, :sample).and_return(team2)&lt;br /&gt;
        allow(assignment).to receive(:assign_reviewer_dynamically_no_topic).with(participant, team2).and_return(true)&lt;br /&gt;
        allow(ReviewResponseMap).to receive(:reviewer_id).with(1).and_return(0)&lt;br /&gt;
        allow(assignment).to receive(:num_reviews_allowed).and_return(1)&lt;br /&gt;
	params = {&lt;br /&gt;
          assignment_id: 1,&lt;br /&gt;
          reviewer_id: 1,&lt;br /&gt;
          topic_id: 1&lt;br /&gt;
        }&lt;br /&gt;
        post :assign_reviewer_dynamically, params&lt;br /&gt;
        expect(response).to redirect_to '/student_review/list?id=1'&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''review_mapping_controller.rb'''&lt;br /&gt;
* A new check was added to find the number of reviews done by the student. Whenever a student ask for review, a new entry is done in the ReviewResponseMap table in the database. &lt;br /&gt;
* The code here checks the number of reviews assigned to the student and then compares it with the maximum number of reviews allowed as per assignment policy. If the student is asking for more reviews than the assignment policy then a flash notice is sent to the student.&lt;br /&gt;
* Also there is a check on the number of outstanding assignment reviews a user can have at a time. The check_outstanding_review keeps a count of the number of reviews in progress as well as the number of reviews currently completed by the user and returns a Boolean value depending upon whether the former is less than the maximum outstanding reviews allowed as per the assignment policy or not. The user can only request for a submission if the check_outstanding_review returns True.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assign_reviewer_dynamically&lt;br /&gt;
    assignment = Assignment.find(params[:assignment_id])&lt;br /&gt;
    reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first &lt;br /&gt;
&lt;br /&gt;
    if params[:i_dont_care].nil? &amp;amp;&amp;amp; params[:topic_id].nil? &amp;amp;&amp;amp; assignment.topics? &amp;amp;&amp;amp; assignment.can_choose_topic_to_review?&lt;br /&gt;
      flash[:error] = &amp;quot;No topic is selected.  Please go back and select a topic.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if is_review_allowed?(assignment, reviewer)&lt;br /&gt;
        if check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
          # begin&lt;br /&gt;
          if assignment.topics? # assignment with topics&lt;br /&gt;
            topic = if params[:topic_id]&lt;br /&gt;
                      SignUpTopic.find(params[:topic_id])&lt;br /&gt;
                    else&lt;br /&gt;
                      assignment.candidate_topics_to_review(reviewer).to_a.sample rescue nil&lt;br /&gt;
                    end&lt;br /&gt;
            if topic.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No topics are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically(reviewer, topic)&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          else # assignment without topic -Yang&lt;br /&gt;
            assignment_teams = assignment.candidate_assignment_teams_to_review(reviewer)&lt;br /&gt;
            assignment_team = assignment_teams.to_a.sample rescue nil&lt;br /&gt;
            if assignment_team.nil?&lt;br /&gt;
              flash[:error] = &amp;quot;No artifacts are available to review at this time. Please try later.&amp;quot;&lt;br /&gt;
            else&lt;br /&gt;
              assignment.assign_reviewer_dynamically_no_topic(reviewer, assignment_team)&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:notice] = &amp;quot;You cannot do more than &amp;quot; + assignment.num_reviews_allowed.to_s + &amp;quot; reviews based on assignment policy&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
    redirect_to controller: 'student_review', action: 'list', id: reviewer.id&lt;br /&gt;
  end&lt;br /&gt;
      &lt;br /&gt;
  def is_review_allowed?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id:  assignment.id)&lt;br /&gt;
    assignment.num_reviews_allowed &amp;gt; @review_mappings.size&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def check_outstanding_reviews?(assignment, reviewer)&lt;br /&gt;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id, reviewed_object_id: assignment.id)&lt;br /&gt;
    @num_reviews_total = @review_mappings.size&lt;br /&gt;
    if @num_reviews_total == 0&lt;br /&gt;
      true&lt;br /&gt;
    else&lt;br /&gt;
      @num_reviews_completed = 0&lt;br /&gt;
      @review_mappings.each do |map|&lt;br /&gt;
        @num_reviews_completed += 1 if !map.response.empty? &amp;amp;&amp;amp; map.response.last.is_submitted&lt;br /&gt;
      end&lt;br /&gt;
      @num_reviews_in_progress = @num_reviews_total - @num_reviews_completed&lt;br /&gt;
      @num_reviews_in_progress &amp;lt; Assignment.max_outstanding_reviews&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below: Instructor Login: username -&amp;gt; instructor6, password -&amp;gt; password&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Use the given link: http://152.46.19.135:8080/&lt;br /&gt;
&lt;br /&gt;
Follow the instructions below to test the implemented changes:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Go to Manage-&amp;gt;Assignments and navigate to assignment name 'test1'. &amp;lt;br/&amp;gt;&lt;br /&gt;
3. Click on add participants. This will give a list of all participants. &amp;lt;br/&amp;gt;&lt;br /&gt;
4. Now click on any student username in order to impersonate. &amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to test1-&amp;gt;other's_work and click on request submission button continuously and wait for the response.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. It would be noted that the request would never exceed the number of submissions mentioned in the assignment policy.&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review Limit enforcement===&lt;br /&gt;
&lt;br /&gt;
===Automated Test Cases For Review pending check===&lt;br /&gt;
&lt;br /&gt;
==Code Coverage==&lt;br /&gt;
22.581%&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
&lt;br /&gt;
Neel Parikh&lt;br /&gt;
&lt;br /&gt;
Steve Menezes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Mentor: Suraj Siddharudh&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
1.[https://github.com/expertiza/expertiza/ Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
2.[https://github.com/dhruvil009/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
3.[http://expertiza.ncsu.edu/ Live Expertiza website]&lt;br /&gt;
&lt;br /&gt;
4.[http://152.46.19.135:8080/ Demo Link]&lt;br /&gt;
&lt;br /&gt;
5.[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_E1956._There_is_no_shortcut_to_get_free_review_points:_Review_Assignment_Bug Project documentation wiki]&lt;br /&gt;
&lt;br /&gt;
6.[https://relishapp.com/rspec Rspec Documentation]&lt;/div&gt;</summary>
		<author><name>Smeneze</name></author>
	</entry>
</feed>