<?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=Dshah4</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=Dshah4"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Dshah4"/>
	<updated>2026-06-18T10:38:59Z</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_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=131198</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=131198"/>
		<updated>2019-12-10T19:27:31Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: Deleted Special Note.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
&lt;br /&gt;
We propose to use `updated_at` in `answer_tags` model for each user to calculate gaps between each tagging action, then use `report_formatter_helper` together with `reports_controller` to generate a separate review view. Filtered gaps would be presented in the form of line-chart, with the `chartjs-ror` gem connecting the `Chart.js` component in front end.&lt;br /&gt;
&lt;br /&gt;
This specific project does not require a design pattern, since it only requires using same type of class in generating same type of objects.&lt;br /&gt;
&lt;br /&gt;
== '''Behavior Diagram for Instructor/TA Diagram ''' ==&lt;br /&gt;
[[File: Behaviorv1.png]]&lt;br /&gt;
[[File: Answer_tag_data_flow.png]]&lt;br /&gt;
&lt;br /&gt;
==  '''Implementation ''' ==&lt;br /&gt;
To create a chart within the front end, we went through the list of already installed gems to avoid enrolling complexity to the existing environment. We did find a gem ''chartjs-ror'' and decide to bring out our implementation with the package.&lt;br /&gt;
&lt;br /&gt;
What ''chartjs'' does is it takes a series of parameter and compile them into different kinds of graphs when getting called in front-end, so this project is divided into several components:&lt;br /&gt;
=== Preparing ===&lt;br /&gt;
&lt;br /&gt;
* Extracting data&lt;br /&gt;
** First we would need to see what data is needed in generating report, we found that:&lt;br /&gt;
*** We would need student information to generate report for the specific student&lt;br /&gt;
*** We would need Assignment information to generate report for assignment (currently the report button is under each assignment)&lt;br /&gt;
*** We would need Review data to see what could be tagged&lt;br /&gt;
*** And we would need tagging information to generate time associated with it&lt;br /&gt;
* Compiling chart parameters&lt;br /&gt;
** This stage requires understanding of the gem, this particular gem takes two piece of information&lt;br /&gt;
*** Data, which include the data to be presented on the chart as well as labels associated with axis's&lt;br /&gt;
*** Options, which captures everything else, including size of chart and range of data to be displayed&lt;br /&gt;
* Calling gem to generate graph&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
* Data&lt;br /&gt;
Data is stored across multiple tables, specifically if we need to gather Assignment, review, tagging, and user data, we would need at least Tag_prompt_deployment and answer_tags table. The report_formatter_helper file (which is in charge of generating reports) calls the assignment_tagging_progress function while generating rows (taggers) within a report, so we added a function within to calculate time intervals of everyone's tagging actions：&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def assignment_tagging_progress&lt;br /&gt;
    teams = Team.where(parent_id: self.assignment_id)&lt;br /&gt;
    questions = Question.where(questionnaire_id: self.questionnaire.id, type: self.question_type)&lt;br /&gt;
    questions_ids = questions.map(&amp;amp;:id)&lt;br /&gt;
    user_answer_tagging = []&lt;br /&gt;
    unless teams.empty? or questions.empty?&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        if self.assignment.varying_rubrics_by_round?&lt;br /&gt;
          responses = []&lt;br /&gt;
          for round in 1..self.assignment.rounds_of_reviews&lt;br /&gt;
            responses += ReviewResponseMap.get_responses_for_team_round(team, round)&lt;br /&gt;
          end&lt;br /&gt;
        else&lt;br /&gt;
          responses = ResponseMap.get_assessments_for(team)&lt;br /&gt;
        end&lt;br /&gt;
        responses_ids = responses.map(&amp;amp;:id)&lt;br /&gt;
        answers = Answer.where(question_id: questions_ids, response_id: responses_ids)&lt;br /&gt;
        answers = answers.where(&amp;quot;length(comments) &amp;gt; ?&amp;quot;, self.answer_length_threshold.to_s) unless self.answer_length_threshold.nil?&lt;br /&gt;
        answers_ids = answers.map(&amp;amp;:id)&lt;br /&gt;
        users = TeamsUser.where(team_id: team.id).map(&amp;amp;:user)&lt;br /&gt;
        users.each do |user|&lt;br /&gt;
          tags = AnswerTag.where(tag_prompt_deployment_id: self.id, user_id: user.id, answer_id: answers_ids)&lt;br /&gt;
          tagged_answers_ids = tags.map(&amp;amp;:answer_id)&lt;br /&gt;
&lt;br /&gt;
          # E1993 Track_Time_Between_Successive_Tag_Assignments&lt;br /&gt;
          # Extract time where each tag is generated / modified&lt;br /&gt;
          tag_updated_times = tags.map(&amp;amp;:updated_at)&lt;br /&gt;
          # tag_updated_times.sort_by{|time_string| Time.parse(time_string)}.reverse&lt;br /&gt;
          tag_updated_times.sort_by{|time_string| time_string}.reverse&lt;br /&gt;
          number_of_updated_time = tag_updated_times.length&lt;br /&gt;
          tag_update_intervals = []&lt;br /&gt;
          for i in 1..(number_of_updated_time -1) do&lt;br /&gt;
            tag_update_intervals.append(tag_updated_times[i] - tag_updated_times[i-1])&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          percentage = answers.count == 0 ? &amp;quot;-&amp;quot; : format(&amp;quot;%.1f&amp;quot;, tags.count.to_f / answers.count * 100)&lt;br /&gt;
          not_tagged_answers = answers.where.not(id: tagged_answers_ids)&lt;br /&gt;
&lt;br /&gt;
          # E1993 Adding tag_update_intervals as information that should be passed&lt;br /&gt;
          answer_tagging = VmUserAnswerTagging.new(user, percentage, tags.count, not_tagged_answers.count, answers.count, tag_update_intervals)&lt;br /&gt;
          user_answer_tagging.append(answer_tagging)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    user_answer_tagging&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We extracted each student's tagging information of reviews towards a specific assignment, sorted the tagging action in order and calculated intervals between each action, this information is passed back to the report_formatter_helper in a VmUserAnswerTagging data structure, so we added a new field as well as reader and writer within it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class VmUserAnswerTagging&lt;br /&gt;
  def initialize(user, percentage, no_tagged, no_not_tagged, no_tagable, tag_update_intervals)&lt;br /&gt;
    @user = user&lt;br /&gt;
    @percentage = percentage&lt;br /&gt;
    @no_tagged = no_tagged&lt;br /&gt;
    @no_not_tagged = no_not_tagged&lt;br /&gt;
    @no_tagable = no_tagable&lt;br /&gt;
    # E1993 Adding interval to be passed for graph plotting&lt;br /&gt;
    @tag_update_intervals = tag_update_intervals&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  attr_accessor :user&lt;br /&gt;
  attr_accessor :percentage&lt;br /&gt;
  attr_accessor :no_tagged&lt;br /&gt;
  attr_accessor :no_not_tagged&lt;br /&gt;
  attr_accessor :no_tagable&lt;br /&gt;
  attr_accessor :tag_update_intervals&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
While from the front-end, the _answer_tagging_report partial who's in charge of generating report table would call the user_summery_report function within the report_formatter_helper to generate information for each user, we made sure that the interval information is passed to it and correctly evaluated:&lt;br /&gt;
Helper:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def user_summary_report(line)&lt;br /&gt;
    if @user_tagging_report[line.user.name].nil?&lt;br /&gt;
      # E1993 Adding extra filed of interval array into data structure&lt;br /&gt;
&lt;br /&gt;
      @user_tagging_report[line.user.name] = VmUserAnswerTagging.new(line.user, line.percentage, line.no_tagged, line.no_not_tagged, line.no_tagable, line.tag_update_intervals)&lt;br /&gt;
    else&lt;br /&gt;
      @user_tagging_report[line.user.name].no_tagged += line.no_tagged&lt;br /&gt;
      @user_tagging_report[line.user.name].no_not_tagged += line.no_not_tagged&lt;br /&gt;
      @user_tagging_report[line.user.name].no_tagable += line.no_tagable&lt;br /&gt;
      @user_tagging_report[line.user.name].percentage = calculate_formatted_percentage(line)&lt;br /&gt;
      @user_tagging_report[line.user.name].tag_update_intervals = line.tag_update_intervals&lt;br /&gt;
      # E1993 interval array doesn't gets updated by new records in TagPromptDeployment, it's once computed and final (when you generate a new report)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Front end:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% report_lines.each do |report_line| %&amp;gt;&lt;br /&gt;
                &amp;lt;tr&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.user.name(session[:ip]) %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.user.fullname(session[:ip]) %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.percentage.to_s %&amp;gt;%&amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.no_tagged.to_s %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.no_not_tagged.to_s %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- E1993 Call chart plotting function from review_mapping_helper --&amp;gt;&lt;br /&gt;
                  &amp;lt;td align='left'&amp;gt;&lt;br /&gt;
                    &amp;lt;%= display_tagging_interval_chart(report_line.tag_update_intervals) %&amp;gt;&lt;br /&gt;
                  &amp;lt;/td&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- &amp;lt;td&amp;gt;&amp;lt;%= report_line.tag_update_intervals.to_s %&amp;gt;&amp;lt;/td&amp;gt; --&amp;gt;&lt;br /&gt;
                  &amp;lt;td&amp;gt;&amp;lt;%= report_line.no_tagable %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
                &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Parameters for the chart gem&lt;br /&gt;
The other big component is to generate information for the gem to use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def display_tagging_interval_chart(intervals)&lt;br /&gt;
    # if someone did not do any tagging in 30 seconds, then ignore this interval&lt;br /&gt;
    threshold = 30&lt;br /&gt;
    intervals = intervals.select{|v| v &amp;lt; threshold}&lt;br /&gt;
    if not intervals.empty?&lt;br /&gt;
      interval_mean = intervals.reduce(:+) / intervals.size.to_f&lt;br /&gt;
    end&lt;br /&gt;
    data = {&lt;br /&gt;
      labels: [*1..intervals.length],&lt;br /&gt;
      datasets: [&lt;br /&gt;
        {&lt;br /&gt;
          backgroundColor: &amp;quot;rgba(255,99,132,0.8)&amp;quot;,&lt;br /&gt;
          data: intervals,&lt;br /&gt;
          label: &amp;quot;time intervals&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        if not intervals.empty?&lt;br /&gt;
          {&lt;br /&gt;
            data: Array.new(intervals.length, interval_mean),&lt;br /&gt;
            label: &amp;quot;Mean time spent&amp;quot;&lt;br /&gt;
          }&lt;br /&gt;
        end&lt;br /&gt;
      ]&lt;br /&gt;
    }&lt;br /&gt;
    options = {&lt;br /&gt;
      width: &amp;quot;200&amp;quot;,&lt;br /&gt;
      height: &amp;quot;125&amp;quot;,&lt;br /&gt;
      scales: {&lt;br /&gt;
        yAxes: [{&lt;br /&gt;
          stacked: false,&lt;br /&gt;
          ticks: {&lt;br /&gt;
                beginAtZero: true&lt;br /&gt;
            }&lt;br /&gt;
        }],&lt;br /&gt;
        xAxes: [{&lt;br /&gt;
          stacked: false&lt;br /&gt;
        }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    line_chart data, options&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this step, we filtered out intervals that are larger than 30 seconds, because as we were testing this function, we found having more than 30 second's interval in the graph would affect the scale of it and making smaller time intervals visually indifferent to viewers. To create a visual effect that is similar across all users, we set the y axis to always start from 0.&lt;br /&gt;
Besides the basics, we've also plotted a average time spent on each tag (with abnormalities filtered) to provide additional visual cue for the teaching team.&lt;br /&gt;
* Plotting graph&lt;br /&gt;
As could be seen in the code block above, we called the function as well as the implementation from the gem in our front end and plotted interval graphs for each student tagger:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= display_tagging_interval_chart(report_line.tag_update_intervals) %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing ===&lt;br /&gt;
Automated testing is not available for this specific project because:&lt;br /&gt;
* To test the review tagging interval one has to&lt;br /&gt;
** Create courses&lt;br /&gt;
** Create assignment&lt;br /&gt;
** Setup assignment dues dates as well as reviews and review tagging rubrics&lt;br /&gt;
** Enroll more than 2 students to the assignment&lt;br /&gt;
** Let students finish assignment&lt;br /&gt;
** Change due date to the past&lt;br /&gt;
** Have students review each other's work&lt;br /&gt;
** Change review due date to the past&lt;br /&gt;
** Have students tag each other's work, with time intervals (pause or sleep between each review comment, having at lease one interval longer than 3 minutes)&lt;br /&gt;
** Generate review tagging report&lt;br /&gt;
** Generate review tagging time interval line chart&lt;br /&gt;
&lt;br /&gt;
And you cannot verify what's on the line chart with Rspec since it's a image, we wouldn't be able to see if the interval greater than 3 minutes is filtered&lt;br /&gt;
&lt;br /&gt;
Each time this script runs, it would take minutes to test, let along having the intervals, and each time Expertiza runs a system level testing, this script would be included, adding who knows how long to the already too long testing process.&lt;br /&gt;
&lt;br /&gt;
Thus we propose to verify this function in non automated ways&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
[[File:Tagging1993.png]]&lt;br /&gt;
As described, we tested this feature in the following sequence:&lt;br /&gt;
* As instructor &lt;br /&gt;
** Create courses&lt;br /&gt;
** Create assignment&lt;br /&gt;
** Setup assignment dues dates as well as reviews and review tagging rubrics&lt;br /&gt;
** Enroll more than 2 students to the assignment&lt;br /&gt;
* As Student&lt;br /&gt;
** Finish assignment&lt;br /&gt;
* As instructor &lt;br /&gt;
** Change due date to the past&lt;br /&gt;
* As Student&lt;br /&gt;
** Review each other's work&lt;br /&gt;
* As instructor &lt;br /&gt;
** Change review due date to the past&lt;br /&gt;
* As Student&lt;br /&gt;
** Have students tag each other's work, with time intervals both over and under 30 seconds&lt;br /&gt;
* As instructor &lt;br /&gt;
** Generate review tagging report&lt;br /&gt;
** Generate review tagging time interval line chart&lt;br /&gt;
&lt;br /&gt;
The result is shown in the graph above, manual testing showed that intervals greater than threshold did get filtered and students without any tagging activities are dropped in graph creation.&lt;br /&gt;
&lt;br /&gt;
=== Note ===&lt;br /&gt;
We did try to auto mate this process, but is stopped in the last step while validating the graph created, as the function is wrapped in the gem and cannot be accessed from RSepc:&lt;br /&gt;
[[File:1993canvastest.png]]&lt;br /&gt;
&lt;br /&gt;
You may also want to see our testing video [[https://youtu.be/YxR9sitpZcs here]]&lt;br /&gt;
&lt;br /&gt;
We'd also like to suggest a refactor of the code, since some old functions are spread from model to controller to view and parts of it is been run for unnecessary times, too much data is getting passed back and forth including data that shouldn't be given to the view.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Yunkai &amp;quot;Kai&amp;quot; Xiao (yxiao28@ncsu.edu) Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
#[https://github.com/Galactis/expertiza Team Github]&lt;br /&gt;
#[https://youtu.be/YxR9sitpZcs Test video]&lt;br /&gt;
#[http://152.46.18.176:8080/ Live system on VCL]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Behaviorv1.png&amp;diff=129410</id>
		<title>File:Behaviorv1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Behaviorv1.png&amp;diff=129410"/>
		<updated>2019-11-15T23:50:45Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129409</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129409"/>
		<updated>2019-11-15T23:49:58Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
&lt;br /&gt;
== '''Behavior Diagram for Instructor/TA Diagram ''' ==&lt;br /&gt;
[[File: Behaviorv1.png|frame|centre]]&lt;br /&gt;
== ''' Flow Chart ''' ==&lt;br /&gt;
[[File: Flowv1.png|frame|centre]]&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
We have proposed to use Rspec for testing the functionality of our project. Automated tests are carried out to see whether for each tagged review is the time getting saved. The main functionality to be tested is that is the controller saving the time between consecutive review taggings. This time is then saved to the database which is later used for analysis whether the tagging of the review was done properly or not. This is analysis is beyond the scope of our project. We also propose to develop certain use cases which include edge cases  like if a user leaves the tagging process for sometime(like half and hour) and comes back to resume the tagging process. This is one of the cases which needs to be tested apart from the main test which is to see whether the time between consecutive reviews is getting saved in the database.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129408</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129408"/>
		<updated>2019-11-15T23:45:45Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* UML Diagram  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
&lt;br /&gt;
== '''Behavior Diagram for Instructor/TA Diagram ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Flow Chart ''' ==&lt;br /&gt;
[[File: Flowv1.png|frame|centre]]&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
We have proposed to use Rspec for testing the functionality of our project. Automated tests are carried out to see whether for each tagged review is the time getting saved. The main functionality to be tested is that is the controller saving the time between consecutive review taggings. This time is then saved to the database which is later used for analysis whether the tagging of the review was done properly or not. This is analysis is beyond the scope of our project. We also propose to develop certain use cases which include edge cases  like if a user leaves the tagging process for sometime(like half and hour) and comes back to resume the tagging process. This is one of the cases which needs to be tested apart from the main test which is to see whether the time between consecutive reviews is getting saved in the database.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129407</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=129407"/>
		<updated>2019-11-15T23:24:37Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /*  Flow Chart  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
&lt;br /&gt;
== '''UML Diagram ''' ==&lt;br /&gt;
== ''' Flow Chart ''' ==&lt;br /&gt;
[[File: Flowv1.png|frame|centre]]&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
We have proposed to use Rspec for testing the functionality of our project. Automated tests are carried out to see whether for each tagged review is the time getting saved. The main functionality to be tested is that is the controller saving the time between consecutive review taggings. This time is then saved to the database which is later used for analysis whether the tagging of the review was done properly or not. This is analysis is beyond the scope of our project. We also propose to develop certain use cases which include edge cases  like if a user leaves the tagging process for sometime(like half and hour) and comes back to resume the tagging process. This is one of the cases which needs to be tested apart from the main test which is to see whether the time between consecutive reviews is getting saved in the database.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128138</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128138"/>
		<updated>2019-11-10T18:11:23Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
&lt;br /&gt;
== ''' Flow Chart ''' ==&lt;br /&gt;
[[File: Flowv1.png|frame|centre]]&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
We have proposed to use Rspec for testing the functionality of our project. Automated tests are carried out to see whether for each tagged review is the time getting saved. The main functionality to be tested is that is the controller saving the time between consecutive review taggings. This time is then saved to the database which is later used for analysis whether the tagging of the review was done properly or not. This is analysis is beyond the scope of our project. We also propose to develop certain use cases which include edge cases  like if a user leaves the tagging process for sometime(like half and hour) and comes back to resume the tagging process. This is one of the cases which needs to be tested apart from the main test which is to see whether the time between consecutive reviews is getting saved in the database.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128137</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128137"/>
		<updated>2019-11-10T18:10:45Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /*  Proposed Approach  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
== ''' Project Description ''' ==&lt;br /&gt;
CSC/ECE 517 classes have helped us by “tagging” review comments over the past two years.  This is important for us, because it is how we get the “labels” that we need to train our machine-learning models to recognize review comments that detect problems, make suggestions, or that are considered helpful by the authors.  Our goal is to help reviewers by telling them how helpful their review will be before they submit it.&lt;br /&gt;
&lt;br /&gt;
Tagging a review comment usually means sliding 4 sliders to either side, depending on which of four attributes it has.  But can we trust the tags that students assign?  In past semesters, our checks have revealed that some students appear not to be paying much attention to the tags they assign: the tags seem to be unrelated to the characteristic they are supposed to rate, or they follow a set pattern, like repeated patterns of one tag yes, then one tag no. &lt;br /&gt;
Studies on other kinds of “crowdwork” have shown that the time spent between assigning each label indicates how careful the labeling (“tagging”) has been.  We believe that students who tag “too fast” are probably not paying enough attention, and want to set their tags aside to be examined by course staff and researchers..&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
We would like to modify the model reflecting review tagging actions (answer_tag entity), adding new fields to track the time interval between each tagging action, as well as revise the controller to implement this interval tracking functionality. A few things to take into consideration:&lt;br /&gt;
A user might not tag reviews in sequence, they may jump through them and only tag the one he or she is interested&lt;br /&gt;
When annotator tags 1 rubric of all reviews then move onto the next, their behavior will be much different compared with those who tags 4 rubrics of each review.&lt;br /&gt;
Sometimes an annotator could take long breaks to refresh and relax, some even take days off, these irregularities needs to be handled.&lt;br /&gt;
A user may slide the slider back and forth for a number of times, then go to the next slider; they may also come back and revise a tag they made, these needs to be treated differently.&lt;br /&gt;
The first step would be to examine the literature on measuring the reliability of crowdwork, and determine appropriate measures to apply to review tagging.  The next step would be to code these metrics and call them from report_formatter_helper.rb, so that they will be available to the course staff when it grades answer tagging.  There should also be a threshold set so that any record in the answer_tags table created by a user with suspect metrics would be marked as unreliable (you can add a field for that to the answer_tags table).&lt;br /&gt;
[[File: Flowv1.png|frame|centre]]&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
We have proposed to use Rspec for testing the functionality of our project. Automated tests are carried out to see whether for each tagged review is the time getting saved. The main functionality to be tested is that is the controller saving the time between consecutive review taggings. This time is then saved to the database which is later used for analysis whether the tagging of the review was done properly or not. This is analysis is beyond the scope of our project. We also propose to develop certain use cases which include edge cases  like if a user leaves the tagging process for sometime(like half and hour) and comes back to resume the tagging process. This is one of the cases which needs to be tested apart from the main test which is to see whether the time between consecutive reviews is getting saved in the database.&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai(adesai5@ncsu.edu)&lt;br /&gt;
#Dhruvil Shah(dshah4@ncsu.edu)&lt;br /&gt;
#Jeel Sukhadia(jsukhad@ncsu.edu&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao(yxia28@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain(mjain6@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowv1.png&amp;diff=128136</id>
		<title>File:Flowv1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowv1.png&amp;diff=128136"/>
		<updated>2019-11-10T18:09:08Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: Flowchartv1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Flowchartv1&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128129</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128129"/>
		<updated>2019-11-10T17:12:35Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
So far, Expertiza does not have any such feature. However, three teams have already worked on this in the past but their builds were not merged due to some problems.&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/875 E1705] identified how to track the active time of windows opened from the submitted links. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1124 E1791] provided detailed insights on how they planned to track time taken by a student in viewing a submission and possible edge cases. Further, they also implemented popups and figured out a way to open downloadable files. However, the details are rendered in a not-so-friendly manner and hence it was not merged. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2017/E1791._Track_the_time_that_students_look_at_the_other_submissions_-_logging_improvement Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1309 E1872] tried to solve this by incorporating the statistics in the review reports page, but their UI made the page cluttered and not friendly. Further, it was hard to identify which statistic belonged to which review, and there were almost no tests. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018/E1872_Track_Time_Students_Look_At_Other_Submissions Wiki])&lt;br /&gt;
&lt;br /&gt;
== ''' Problem Statement ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Proposed Approach ''' ==&lt;br /&gt;
&lt;br /&gt;
==  '''Proposed Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
&lt;br /&gt;
=== Coverage ===&lt;br /&gt;
&lt;br /&gt;
=== Manual UI Testing ===&lt;br /&gt;
&lt;br /&gt;
== ''' Our Work ''' ==&lt;br /&gt;
The code we created can be found below.&lt;br /&gt;
*[https://github.com/rohanpillai20/expertiza GitHub Repository]&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1607 Pull Request]&lt;br /&gt;
*[http:// Deployed URL] (Currently, Does not Exist)&lt;br /&gt;
&lt;br /&gt;
The project could be run locally by cloning the [https://github.com/rohanpillai20/expertiza GitHub Repository] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai&lt;br /&gt;
#Dhruvil Shah&lt;br /&gt;
#Jeel Sukhadia&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain &lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128126</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128126"/>
		<updated>2019-11-10T17:03:56Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /*  Team Information  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
So far, Expertiza does not have any such feature. However, three teams have already worked on this in the past but their builds were not merged due to some problems.&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/875 E1705] identified how to track the active time of windows opened from the submitted links. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1124 E1791] provided detailed insights on how they planned to track time taken by a student in viewing a submission and possible edge cases. Further, they also implemented popups and figured out a way to open downloadable files. However, the details are rendered in a not-so-friendly manner and hence it was not merged. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2017/E1791._Track_the_time_that_students_look_at_the_other_submissions_-_logging_improvement Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1309 E1872] tried to solve this by incorporating the statistics in the review reports page, but their UI made the page cluttered and not friendly. Further, it was hard to identify which statistic belonged to which review, and there were almost no tests. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018/E1872_Track_Time_Students_Look_At_Other_Submissions Wiki])&lt;br /&gt;
&lt;br /&gt;
== ''' Problem Statement ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Solutions ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Code Changes ''' ==&lt;br /&gt;
&lt;br /&gt;
==  ''' Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
&lt;br /&gt;
=== Coverage ===&lt;br /&gt;
&lt;br /&gt;
=== Manual UI Testing ===&lt;br /&gt;
&lt;br /&gt;
== ''' Our Work ''' ==&lt;br /&gt;
The code we created can be found below.&lt;br /&gt;
*[https://github.com/rohanpillai20/expertiza GitHub Repository]&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1607 Pull Request]&lt;br /&gt;
*[http:// Deployed URL] (Currently, Does not Exist)&lt;br /&gt;
&lt;br /&gt;
The project could be run locally by cloning the [https://github.com/rohanpillai20/expertiza GitHub Repository] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Anmol Desai&lt;br /&gt;
#Dhruvil Shah&lt;br /&gt;
#Jeel Sukhadia&lt;br /&gt;
#YunKai &amp;quot;Kai&amp;quot; Xiao&lt;br /&gt;
&lt;br /&gt;
Mentor: Mohit Jain &lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128125</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128125"/>
		<updated>2019-11-10T17:02:04Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ''' Introduction ''' ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] project takes advantage of peer-review among students to allow them to learn from each other. Tracking the time that a student spends on each submitted resources is meaningful to instructors to study and improve the teaching experience. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission (e.g. GitHub code / deployed application), which makes it difficult for the system to track the time that the reviewers spend on the submissions.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
So far, Expertiza does not have any such feature. However, three teams have already worked on this in the past but their builds were not merged due to some problems.&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/875 E1705] identified how to track the active time of windows opened from the submitted links. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1124 E1791] provided detailed insights on how they planned to track time taken by a student in viewing a submission and possible edge cases. Further, they also implemented popups and figured out a way to open downloadable files. However, the details are rendered in a not-so-friendly manner and hence it was not merged. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2017/E1791._Track_the_time_that_students_look_at_the_other_submissions_-_logging_improvement Wiki])&lt;br /&gt;
#[https://github.com/expertiza/expertiza/pull/1309 E1872] tried to solve this by incorporating the statistics in the review reports page, but their UI made the page cluttered and not friendly. Further, it was hard to identify which statistic belonged to which review, and there were almost no tests. ([http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2018/E1872_Track_Time_Students_Look_At_Other_Submissions Wiki])&lt;br /&gt;
&lt;br /&gt;
== ''' Problem Statement ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Solutions ''' ==&lt;br /&gt;
&lt;br /&gt;
== ''' Code Changes ''' ==&lt;br /&gt;
&lt;br /&gt;
==  ''' Test Plan ''' ==&lt;br /&gt;
=== Automated Testing Using Rspec ===&lt;br /&gt;
&lt;br /&gt;
=== Coverage ===&lt;br /&gt;
&lt;br /&gt;
=== Manual UI Testing ===&lt;br /&gt;
&lt;br /&gt;
== ''' Our Work ''' ==&lt;br /&gt;
The code we created can be found below.&lt;br /&gt;
*[https://github.com/rohanpillai20/expertiza GitHub Repository]&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1607 Pull Request]&lt;br /&gt;
*[http:// Deployed URL] (Currently, Does not Exist)&lt;br /&gt;
&lt;br /&gt;
The project could be run locally by cloning the [https://github.com/rohanpillai20/expertiza GitHub Repository] and then running the following commands sequentially.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ''' Team Information ''' ==&lt;br /&gt;
#Dylan Spruill (drspruil)&lt;br /&gt;
#Forrest Devita (fcdevita)&lt;br /&gt;
#Rohan Pillai (rspillai)&lt;br /&gt;
#Shalin Rathi (sjrathi)&lt;br /&gt;
&lt;br /&gt;
Mentor: Akanksha Mohan (amohan7)&lt;br /&gt;
&amp;lt;br&amp;gt;Professor: Dr. Edward F. Gehringer (efg)&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://relishapp.com/rspec RSpec Documentation]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128124</id>
		<title>CSC/ECE 517 Fall 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128124"/>
		<updated>2019-11-10T16:59:03Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2019 - Project E1947. Refactor quiz_questionnaire_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1965. Review report should link to the usual view for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1972. OSS project J. Skellington: Accessing Assignment Rubrics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1961. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1971. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1953. Tagging report for student]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1955.Write  unit tests for student_task.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1954. Auto-generate submission directory names based on assignment names]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1958. Two issues related to assignment management]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1948. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1959. Intelligent copying of assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1968. Fixes for adding members to teams]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1969. Fixes for reviews not being available]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1951. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1957. Time travel Not Allowed..!!! Restrict TAs’ ability to change their own grade + limit file-size upload]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1963. Changing assignment participant role]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1941. Issues related to topic deadlines]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1966. Tabbed_reviews partial file refactor for displaying the alternate view of reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1962. Email notification upon account creation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1967. Fix glitches in author feedback]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1960. Create new late policy successfully and fixing &amp;quot;Back&amp;quot; link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1939. OSS Project Juniper: Bookmark enhancements]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1950. Support Asynchronous Web Assembly Compilation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1951. Implement missing OffscreenCanvas APIs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1940. Improving email notification]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1942. Refactor stage deadlines in assignment.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1952. Missing DOM features project]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1945. Refactor users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1964. Export review scores for projects]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1949. Write Unit Tests for Importing assignment participants and import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1944. Refactor review mapping controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1982. Regulate changing of rubrics while projects are in progress]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1989. Track the time students look at other submissions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1990. Integrate suggestion detection algorithm]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1995. Tests for email functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1979. Completion/Progress view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1995. Weights in grade calculation]]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128123</id>
		<title>CSC/ECE 517 Fall 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019&amp;diff=128123"/>
		<updated>2019-11-10T16:56:35Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2019 - Project E1947. Refactor quiz_questionnaire_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1965. Review report should link to the usual view for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1972. OSS project J. Skellington: Accessing Assignment Rubrics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1961. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1971. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1953. Tagging report for student]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1955.Write  unit tests for student_task.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1954. Auto-generate submission directory names based on assignment names]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1958. Two issues related to assignment management]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1948. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1959. Intelligent copying of assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1968. Fixes for adding members to teams]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1969. Fixes for reviews not being available]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1951. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1957. Time travel Not Allowed..!!! Restrict TAs’ ability to change their own grade + limit file-size upload]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1963. Changing assignment participant role]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1941. Issues related to topic deadlines]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1966. Tabbed_reviews partial file refactor for displaying the alternate view of reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1962. Email notification upon account creation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1967. Fix glitches in author feedback]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1960. Create new late policy successfully and fixing &amp;quot;Back&amp;quot; link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1939. OSS Project Juniper: Bookmark enhancements]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1950. Support Asynchronous Web Assembly Compilation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1938. OSS project Duke Blue: Fix import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1951. Implement missing OffscreenCanvas APIs]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1940. Improving email notification]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1956. There is no shortcut to get free review points: Review Assignment Bug]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1942. Refactor stage deadlines in assignment.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - M1952. Missing DOM features project]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1945. Refactor users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1964. Export review scores for projects]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1949. Write Unit Tests for Importing assignment participants and import glitches]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1944. Refactor review mapping controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1982. Regulate changing of rubrics while projects are in progress]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1989. Track the time students look at other submissions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1990. Integrate suggestion detection algorithm]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1995. Tests for email functionality]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1979. Completion/Progress view]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1995. Weights in grade calculation]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments]]&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128122</id>
		<title>CSC/ECE 517 Fall 2019 - E1993 Track Time Between Successive Tag Assignments</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1993_Track_Time_Between_Successive_Tag_Assignments&amp;diff=128122"/>
		<updated>2019-11-10T16:55:12Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: Created page with &amp;quot;Hello&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello&lt;/div&gt;</summary>
		<author><name>Dshah4</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=127955</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=127955"/>
		<updated>2019-11-07T03:50:42Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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;
==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:Pro.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>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pro.png&amp;diff=127953</id>
		<title>File:Pro.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pro.png&amp;diff=127953"/>
		<updated>2019-11-07T03:50:10Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</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=127912</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=127912"/>
		<updated>2019-11-07T03:21:55Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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;
==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 zoom.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>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Process_zoom.png&amp;diff=127911</id>
		<title>File:Process zoom.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Process_zoom.png&amp;diff=127911"/>
		<updated>2019-11-07T03:21:46Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</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=127896</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=127896"/>
		<updated>2019-11-07T03:14:31Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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>Dshah4</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=127892</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=127892"/>
		<updated>2019-11-07T03:13:18Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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;
&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>Dshah4</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=127882</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=127882"/>
		<updated>2019-11-07T03:08:44Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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]]&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>Dshah4</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=127881</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=127881"/>
		<updated>2019-11-07T03:08:21Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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]][[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>Dshah4</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=127879</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=127879"/>
		<updated>2019-11-07T03:07:58Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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]]&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>Dshah4</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=127877</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=127877"/>
		<updated>2019-11-07T03:07:38Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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]][[File:Issue.png|frame]]&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>Dshah4</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=127872</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=127872"/>
		<updated>2019-11-07T03:06:19Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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;
&amp;lt;div style=&amp;quot;display: inline; float: left;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Process resize.png|frame]][[File:Issue.png|frame]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&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>Dshah4</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=127868</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=127868"/>
		<updated>2019-11-07T03:05:41Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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;
&amp;lt;div style=&amp;quot;display: inline; float: left;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Process resize.png|frame|center]][[File:Issue.png|frame|center]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&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>Dshah4</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=127867</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=127867"/>
		<updated>2019-11-07T03:05:21Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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;
&amp;lt;div style=&amp;quot;display: inline; float: left;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Process resize.png|frame|left]][[File:Issue.png|frame|left]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&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>Dshah4</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=127854</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=127854"/>
		<updated>2019-11-07T03:01:14Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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: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>Dshah4</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=127853</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=127853"/>
		<updated>2019-11-07T03:00:17Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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|frame|left|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>Dshah4</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=127851</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=127851"/>
		<updated>2019-11-07T02:59:55Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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|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 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>Dshah4</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=127844</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=127844"/>
		<updated>2019-11-07T02:56:49Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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: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>Dshah4</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=127843</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=127843"/>
		<updated>2019-11-07T02:56:23Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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 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:Process resize.png]][[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>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Process_resize.png&amp;diff=127840</id>
		<title>File:Process resize.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Process_resize.png&amp;diff=127840"/>
		<updated>2019-11-07T02:54:49Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</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=127833</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=127833"/>
		<updated>2019-11-07T02:48:32Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: Grammar Check&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_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;
&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>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Issue.png&amp;diff=127826</id>
		<title>File:Issue.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Issue.png&amp;diff=127826"/>
		<updated>2019-11-07T02:38:43Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Process.png&amp;diff=127825</id>
		<title>File:Process.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Process.png&amp;diff=127825"/>
		<updated>2019-11-07T02:38:24Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dshah4</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=127809</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=127809"/>
		<updated>2019-11-07T02:29:51Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Background */&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>Dshah4</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=127804</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=127804"/>
		<updated>2019-11-07T02:29:05Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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;
==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>Dshah4</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=127800</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=127800"/>
		<updated>2019-11-07T02:26:14Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* 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;
==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>Dshah4</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=127777</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=127777"/>
		<updated>2019-11-07T02:04:59Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review Limit enforcement */&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 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>Dshah4</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=127775</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=127775"/>
		<updated>2019-11-07T02:04:32Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review pending check */&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. 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>Dshah4</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=127771</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=127771"/>
		<updated>2019-11-07T02:03:58Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review Limit enforcement */&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;
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>Dshah4</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=127769</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=127769"/>
		<updated>2019-11-07T02:02:12Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review pending check */&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;
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. 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;
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>Dshah4</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=127766</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=127766"/>
		<updated>2019-11-07T02:00:27Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review Limit enforcement */&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;
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. 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>Dshah4</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=127757</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=127757"/>
		<updated>2019-11-07T01:58:00Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review Limit enforcement */&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;
::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>Dshah4</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=127756</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=127756"/>
		<updated>2019-11-07T01:57:46Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Automated Test Cases For Review Limit enforcement */&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;
::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;
&lt;br /&gt;
::1. 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>Dshah4</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=127734</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=127734"/>
		<updated>2019-11-07T01:38:57Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Code Coverage */&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;
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>Dshah4</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=127650</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=127650"/>
		<updated>2019-11-07T00:43:50Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: /* Team Information */&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;
This page provides a description of the Expertiza based OSS project. &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;
===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;
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;
&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;
&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;
&amp;lt;pre&amp;gt;&lt;br /&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;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id)&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 @review_mappings.size &amp;gt;= assignment.num_reviews_allowed&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;
        &lt;br /&gt;
      else&lt;br /&gt;
&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;
&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # rescue Exception =&amp;gt; e&lt;br /&gt;
    #   flash[:error] = (e.nil?) ? $! : e&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;
&amp;lt;/pre&amp;gt;&lt;br /&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;
&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>Dshah4</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=127646</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=127646"/>
		<updated>2019-11-07T00:43:14Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: &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;
This page provides a description of the Expertiza based OSS project. &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;
===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;
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;
&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;
&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;
&amp;lt;pre&amp;gt;&lt;br /&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;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id)&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 @review_mappings.size &amp;gt;= assignment.num_reviews_allowed&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;
        &lt;br /&gt;
      else&lt;br /&gt;
&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;
&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # rescue Exception =&amp;gt; e&lt;br /&gt;
    #   flash[:error] = (e.nil?) ? $! : e&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;
&amp;lt;/pre&amp;gt;&lt;br /&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;
&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
Dhruvil Shah&lt;br /&gt;
Neel Parikh&lt;br /&gt;
Steve Menezes&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>Dshah4</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=127378</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=127378"/>
		<updated>2019-11-06T20:50:27Z</updated>

		<summary type="html">&lt;p&gt;Dshah4: Restructured. Added Automated testing section.&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;
This page provides a description of the Expertiza based OSS project. &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;
===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;
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;
&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;
&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;
&amp;lt;pre&amp;gt;&lt;br /&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;
    @review_mappings = ReviewResponseMap.where(reviewer_id: reviewer.id)&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 @review_mappings.size &amp;gt;= assignment.num_reviews_allowed&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;
        &lt;br /&gt;
      else&lt;br /&gt;
&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;
&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # rescue Exception =&amp;gt; e&lt;br /&gt;
    #   flash[:error] = (e.nil?) ? $! : e&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;
&amp;lt;/pre&amp;gt;&lt;br /&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;
==Scope for Future Improvement==&lt;br /&gt;
1. To Think&lt;/div&gt;</summary>
		<author><name>Dshah4</name></author>
	</entry>
</feed>