<?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=Ajshipma</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=Ajshipma"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ajshipma"/>
	<updated>2026-07-12T22:28:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=142735</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=142735"/>
		<updated>2021-12-08T16:12:26Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* Demonstration Videos */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing E2147]with the existing [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types E2026]. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing E2147(Role based reviewing)]: The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types E2026(Specialized rubrics for different topics)]: The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the functionality of duties_controller.&lt;br /&gt;
&lt;br /&gt;
The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit. We then run the arbitrary code that is needed before each test in this context. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin. We check if the action is allowed by stubbing the current user to admin. We then verify if the controller is able to perform the action for the current admin user&lt;br /&gt;
 &lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor of the current assignment. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course. We check if the action is allowed by stubbing the current user to TA. We then verify if the controller is able to perform the action for the current TA user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new(create) in the arbitrary code that runs before each test.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update. We check if the controller can perform the action 'new' which we mocked in the before each step.&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also added few tests to test creation/edit/deletion of a duty. &lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
We write a test to check if the right page is rendered after successful creation and saving of a new duty in the database. We do this by stubbing the duty object to get saved in the database, and then perform the create action. We also check if the flash message rendered matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed. We stub duty to receive errors, perform the create action, and then check if the right page is rendered and also the check if the flash message matches with the expected error message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty.&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered. We first stub the duty active record find function to return a mocked duty object. We then try to edit the duty object by performing the update action, and then check if the right page is rendered and the flash message matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed. We stub the duty object to receive errors. And then we try to save the duty by performing the create action, which results in an unsuccessful attempt, where we check if the right page is rendered and the flash message matches with the expected one. &lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty. We perform the delete action, and then check if the right page is rendered after the delete action, and also check if the flash message matches with the expected one &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties. We run an arbitrary code, in before each block, where we mock the action to update duties. In the inner context, we then stub the current user to be a student user, and check if the controller allows the update duties action.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
E2161&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstration Videos==&lt;br /&gt;
* Functionality Walk-through: https://youtu.be/FRt3ZyofGf4&lt;br /&gt;
* RSpec Testing Video: https://youtu.be/PdlbX5Dlgnw&lt;br /&gt;
&lt;br /&gt;
==Deployments and Pull Requests==&lt;br /&gt;
* Our version of expertiza is deployed at : http://152.7.176.120:8080&lt;br /&gt;
* Our github repository is : https://github.com/namanshrimali/expertiza/tree/beta&lt;br /&gt;
* Our Pull Request : https://github.com/expertiza/expertiza/pull/2137&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141940</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141940"/>
		<updated>2021-11-29T21:27:47Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the functionality of duties_controller.&lt;br /&gt;
&lt;br /&gt;
The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit. We then run the arbitrary code that is needed before each test in this context. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin. We check if the action is allowed by stubbing the current user to admin. We then verify if the controller is able to perform the action for the current admin user&lt;br /&gt;
 &lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor of the current assignment. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course. We check if the action is allowed by stubbing the current user to TA. We then verify if the controller is able to perform the action for the current TA user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new(create) in the arbitrary code that runs before each test.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update. We check if the controller can perform the action 'new' which we mocked in the before each step.&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also added few tests to test creation/edit/deletion of a duty. &lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
We write a test to check if the right page is rendered after successful creation and saving of a new duty in the database. We do this by stubbing the duty object to get saved in the database, and then perform the create action. We also check if the flash message rendered matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed. We stub duty to receive errors, perform the create action, and then check if the right page is rendered and also the check if the flash message matches with the expected error message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty.&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered. We first stub the duty active record find function to return a mocked duty object. We then try to edit the duty object by performing the update action, and then check if the right page is rendered and the flash message matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed. We stub the duty object to receive errors. And then we try to save the duty by performing the create action, which results in an unsuccessful attempt, where we check if the right page is rendered and the flash message matches with the expected one. &lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty. We perform the delete action, and then check if the right page is rendered after the delete action, and also check if the flash message matches with the expected one &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties. We run an arbitrary code, in before each block, where we mock the action to update duties. In the inner context, we then stub the current user to be a student user, and check if the controller allows the update duties action.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Link to Rspec testing video: https://youtu.be/CVRYYNh49Bk&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141932</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141932"/>
		<updated>2021-11-29T21:23:33Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the functionality of duties_controller.&lt;br /&gt;
&lt;br /&gt;
The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit. We then run the arbitrary code that is needed before each test in this context. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin. We check if the action is allowed by stubbing the current user to admin. We then verify if the controller is able to perform the action for the current admin user&lt;br /&gt;
 &lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor of the current assignment. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course. We check if the action is allowed by stubbing the current user to TA. We then verify if the controller is able to perform the action for the current TA user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new(create) in the arbitrary code that runs before each test.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update. We check if the controller can perform the action 'new' which we mocked in the before each step.&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also added few tests to test creation/edit/deletion of a duty. &lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
We write a test to check if the right page is rendered after successful creation and saving of a new duty in the database. We do this by stubbing the duty object to get saved in the database, and then perform the create action. We also check if the flash message rendered matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed. We stub duty to receive errors, perform the create action, and then check if the right page is rendered and also the check if the flash message matches with the expected error message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty.&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered. We first stub the duty active record find function to return a mocked duty object. We then try to edit the duty object by performing the update action, and then check if the right page is rendered and the flash message matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed. We stub the duty object to receive errors. And then we try to save the duty by performing the create action, which results in an unsuccessful attempt, where we check if the right page is rendered and the flash message matches with the expected one. &lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty. We perform the delete action, and then check if the right page is rendered after the delete action, and also check if the flash message matches with the expected one &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties. We run an arbitrary code, in before each block, where we mock the action to update duties. In the inner context, we then stub the current user to be a student user, and check if the controller allows the update duties action.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
[[Media:&amp;lt;iframe width=&amp;quot;560&amp;quot; height=&amp;quot;315&amp;quot; src=&amp;quot;https://www.youtube.com/embed/CVRYYNh49Bk&amp;quot; title=&amp;quot;YouTube video player&amp;quot; frameborder=&amp;quot;0&amp;quot; allow=&amp;quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&amp;quot; allowfullscreen&amp;gt;&amp;lt;/iframe&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141930</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141930"/>
		<updated>2021-11-29T21:22:38Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the functionality of duties_controller.&lt;br /&gt;
&lt;br /&gt;
The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit. We then run the arbitrary code that is needed before each test in this context. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin. We check if the action is allowed by stubbing the current user to admin. We then verify if the controller is able to perform the action for the current admin user&lt;br /&gt;
 &lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor of the current assignment. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course. We check if the action is allowed by stubbing the current user to TA. We then verify if the controller is able to perform the action for the current TA user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new(create) in the arbitrary code that runs before each test.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update. We check if the controller can perform the action 'new' which we mocked in the before each step.&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also added few tests to test creation/edit/deletion of a duty. &lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
We write a test to check if the right page is rendered after successful creation and saving of a new duty in the database. We do this by stubbing the duty object to get saved in the database, and then perform the create action. We also check if the flash message rendered matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed. We stub duty to receive errors, perform the create action, and then check if the right page is rendered and also the check if the flash message matches with the expected error message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty.&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered. We first stub the duty active record find function to return a mocked duty object. We then try to edit the duty object by performing the update action, and then check if the right page is rendered and the flash message matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed. We stub the duty object to receive errors. And then we try to save the duty by performing the create action, which results in an unsuccessful attempt, where we check if the right page is rendered and the flash message matches with the expected one. &lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty. We perform the delete action, and then check if the right page is rendered after the delete action, and also check if the flash message matches with the expected one &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties. We run an arbitrary code, in before each block, where we mock the action to update duties. In the inner context, we then stub the current user to be a student user, and check if the controller allows the update duties action.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141928</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141928"/>
		<updated>2021-11-29T21:20:44Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the functionality of duties_controller.&lt;br /&gt;
&lt;br /&gt;
The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit. We then run the arbitrary code that is needed before each test in this context. We include method stubs here that we can use for each test. We stub the current user to be instructor for now.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin. We check if the action is allowed by stubbing the current user to admin. We then verify if the controller is able to perform the action for the current admin user&lt;br /&gt;
 &lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor of the current assignment. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course. We check if the action is allowed by stubbing the current user to TA. We then verify if the controller is able to perform the action for the current TA user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course. We check if the action is allowed by stubbing the current user to instructor. We then verify if the controller is able to perform the action for the current instructor user&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new(create) in the arbitrary code that runs before each test.&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update. We check if the controller can perform the action 'new' which we mocked in the before each step.&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
We also added few tests to test creation/edit/deletion of a duty. &lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
We write a test to check if the right page is rendered after successful creation and saving of a new duty in the database. We do this by stubbing the duty object to get saved in the database, and then perform the create action. We also check if the flash message rendered matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed. We stub duty to receive errors, perform the create action, and then check if the right page is rendered and also the check if the flash message matches with the expected error message.&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty.&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered. We first stub the duty active record find function to return a mocked duty object. We then try to edit the duty object by performing the update action, and then check if the right page is rendered and the flash message matches to the expected message.&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed. We stub the duty object to receive errors. And then we try to save the duty by performing the create action, which results in an unsuccessful attempt, where we check if the right page is rendered and the flash message matches with the expected one. &lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty. We perform the delete action, and then check if the right page is rendered after the delete action, and also check if the flash message matches with the expected one &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties. We run an arbitrary code, in before each block, where we mock the action to update duties. In the inner context, we then stub the current user to be a student user, and check if the controller allows the update duties action.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;iframe width=&amp;quot;560&amp;quot; height=&amp;quot;315&amp;quot; src=&amp;quot;https://www.youtube.com/embed/CVRYYNh49Bk&amp;quot; title=&amp;quot;YouTube video player&amp;quot; frameborder=&amp;quot;0&amp;quot; allow=&amp;quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&amp;quot; allowfullscreen&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141843</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141843"/>
		<updated>2021-11-29T14:23:24Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duty_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
The main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the object. The mock data is shown below which is used for all tests in this file.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
An assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not. The first test checks to make sure a duty can be assigned to a student when the role is available. This makes sure the students will not run into a problem when the roles are assigned within the group. If the roles could not be assigned, then the specific rubrics could not be used during the reviewing phase of the project.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
The next test case makes sure a duty cannot be assigned if there is already the max number of people assigned that role. This test case is important because if too many people are assigned that role the team dynamic will not be correct.&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141842</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141842"/>
		<updated>2021-11-29T14:13:08Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id. This test case ensures no errors will happen when a user is attempting to search for this. This scenario could very easily happen and this test ensures the functionality when it cannot be found.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire. Ensuring that this test passes will be useful because if the questionnaire cannot be returned then it will not be possible to do role based reviewing.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141841</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141841"/>
		<updated>2021-11-29T14:05:59Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. The first step was to create mock data so that the test could run on objects created for the tests. The code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. The first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. This test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141774</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141774"/>
		<updated>2021-11-28T20:07:50Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147  (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026  (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141773</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141773"/>
		<updated>2021-11-28T20:07:24Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147 (Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026 (Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141772</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141772"/>
		<updated>2021-11-28T19:57:00Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141730</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141730"/>
		<updated>2021-11-28T14:54:55Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
the duties_controller_spec.rb file tested the functionality of the duties themselves which was the main part of our project. For this reason this was probably the longest testing file that we wrote. It needed to contain many test cases for duties as it tested everything about them. Firstly we began by creating the mock data that would be used throughout all the tests. This included and admin, an assignment, instructors, a teaching assistant, a duty, and a due date.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
''&lt;br /&gt;
next the before each block initializing all the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
After this it was time to begin the actual testing. the first test was a test on the #action_allowed? method to ensure that the permissions worked and only people with the correct account type could change the data. only instructors and tas should be able to create roles and questionnaires for the roles. Students should be the ones who assign the roles within their group. We wrote 6 tests to test this functionality.&lt;br /&gt;
''&lt;br /&gt;
   describe '#action_allowed?' do&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Next we tested the basic functionality of the duty object to make sure the data could be edited as needed. This part of the testing included testing the create, update and destroy methods. First up was the create method which is shown in the code below. The main testing for this is to make sure the correct thing happens when the duty is saved, as well as when there is an error saving it.&lt;br /&gt;
''&lt;br /&gt;
  describe '#create' do&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141729</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141729"/>
		<updated>2021-11-28T14:53:13Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
the duties_controller_spec.rb file tested the functionality of the duties themselves which was the main part of our project. For this reason this was probably the longest testing file that we wrote. It needed to contain many test cases for duties as it tested everything about them. Firstly we began by creating the mock data that would be used throughout all the tests. This included and admin, an assignment, instructors, a teaching assistant, a duty, and a due date.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
''&lt;br /&gt;
next the before each block initializing all the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
After this it was time to begin the actual testing. the first test was a test on the #action_allowed? method to ensure that the permissions worked and only people with the correct account type could change the data. only instructors and tas should be able to create roles and questionnaires for the roles. Students should be the ones who assign the roles within their group. We wrote 6 tests to test this functionality.&lt;br /&gt;
''&lt;br /&gt;
   describe '#action_allowed?' do&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Next we tested the basic functionality of the duty object to make sure the data could be edited as needed. This part of the testing included testing the create, update and destroy methods.&lt;br /&gt;
''&lt;br /&gt;
  describe '#create' do&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141728</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141728"/>
		<updated>2021-11-28T14:46:45Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
the duties_controller_spec.rb file tested the functionality of the duties themselves which was the main part of our project. For this reason this was probably the longest testing file that we wrote. It needed to contain many test cases for duties as it tested everything about them. Firstly we began by creating the mock data that would be used throughout all the tests. This included and admin, an assignment, instructors, a teaching assistant, a duty, and a due date.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
''&lt;br /&gt;
next the before each block initializing all the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
After this it was time to begin the actual testing. the first test was a test on the #action_allowed? method to ensure that the permissions worked and only people with the correct account type could change the data. only instructors and tas should be able to create roles and questionnaires for the roles. Students should be the ones who assign the roles within their group. We wrote 7 tests to test this functionality.&lt;br /&gt;
''&lt;br /&gt;
   describe '#action_allowed?' do&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141727</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141727"/>
		<updated>2021-11-28T14:40:50Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
the duties_controller_spec.rb file tested the functionality of the duties themselves which was the main part of our project. For this reason this was probably the longest testing file that we wrote. It needed to contain many test cases for duties as it tested everything about them. Firstly we began by creating the mock data that would be used throughout all the tests. This included and admin, an assignment, instructors, a teaching assistant, a duty, and a due date.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) }&lt;br /&gt;
''&lt;br /&gt;
next the before each block initializing all the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141726</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141726"/>
		<updated>2021-11-28T14:34:39Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
the duties_controller_spec.rb file tested the functionality of the duties themselves which was the main part of our project. For this reason this was probably the longest testing file that we wrote. It needed to contain many test cases for duties as it tested everything about them.&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141725</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141725"/>
		<updated>2021-11-28T14:23:26Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duties_controller_test.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141724</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141724"/>
		<updated>2021-11-28T14:15:42Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* teammate_review_response_map_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
This step created the review response map that we would be testing as well as and assignment which contained a questionnaire. The next step was to actually test the data. First we decided to ensure that the correct questionnaire was returned with the following test. It compares the returned questionnaire with the one we know is correct.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns questionnaire specific to a duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire1])&lt;br /&gt;
      allow(Questionnaire).to receive(:find).with(assignment_questionnaire1.questionnaire_id).and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
Finally we added the inverse for when there was an error returning the questionnaire. in this case the program should return the default questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  it 'returns default questionnaire when no questionnaire is found for duty' do&lt;br /&gt;
      allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([])&lt;br /&gt;
      allow(assignment.questionnaires).to receive(:find_by).with(type: 'TeammateReviewQuestionnaire').and_return(questionnaire)&lt;br /&gt;
      expect(teammate_review_response_map.questionnaire_by_duty(1)).to eq questionnaire&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141723</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141723"/>
		<updated>2021-11-28T14:11:47Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* teammate_review_response_map_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because when one student goes to review another they must get the correct questionnaire for their role. We tested this functionality as well as the inverse, when the role could not be found. initially we created the mock data for testing which is shown below.&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire) { Questionnaire.new name: &amp;quot;abc&amp;quot;, private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 }&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt', is_duty_based_assignment: true, questionnaires: [questionnaire]) }&lt;br /&gt;
  let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 2, duty_id: 1) }&lt;br /&gt;
  let(:participant) { build(:participant, id: 1, user_id: 6, assignment: assignment) }&lt;br /&gt;
  let(:teammate_review_response_map) { TeammateReviewResponseMap.new reviewer: participant, reviewer_is_team: true, assignment:assignment }&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141722</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141722"/>
		<updated>2021-11-28T14:09:31Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* teammate_review_response_map_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
This Rspec testing file tests that a specific questionnaire can be returned when the student has a role assigned to them. This is needed for the role based reviewing because&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141714</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141714"/>
		<updated>2021-11-28T04:36:59Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duty_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
Finally the actual tests were implemented. The tests are fairly simple because they just need to check if the duty can be assigned or not.&lt;br /&gt;
''&lt;br /&gt;
    describe '#can_be_assigned?' do&lt;br /&gt;
    context 'when users in current team want to assign roles that are available'&lt;br /&gt;
      it 'returns true' do&lt;br /&gt;
        expect(sample_duty_not_taken.can_be_assigned?(team1)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    context 'when users in current team want to assign roles that are unavailable'&lt;br /&gt;
    it 'returns false' do&lt;br /&gt;
      expect(sample_duty_taken.can_be_assigned?(team1)).to be false&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141713</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141713"/>
		<updated>2021-11-28T04:35:37Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duty_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141712</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141712"/>
		<updated>2021-11-28T04:33:41Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* duty_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
the main purpose of the duty_spec.rb file is to test any duty to make sure a duty can be assigned to a team member. it also tests if a duty is unavailable to a team member because the max number of people have been assigned that duty. to test this functionality the mock data is created to allow for testing of the objcect.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1, name: 'no assgt') }&lt;br /&gt;
  let(:participant) { build(:participant, id:1, user_id: 1) }&lt;br /&gt;
  let(:participant2) { build(:participant, id:2, user_id: 2) }&lt;br /&gt;
  let(:participant3) { build(:participant, id:3, user_id: 3) }&lt;br /&gt;
  let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) }&lt;br /&gt;
  let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) }&lt;br /&gt;
  let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) }&lt;br /&gt;
&lt;br /&gt;
  let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) }&lt;br /&gt;
  let(:sample_duty_taken) { build(:duty, id: 1, max_members_for_duty:1, assignment_id:1) }&lt;br /&gt;
  let(:sample_duty_not_taken) { build(:duty, id: 1, max_members_for_duty:2, assignment_id:1) }&lt;br /&gt;
&lt;br /&gt;
  let(:team_user1) { build(:team_user, id: 1, user: user) }&lt;br /&gt;
  let(:team_user2) { build(:team_user, id: 2, user: user2) }&lt;br /&gt;
  let(:team_user3) { build(:team_user, id: 3, user: user3, duty_id:1) }&lt;br /&gt;
''&lt;br /&gt;
an assignment is created on which the duties can be tested. for the testing multiple users and participants are created. Finally we created team users that could be assigned duties through the duty_id field. the next step was to set up the reoccurring steps for each of the tests.&lt;br /&gt;
''&lt;br /&gt;
   before(:each) do&lt;br /&gt;
    allow(team1).to receive(:participants).and_return([participant, participant2, participant3])&lt;br /&gt;
    allow(participant).to receive(:get_team_user).and_return(team_user1)&lt;br /&gt;
    allow(participant2).to receive(:get_team_user).and_return(team_user2)&lt;br /&gt;
    allow(participant3).to receive(:get_team_user).and_return(team_user3)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141711</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141711"/>
		<updated>2021-11-28T04:23:17Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. this test is very similar to the one where the test is not found because the it searches through the active record to find the assignment questionnaire.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141710</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141710"/>
		<updated>2021-11-28T04:17:28Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. once  &lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141709</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141709"/>
		<updated>2021-11-28T04:16:53Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
''&lt;br /&gt;
The new_assignment_questionnaire object is used for both test cases in this file. the first test case checks for when the active record cannot be found for a specific assignment id or duty id.&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id and duty_id' do&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
The next next test checks when the assignment questionnaire is found given the assignment id and duty id parameters. once  &lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id and duty_id' do&lt;br /&gt;
      let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141708</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141708"/>
		<updated>2021-11-28T03:57:52Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment_questionnaire2) { build(:assignment_questionnaire, id:1, duty_id:1, questionnaire_id:1) }&lt;br /&gt;
''&lt;br /&gt;
''&lt;br /&gt;
  let(:questionnaire3) { double('Questionnaire', type: 'TeammateReviewQuestionnaire') }&lt;br /&gt;
''&lt;br /&gt;
the test cases are shown below&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is not found for a given assignment_id amd duty_id' do&lt;br /&gt;
      let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: anything).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(new_assignment_questionnaire)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
''&lt;br /&gt;
  context 'when active record for assignment_questionnaire is found for a given assignment_id amd duty_id' do&lt;br /&gt;
      let(:new_assignment_questionnaire) { build(:assignment_questionnaire) }&lt;br /&gt;
      it 'returns new instance of assignment_questionnaire with default values' do&lt;br /&gt;
        allow(assignment).to receive(:questionnaire_varies_by_duty).and_return(true)&lt;br /&gt;
        allow(Questionnaire).to receive(:find).with(1).and_return(questionnaire3)&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(assignment_id: 1, duty_id: 1).and_return([assignment_questionnaire2])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:where).with(user_id: anything, assignment_id: nil, questionnaire_id: nil).and_return([])&lt;br /&gt;
        allow(AssignmentQuestionnaire).to receive(:new).and_return(new_assignment_questionnaire)&lt;br /&gt;
        expect(assignment_form.assignment_questionnaire('TeammateReviewQuestionnaire', nil, nil, 1)).to eq(assignment_questionnaire2)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141707</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141707"/>
		<updated>2021-11-28T03:55:59Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
&lt;br /&gt;
''  let(:assignment_questionnaire2) { build(:assignment_questionnaire, id:1, duty_id:1, questionnaire_id:1) }''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141706</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141706"/>
		<updated>2021-11-28T03:55:46Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''  let(:assignment_questionnaire2) { build(:assignment_questionnaire, id:1, duty_id:1, questionnaire_id:1) }''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141705</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141705"/>
		<updated>2021-11-28T03:55:29Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* assignment_form_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
The assignemnt_form_spec.rb file contains all the test files for the assignment form, which includes adding object to a queue. the first step was to create mock data so that the test could run on objects created for the tests. the code below shows how the mock data was created for the specific tests that we created to ensure the functionality of the projects.&lt;br /&gt;
''&lt;br /&gt;
  let(:assignment_questionnaire2) { build(:assignment_questionnaire, id:1, duty_id:1, questionnaire_id:1) }&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141704</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141704"/>
		<updated>2021-11-28T03:47:09Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duty_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== teammate_review_response_map_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
== duties_controller_test.rb ==&lt;br /&gt;
&lt;br /&gt;
== Manual Testing in Expertiza UI ==&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141703</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141703"/>
		<updated>2021-11-28T03:43:39Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
== assignment_form_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141702</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141702"/>
		<updated>2021-11-28T02:54:58Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141701</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141701"/>
		<updated>2021-11-28T02:54:09Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
let(:teams_user1) {TeamsUser.new id:1, duty_id:1}&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141700</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141700"/>
		<updated>2021-11-28T02:53:33Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: /* team_users_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page. just as with the previous section the first step is to mock the data by creating a team user object.&lt;br /&gt;
&lt;br /&gt;
''let(:teams_user1) {TeamsUser.new id:1, duty_id:1}''&lt;br /&gt;
&lt;br /&gt;
Then the data is actually updated and we ensure that the user is redirected to the proper place.&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141699</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141699"/>
		<updated>2021-11-28T02:48:42Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed and implemented for [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.8s6o9jnnxj0p E2161. Merge code for role-based reviewing with code for topic-specific rubrics], a Final Project for CSC/ECE 517, Fall 2021.&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
The project objective is to merge E2147-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2147._Role-based_reviewing#E2147._Role-based_reviewing with the existing E2026-https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types. While merging, we found out that the code for E2026 has already been merged on Expertiza beta branch and so now the actual implementation is to write test cases for both E2147 and E2026.&lt;br /&gt;
&lt;br /&gt;
==Brief Overview of E2147 and E2026 Projects==&lt;br /&gt;
*E2147(Role based reviewing): The project objective was to develop teammate review varying by the roles that each team member has in order to evaluate the particular role that each team member has taken rather than asking a generic questionnaire which was same for all the team members previously. For eg, the instructor would create a separate teammate questionnaire for developer role and for tester role respectively.&lt;br /&gt;
*E2026(Specialized rubrics for different topics): The project objective was to develop specialized rubrics based on project topics, previously we had same type of questionnaire for all the different types of projects. This implementation made sure that we evaluate different projects based on personalised rubrics rather than having same rubrics.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2147(Role based reviewing)===&lt;br /&gt;
*Only Instructor/TA/Admin should be able to create or update duties: Only the instructor/admin should be able to create or update duties. Also, the corresponding TA of the assignment should be able to create or update duties.&lt;br /&gt;
*Create new roles: If the assignment is role based reviewing then the instructor should be able to create new roles for the same and save it in the database using new role functionality.&lt;br /&gt;
*Only allow student to update duties in Student View: Only student should be able to update his duties in Student View. &lt;br /&gt;
*Edit existing roles: Once the new roles have been created, then the instructor should be able to edit its details such as the maximum number of each role allowed.&lt;br /&gt;
*Delete existing roles: The instructor should also be able to delete any roles if he wants.&lt;br /&gt;
*Review rubric by role: On Rubrics tab, if the instructor clicks on Review rubric by role, then the corresponding rubric roles based teammate questionnaire should appear and get saved successfully.&lt;br /&gt;
*Student View: If the assignment is role based assignment, then the respective students should be able to see the respective teammate questionnaire based on roles for his other team members.&lt;br /&gt;
*Selection of Roles: On student login, a student should be able to see the existing roles that he can take up in the project. Only the roles which are available should be shown to the student.&lt;br /&gt;
&lt;br /&gt;
===Test Scenarios for E2026(Specialized rubrics for different topics)===&lt;br /&gt;
&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*spec/helpers/duties_controller_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== duties_controller_spec.rb ==&lt;br /&gt;
We have created this new test file to unit test the duties scenarios.&lt;br /&gt;
&lt;br /&gt;
First we mock the data accordingly as needed by the tests. &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe DutiesController do&lt;br /&gt;
  let(:assignment) { build(:assignment, id: 1,course_id: 1,instructor_id: 6, due_dates: [due_date], microtask: true, staggered_deadline: true)}&lt;br /&gt;
  let(:admin) { build(:admin) }&lt;br /&gt;
  let(:instructor) { build(:instructor, id: 6) }&lt;br /&gt;
  let(:instructor2) { build(:instructor, id: 66) }&lt;br /&gt;
  let(:ta) { build(:teaching_assistant, id: 8) }&lt;br /&gt;
  let(:duty) { build(:duty, id: 1, duty_name: &amp;quot;Role&amp;quot;, max_members_for_duty: 2, assignment_id: 1) }&lt;br /&gt;
  let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } ''&lt;br /&gt;
&lt;br /&gt;
We then run the arbitrary code that is needed before each test &lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    allow(Assignment).to receive(:find).with(1).and_return(assignment)&lt;br /&gt;
    stub_current_user(instructor, instructor.role.name, instructor.role)&lt;br /&gt;
    allow(Duty).to receive(:find).with('1').and_return(duty)&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Test scenarios for duties controller:&lt;br /&gt;
1) Only admin, superadmin, TA, Instructor can perform edit or update action&lt;br /&gt;
&lt;br /&gt;
'' describe '#action_allowed?' do ''&lt;br /&gt;
&lt;br /&gt;
The whole context that defines if the action allowed is edit or update. We do this by mocking the action to edit&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is edit or update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'edit'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is super admin or admin&lt;br /&gt;
&lt;br /&gt;
      context 'when the role name of current user is super admin or admin' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(admin, admin.role.name, admin.role)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is instructor&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of current assignment' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user role is the TA of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the ta of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(ta, ta.role.name, ta.role)&lt;br /&gt;
          allow(TaMapping).to receive(:exists?).with(ta_id: 8, course_id: 1).and_return(true)&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
When the current logged in user is the instructor of the course&lt;br /&gt;
&lt;br /&gt;
      context 'when current user is the instructor of the course which current assignment belongs to' do&lt;br /&gt;
        it 'allows certain action' do&lt;br /&gt;
          stub_current_user(instructor2, instructor2.role.name, instructor2.role)&lt;br /&gt;
          allow(Course).to receive(:find).with(1).and_return(double('Course', instructor_id: 66))&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the parameter action is neither edit nor update, we do this by mocking the action to new&lt;br /&gt;
&lt;br /&gt;
    context 'when params action is not edit and update' do&lt;br /&gt;
      before(:each) do&lt;br /&gt;
        controller.params = {id: '1', action: 'new'}&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
We now check if super admin/admin/instructor/ta can perform this action which is neither edit nor update&lt;br /&gt;
&lt;br /&gt;
      context 'when the role current user is super admin/admin/instructor/ta' do&lt;br /&gt;
        it 'allows certain action except edit and update' do&lt;br /&gt;
          expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
And then we added few tests to test creation/edit/deletion of a duty&lt;br /&gt;
&lt;br /&gt;
Creation of a duty, we create a duty and check if it is saved successfully&lt;br /&gt;
&lt;br /&gt;
describe '#create' do&lt;br /&gt;
&lt;br /&gt;
Checking if the right page is rendered after successful creation of a duty &lt;br /&gt;
&lt;br /&gt;
      context 'when new duty can be saved successfully' do&lt;br /&gt;
        it 'sets up a new duty and redirects to assignment#edit page' do&lt;br /&gt;
          allow(duty).to receive(:save).and_return('OK')&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: 2,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
          expect(flash[:notice]).to match(/Role was successfully created.*/)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
Test to check if the right error message is shown if the creation of duty is failed&lt;br /&gt;
&lt;br /&gt;
      context 'when new duty cannot be saved successfully' do&lt;br /&gt;
        it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
          allow(duty).to receive(:errors)&lt;br /&gt;
          params = {&lt;br /&gt;
              id: 1,&lt;br /&gt;
              duty: {&lt;br /&gt;
                  duty_name: 'Scrum Master',&lt;br /&gt;
                  max_members_for_duty: -1,&lt;br /&gt;
                  assignment_id: 1&lt;br /&gt;
              }&lt;br /&gt;
          }&lt;br /&gt;
          post :create, params&lt;br /&gt;
          expect(flash[:error]).to eq('Max members for duty must be greater than or equal to 1. ')&lt;br /&gt;
          expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Test to check the edit functionality of a duty&lt;br /&gt;
&lt;br /&gt;
describe '#update' do&lt;br /&gt;
&lt;br /&gt;
When the duty can be edited successfully, we check if the right page is rendered&lt;br /&gt;
&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'updates current duty and redirects to assignment#edit page' do&lt;br /&gt;
        allow(Duty).to receive(:find).with('1').and_return(build(:duty, id: 1))&lt;br /&gt;
          params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            assignment_id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'Scrum Master',&lt;br /&gt;
                max_members_for_duty: 5,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :update, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully updated.*/)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
When the duty cannot be updated, we check if the right error message is displayed&lt;br /&gt;
&lt;br /&gt;
    context 'when new duty cannot be updated successfully' do&lt;br /&gt;
      it 'shows error message and redirects to duty#new page' do&lt;br /&gt;
        allow(duty).to receive(:errors)&lt;br /&gt;
        params = {&lt;br /&gt;
            id: 1,&lt;br /&gt;
            duty: {&lt;br /&gt;
                duty_name: 'SM',&lt;br /&gt;
                max_members_for_duty: 1,&lt;br /&gt;
                assignment_id: 1&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        post :create, params&lt;br /&gt;
        expect(flash[:error]).to eq('Duty name is too short (minimum is 3 characters). ')&lt;br /&gt;
        expect(response).to redirect_to('/duties/new?id=1')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now finally, we test the delete functionality of the duty &lt;br /&gt;
&lt;br /&gt;
 describe '#destroy' do&lt;br /&gt;
    context 'when duty can be found' do&lt;br /&gt;
      it 'redirects to assignment#edit page' do&lt;br /&gt;
        params = {id: 1, assignment_id: 1}&lt;br /&gt;
        post :destroy, params&lt;br /&gt;
        expect(response).to redirect_to('/assignments/1/edit')&lt;br /&gt;
        expect(flash[:notice]).to match(/Role was successfully destroyed.*/)&lt;br /&gt;
      end&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== team_users_controller_spec.rb ==&lt;br /&gt;
&lt;br /&gt;
We have added a test case in this file which tests if the action is allowed only by specific user roles&lt;br /&gt;
&lt;br /&gt;
First, we mock the data&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe TeamsUsersController do&lt;br /&gt;
  let(:assignment) do&lt;br /&gt;
    build(:assignment, id: 1, name: 'test assignment', instructor_id: 6, staggered_deadline: true, directory_path: 'same path',&lt;br /&gt;
          participants: [build(:participant)], teams: [build(:assignment_team)], course_id: 1)&lt;br /&gt;
  end&lt;br /&gt;
  let(:assignment_form) { double('AssignmentForm', assignment: assignment) }&lt;br /&gt;
  let(:student) { build(:student) }&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    allow(Assignment).to receive(:find).with('1').and_return(assignment)&lt;br /&gt;
    stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
 end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Then we check if the student can perform the update action for duties&lt;br /&gt;
&lt;br /&gt;
''&lt;br /&gt;
 describe '#action_allowed?' do&lt;br /&gt;
  context 'when params action is update duties' do&lt;br /&gt;
    before(:each) do&lt;br /&gt;
      controller.params = {id: '1', action: 'update_duties'}&lt;br /&gt;
    end&lt;br /&gt;
    context 'when the role current user is student' do&lt;br /&gt;
      it 'allows certain action' do&lt;br /&gt;
        stub_current_user(student, student.role.name, student.role)&lt;br /&gt;
        expect(controller.send(:action_allowed?)).to be true&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end &lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
This file also contains a test case to ensure the duties can be properly updated. The test case checks this by ensuring that the user is redirected to the student view page.&lt;br /&gt;
''&lt;br /&gt;
  describe '#update_duties' do&lt;br /&gt;
      it 'updates the duties for the participant' do&lt;br /&gt;
        allow(TeamsUser).to receive(:find).with('1').and_return(teams_user1)&lt;br /&gt;
        allow(teams_user1).to receive(:update_attribute).with(any_args).and_return('OK')&lt;br /&gt;
        params = {&lt;br /&gt;
            teams_user_id: '1',&lt;br /&gt;
            teams_user: {duty_id: '1'},&lt;br /&gt;
            participant_id: '1'&lt;br /&gt;
        }&lt;br /&gt;
        session = {user: stub_current_user(student, student.role.name, student.role)}&lt;br /&gt;
        get :update_duties, params, session&lt;br /&gt;
        expect(response).to redirect_to('/student_teams/view?student_id=1')&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
* Naman Shrimali&lt;br /&gt;
* Kanchan Rawat&lt;br /&gt;
* Subodh Thota&lt;br /&gt;
* Andrew Shipman&lt;br /&gt;
Mentor : Prof. Edward F. Gehringer&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141154</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141154"/>
		<updated>2021-11-07T22:57:52Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
===Peer Review Information===&lt;br /&gt;
Login credentials for peer review.&lt;br /&gt;
&lt;br /&gt;
* Instructor login:&lt;br /&gt;
** Username: instructor6&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
* Student login:&lt;br /&gt;
** Username: student4340&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
In various agile methodologies, such as Scrum, different team members take on different roles, such as architect, facilitator, and implementer.  One might want to use a different rubric for evaluating the contribution of members with different roles.  Thus, this would not be separate from teammate review, but it would be a specialization of teammate review.&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Created a new database table, model, view, and controller for duties.&lt;br /&gt;
* Allow assignments to be marked for role-based reviewing.&lt;br /&gt;
* Certain users can add and edit roles for assignments.&lt;br /&gt;
&lt;br /&gt;
Due to naming issues all of the backend components for role-based reviewing are known as duty or duties. When referring to the backend this documentation will refer to them as duty or duties and when referring to frontend components they will be called role or roles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Current Reviewing==&lt;br /&gt;
Currently reviewing does not allow students to have different rubrics for an assignment based on their role in the team.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141153</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141153"/>
		<updated>2021-11-07T22:57:31Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
===Peer Review Information===&lt;br /&gt;
Login credentials for peer review.&lt;br /&gt;
&lt;br /&gt;
* Instructor login:&lt;br /&gt;
** Username: instructor6&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
* Student login:&lt;br /&gt;
** Username: student4340&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
In various agile methodologies, such as Scrum, different team members take on different roles, such as architect, facilitator, and implementer.  One might want to use a different rubric for evaluating the contribution of members with different roles.  Thus, this would not be separate from teammate review, but it would be a specialization of teammate review.&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Created a new database table, model, view, and controller for duties.&lt;br /&gt;
* Allow assignments to be marked for role-based reviewing.&lt;br /&gt;
* Certain users can add and edit roles for assignments.&lt;br /&gt;
&lt;br /&gt;
Due to naming issues all of the backend components for role-based reviewing are known as duty or duties. When referring to the backend this documentation will refer to them as duty or duties and when referring to frontend components they will be called role or roles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Current Reviewing&lt;br /&gt;
Currently reviewing does not allow students to have different rubrics for an assignment based on their role in the team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141152</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141152"/>
		<updated>2021-11-07T22:52:06Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Peer Review Information===&lt;br /&gt;
Login credentials for peer review.&lt;br /&gt;
&lt;br /&gt;
* Instructor login:&lt;br /&gt;
** Username: instructor6&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
* Student login:&lt;br /&gt;
** Username: student4340&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
In various agile methodologies, such as Scrum, different team members take on different roles, such as architect, facilitator, and implementer.  One might want to use a different rubric for evaluating the contribution of members with different roles.  Thus, this would not be separate from teammate review, but it would be a specialization of teammate review.&lt;br /&gt;
&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Created a new database table, model, view, and controller for duties.&lt;br /&gt;
* Allow assignments to be marked for role-based reviewing.&lt;br /&gt;
* Certain users can add and edit roles for assignments.&lt;br /&gt;
&lt;br /&gt;
Due to naming issues all of the backend components for role-based reviewing are known as duty or duties. When referring to the backend this documentation will refer to them as duty or duties and when referring to frontend components they will be called role or roles.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141151</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141151"/>
		<updated>2021-11-07T22:51:41Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Peer Review Information===&lt;br /&gt;
Login credentials for peer review.&lt;br /&gt;
&lt;br /&gt;
* Instructor login:&lt;br /&gt;
** Username: instructor6&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
* Student login:&lt;br /&gt;
** Username: student4340&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141150</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141150"/>
		<updated>2021-11-07T22:51:02Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Peer Review Information===&lt;br /&gt;
Login credentials for peer review.&lt;br /&gt;
&lt;br /&gt;
* Instructor login:&lt;br /&gt;
** Username: instructor6&lt;br /&gt;
** Password: password&lt;br /&gt;
&lt;br /&gt;
* Student login:&lt;br /&gt;
** Username: student4340&lt;br /&gt;
** Password: password&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141149</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141149"/>
		<updated>2021-11-07T22:50:13Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Peer Review Information&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141148</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141148"/>
		<updated>2021-11-07T22:24:17Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
Expertiza is a web application through which students can submit and peer-review learning objects (articles, code, web sites, etc). The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141147</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141147"/>
		<updated>2021-11-07T22:22:30Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141146</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=141146"/>
		<updated>2021-11-07T22:21:01Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2126._Testing_-_Team_Related_Files#Description_about_project CSC/ECE 517 Fall 2021 - E2126. Testing - Team Related Files]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2156._Issues_related_to_meta-reviewing#Description_about_project CSC/ECE 517 Fall 2021 - E2156. Issues related to meta-reviewing]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging]]&lt;br /&gt;
* [[E2157. Fix issues related to deadlines and late policies]]&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141145</id>
		<title>CSC/ECE 517 Fall 2021 - E2161. Merge code for role based reviewing with code for topic specific rubrics</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2161._Merge_code_for_role_based_reviewing_with_code_for_topic_specific_rubrics&amp;diff=141145"/>
		<updated>2021-11-07T22:18:05Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: Created page with &amp;quot;Problem Statement&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Problem Statement&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140156</id>
		<title>CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140156"/>
		<updated>2021-10-27T00:56:36Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
===About SQL File Evaluation===&lt;br /&gt;
&lt;br /&gt;
SQL File Evaluation is a program developed by DR. Paul Wagner to help with the grading of SQL exams given to students in a database systems class. The program parses through tests given to the students and compares their answer queries to the correct answers for the questions. This tool allows the professor to have tests graded in a matter of seconds that could traditionally take hours to grade. When the software is started it provides a GUI with options to connect to either an Oracle or MySQL database to run the answers against and grade the tests. Instructions must create their own assignment properties files which allows them to distribute points accordingly. Once all the inputs have been entered the software will run all of the tests answers, giving points according to the instructor's assignment properties file and produces an output file for each test as well as an overall summary file that tracks all of the students grades.&lt;br /&gt;
&lt;br /&gt;
[[File:SQLFESS.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Project Goal===&lt;br /&gt;
The goal of this project was to refactor the code of the back end of the software to improve clarity and readability. the main focus was on the refactoring of the evaluate method, which was part of the BackEnd class. The original version of the evaluate method was almost 200 lines of code and involved many different processes. Dr. Wagner said the method started out as a few lines but as the code evolved, it grew much larger and needed to be refactored. Our plan for the refactoring of the code involved a few key tasks which were:&lt;br /&gt;
*Breaking up sections of code that were focusing on the same task into separate methods&lt;br /&gt;
*Create checking functions for conditionals that contained a lot of ANDs and ORs &lt;br /&gt;
*Change names of variables that are only a single letter or a few letters to more descriptive names&lt;br /&gt;
*Add comments to describe what every section of code is doing&lt;br /&gt;
*Add comments to methods we created to state their purpose and keep the same styling.&lt;br /&gt;
*Ensure all code complies with SOLID principles&lt;br /&gt;
Following the refactoring, we also created junit tests to ensure the code was still working with the changes we had made to the code. The testing ensured the proper files were created as well as that all the necessary files were created. additionally the testing checks the summary file and compares it to a summary file that is known to be correct to ensure the summary (and all of the files within it are created properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
Testing was a necessary step in working on the open source software because when we received the code it was working and we needed to ensure it still worked after we made the changes in refactoring. Java has a testing frame work called junit that allowed us to create unit tests and verify the code worked. we implemented these tests on the the Backend method, which was the section of code that we refactored. &lt;br /&gt;
&lt;br /&gt;
The first step in creating the test was to set up both a front and and a back end object so the code was able to run. This allowed for the tests to emulate the program when it was actually running. We manually set up all of the information needed for the code to connect to the the proper MySQL database so it could grade the exams. The code below shows how the unit test was set up to begin testing the back end class. The JFXPanel is needed to make sure the test runs properly as if a user was using the software. At the end of the code the evaluate method is called which is what we refactored.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BackEndTests extends AbstractTest {&lt;br /&gt;
&lt;br /&gt;
	@Test&lt;br /&gt;
	void test() {&lt;br /&gt;
		try {&lt;br /&gt;
			// initialize jfx for test to run&lt;br /&gt;
			JFXPanel fxPanel = new JFXPanel();&lt;br /&gt;
			&lt;br /&gt;
			// set default values for testing an input&lt;br /&gt;
			// values will need to be changed for information used in personal testing database&lt;br /&gt;
			String dbmsChoice = &amp;quot;MySQL 8.0&amp;quot;;&lt;br /&gt;
			String dbmsHost = &amp;quot;localhost&amp;quot;;&lt;br /&gt;
			String dbmsPort = &amp;quot;3306&amp;quot;;&lt;br /&gt;
			String dbmsSystemID = &amp;quot;evaltest&amp;quot;;&lt;br /&gt;
			String dbmsUsername = &amp;quot;root&amp;quot;;&lt;br /&gt;
			String dbmsPassword = &amp;quot;****&amp;quot;;&lt;br /&gt;
			String evaluationFolder = &amp;quot;C:\\Users\\andrewshipman\\eclipse-workspace\\SQLFE_project&amp;quot;;&lt;br /&gt;
			String assignPropFile = &amp;quot;assignmentProperties-MySQL&amp;quot;;&lt;br /&gt;
			FrontEnd f = new FrontEnd();&lt;br /&gt;
			&lt;br /&gt;
			// set values for the front end used for testing&lt;br /&gt;
			f.setDbmsChoice(dbmsChoice);&lt;br /&gt;
			f.setDbmsHost(dbmsHost);&lt;br /&gt;
			f.setDbmsPort(dbmsPort);&lt;br /&gt;
			f.setDbmsSystemID(dbmsSystemID);&lt;br /&gt;
			f.setDbmsUsername(dbmsUsername);&lt;br /&gt;
			f.setDbmsPassword(dbmsPassword);&lt;br /&gt;
			f.setEvaluationFolder(evaluationFolder);&lt;br /&gt;
			f.setAssignPropFile(assignPropFile);&lt;br /&gt;
			&lt;br /&gt;
			// setup back end and run evaluation&lt;br /&gt;
			BackEnd b = new BackEnd(f);&lt;br /&gt;
			f.setABackEnd(b);&lt;br /&gt;
			b.transferData(f);&lt;br /&gt;
			b.evaluate();&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the evaluate method is completed the testing is ready to begin to validate that the evaluate method did its job correctly. This is done in a few ways. The first way is that the program checks to make sure the summary file was created. This provides proof that the evaluate method at least ran and tried to create something. the code for this test is fairly simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if output file was created&lt;br /&gt;
File testFile = new File(f.getEvaluationFolder() + &amp;quot;\\evaluations\\AAA_grade_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(testFile.exists());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The next test checks to see that the program created the proper number of output files. This should be 1 for each exam that was submitted into the files folder for evaluation plus an additional 3 files one for the summary, one for any problems that were found in the parser, and one containing the student comments. The code for this test is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if there is the proper number of files&lt;br /&gt;
File inputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\files&amp;quot;);&lt;br /&gt;
File outputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\Evaluations&amp;quot;);&lt;br /&gt;
assertEquals(inputFiles.list().length, (outputFiles.list().length - 3));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The final test checked the output summary of the program against a file that was known to be correct for the first 5 sample files that came with the java code. This test used an API for comparing the contents of 2 files to see if they are the same or different. The correct file is located in another folder in the project called TestingFiles. The code for this test is below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if grade summary output is correct for 5 files&lt;br /&gt;
// uses file in testing file to assert output is correct for 5 evaluations&lt;br /&gt;
File compareFile = new File(f.getEvaluationFolder() + &amp;quot;\\TestingFiles\\Correct_5_evals_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(FileUtils.contentEquals(testFile, compareFile));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
all of the tests passed along with manual testing and checking of all 66 sample files included with the project. This meant our refactoring achieved the same goal of the original program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
The software can be downloaded either as an executable or as a the source code which can be run through Java Eclipse or Intelij IDE. The documentation on how to download and run the program be found in the docs folder on the github repository.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140155</id>
		<title>CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140155"/>
		<updated>2021-10-27T00:56:12Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
===About SQL File Evaluation===&lt;br /&gt;
&lt;br /&gt;
SQL File Evaluation is a program developed by DR. Paul Wagner to help with the grading of SQL exams given to students in a database systems class. The program parses through tests given to the students and compares their answer queries to the correct answers for the questions. This tool allows the professor to have tests graded in a matter of seconds that could traditionally take hours to grade. When the software is started it provides a GUI with options to connect to either an Oracle or MySQL database to run the answers against and grade the tests. Instructions must create their own assignment properties files which allows them to distribute points accordingly. Once all the inputs have been entered the software will run all of the tests answers, giving points according to the instructor's assignment properties file and produces an output file for each test as well as an overall summary file that tracks all of the students grades.&lt;br /&gt;
&lt;br /&gt;
[[File:SQLFESS.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Project Goal===&lt;br /&gt;
The goal of this project was to refactor the code of the back end of the software to improve clarity and readability. the main focus was on the refactoring of the evaluate method, which was part of the BackEnd class. The original version of the evaluate method was almost 200 lines of code and involved many different processes. Dr. Wagner said the method started out as a few lines but as the code evolved, it grew much larger and needed to be refactored. Our plan for the refactoring of the code involved a few key tasks which were:&lt;br /&gt;
*Breaking up sections of code that were focusing on the same task into separate methods&lt;br /&gt;
*Create checking functions for conditionals that contained a lot of ANDs and ORs &lt;br /&gt;
*Change names of variables that are only a single letter or a few letters to more descriptive names&lt;br /&gt;
*Add comments to describe what every section of code is doing&lt;br /&gt;
*Add comments to methods we created to state their purpose and keep the same styling.&lt;br /&gt;
*Ensure all code complies with SOLID principles&lt;br /&gt;
Following the refactoring, we also created junit tests to ensure the code was still working with the changes we had made to the code. The testing ensured the proper files were created as well as that all the necessary files were created. additionally the testing checks the summary file and compares it to a summary file that is known to be correct to ensure the summary (and all of the files within it are created properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
Testing was a necessary step in working on the open source software because when we received the code it was working and we needed to ensure it still worked after we made the changes in refactoring. Java has a testing frame work called junit that allowed us to create unit tests and verify the code worked. we implemented these tests on the the Backend method, which was the section of code that we refactored. &lt;br /&gt;
&lt;br /&gt;
The first step in creating the test was to set up both a front and and a back end object so the code was able to run. This allowed for the tests to emulate the program when it was actually running. We manually set up all of the information needed for the code to connect to the the proper MySQL database so it could grade the exams. The code below shows how the unit test was set up to begin testing the back end class. The JFXPanel is needed to make sure the test runs properly as if a user was using the software. At the end of the code the evaluate method is called which is what we refactored.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BackEndTests extends AbstractTest {&lt;br /&gt;
&lt;br /&gt;
	@Test&lt;br /&gt;
	void test() {&lt;br /&gt;
		try {&lt;br /&gt;
			// initialize jfx for test to run&lt;br /&gt;
			JFXPanel fxPanel = new JFXPanel();&lt;br /&gt;
			&lt;br /&gt;
			// set default values for testing an input&lt;br /&gt;
			// values will need to be changed for information used in personal testing database&lt;br /&gt;
			String dbmsChoice = &amp;quot;MySQL 8.0&amp;quot;;&lt;br /&gt;
			String dbmsHost = &amp;quot;localhost&amp;quot;;&lt;br /&gt;
			String dbmsPort = &amp;quot;3306&amp;quot;;&lt;br /&gt;
			String dbmsSystemID = &amp;quot;evaltest&amp;quot;;&lt;br /&gt;
			String dbmsUsername = &amp;quot;root&amp;quot;;&lt;br /&gt;
			String dbmsPassword = &amp;quot;****&amp;quot;;&lt;br /&gt;
			String evaluationFolder = &amp;quot;C:\\Users\\andrewshipman\\eclipse-workspace\\SQLFE_project&amp;quot;;&lt;br /&gt;
			String assignPropFile = &amp;quot;assignmentProperties-MySQL&amp;quot;;&lt;br /&gt;
			FrontEnd f = new FrontEnd();&lt;br /&gt;
			&lt;br /&gt;
			// set values for the front end used for testing&lt;br /&gt;
			f.setDbmsChoice(dbmsChoice);&lt;br /&gt;
			f.setDbmsHost(dbmsHost);&lt;br /&gt;
			f.setDbmsPort(dbmsPort);&lt;br /&gt;
			f.setDbmsSystemID(dbmsSystemID);&lt;br /&gt;
			f.setDbmsUsername(dbmsUsername);&lt;br /&gt;
			f.setDbmsPassword(dbmsPassword);&lt;br /&gt;
			f.setEvaluationFolder(evaluationFolder);&lt;br /&gt;
			f.setAssignPropFile(assignPropFile);&lt;br /&gt;
			&lt;br /&gt;
			// setup back end and run evaluation&lt;br /&gt;
			BackEnd b = new BackEnd(f);&lt;br /&gt;
			f.setABackEnd(b);&lt;br /&gt;
			b.transferData(f);&lt;br /&gt;
			b.evaluate();&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the evaluate method is completed the testing is ready to begin to validate that the evaluate method did its job correctly. This is done in a few ways. The first way is that the program checks to make sure the summary file was created. This provides proof that the evaluate method at least ran and tried to create something. the code for this test is fairly simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if output file was created&lt;br /&gt;
File testFile = new File(f.getEvaluationFolder() + &amp;quot;\\evaluations\\AAA_grade_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(testFile.exists());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The next test checks to see that the program created the proper number of output files. This should be 1 for each exam that was submitted into the files folder for evaluation plus an additional 3 files one for the summary, one for any problems that were found in the parser, and one containing the student comments. The code for this test is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if there is the proper number of files&lt;br /&gt;
File inputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\files&amp;quot;);&lt;br /&gt;
File outputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\Evaluations&amp;quot;);&lt;br /&gt;
assertEquals(inputFiles.list().length, (outputFiles.list().length - 3));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The final test checked the output summary of the program against a file that was known to be correct for the first 5 sample files that came with the java code. This test used an API for comparing the contents of 2 files to see if they are the same or different. The correct file is located in another folder in the project called TestingFiles. The code for this test is below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if grade summary output is correct for 5 files&lt;br /&gt;
// uses file in testing file to assert output is correct for 5 evaluations&lt;br /&gt;
File compareFile = new File(f.getEvaluationFolder() + &amp;quot;\\TestingFiles\\Correct_5_evals_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(FileUtils.contentEquals(testFile, compareFile));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
all of the tests passed along with manual testing and checking of all 66 sample files included with the project. This meant our refactoring achieved the same goal of the original program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
The software can be downloaded either as an executable or as a the source code which can be run through Java Eclipse or Intelij IDE. The documentation on how to download and run the program be found in the docs folder on the github repository.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140152</id>
		<title>CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140152"/>
		<updated>2021-10-27T00:25:25Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
===About SQL File Evaluation===&lt;br /&gt;
&lt;br /&gt;
SQL File Evaluation is a program developed by DR. Paul Wagner to help with the grading of SQL exams given to students in a database systems class. The program parses through tests given to the students and compares their answer queries to the correct answers for the questions. This tool allows the professor to have tests graded in a matter of seconds that could traditionally take hours to grade. When the software is started it provides a GUI with options to connect to either an Oracle or MySQL database to run the answers against and grade the tests. Instructions must create their own assignment properties files which allows them to distribute points accordingly. Once all the inputs have been entered the software will run all of the tests answers, giving points according to the instructor's assignment properties file and produces an output file for each test as well as an overall summary file that tracks all of the students grades.&lt;br /&gt;
&lt;br /&gt;
[[File:SQLFESS.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Project Goal===&lt;br /&gt;
The goal of this project was to refactor the code of the back end of the software to improve clarity and readability. the main focus was on the refactoring of the evaluate method, which was part of the BackEnd class. The original version of the evaluate method was almost 200 lines of code and involved many different processes. Dr. Wagner said the method started out as a few lines but as the code evolved, it grew much larger and needed to be refactored. Our plan for the refactoring of the code involved a few key tasks which were:&lt;br /&gt;
*Breaking up sections of code that were focusing on the same task into separate methods&lt;br /&gt;
*Create checking functions for conditionals that contained a lot of ANDs and ORs &lt;br /&gt;
*Change names of variables that are only a single letter or a few letters to more descriptive names&lt;br /&gt;
*Add comments to describe what every section of code is doing&lt;br /&gt;
*Add comments to methods we created to state their purpose and keep the same styling.&lt;br /&gt;
*Ensure all code complies with SOLID principles&lt;br /&gt;
Following the refactoring, we also created junit tests to ensure the code was still working with the changes we had made to the code. The testing ensured the proper files were created as well as that all the necessary files were created. additionally the testing checks the summary file and compares it to a summary file that is known to be correct to ensure the summary (and all of the files within it are created properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
Testing was a necessary step in working on the open source software because when we received the code it was working and we needed to ensure it still worked after we made the changes in refactoring. Java has a testing frame work called junit that allowed us to create unit tests and verify the code worked. we implemented these tests on the the Backend method, which was the section of code that we refactored. &lt;br /&gt;
&lt;br /&gt;
The first step in creating the test was to set up both a front and and a back end object so the code was able to run. This allowed for the tests to emulate the program when it was actually running. We manually set up all of the information needed for the code to connect to the the proper MySQL database so it could grade the exams. The code below shows how the unit test was set up to begin testing the back end class. The JFXPanel is needed to make sure the test runs properly as if a user was using the software. At the end of the code the evaluate method is called which is what we refactored.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BackEndTests extends AbstractTest {&lt;br /&gt;
&lt;br /&gt;
	@Test&lt;br /&gt;
	void test() {&lt;br /&gt;
		try {&lt;br /&gt;
			// initialize jfx for test to run&lt;br /&gt;
			JFXPanel fxPanel = new JFXPanel();&lt;br /&gt;
			&lt;br /&gt;
			// set default values for testing an input&lt;br /&gt;
			// values will need to be changed for information used in personal testing database&lt;br /&gt;
			String dbmsChoice = &amp;quot;MySQL 8.0&amp;quot;;&lt;br /&gt;
			String dbmsHost = &amp;quot;localhost&amp;quot;;&lt;br /&gt;
			String dbmsPort = &amp;quot;3306&amp;quot;;&lt;br /&gt;
			String dbmsSystemID = &amp;quot;evaltest&amp;quot;;&lt;br /&gt;
			String dbmsUsername = &amp;quot;root&amp;quot;;&lt;br /&gt;
			String dbmsPassword = &amp;quot;****&amp;quot;;&lt;br /&gt;
			String evaluationFolder = &amp;quot;C:\\Users\\andrewshipman\\eclipse-workspace\\SQLFE_project&amp;quot;;&lt;br /&gt;
			String assignPropFile = &amp;quot;assignmentProperties-MySQL&amp;quot;;&lt;br /&gt;
			FrontEnd f = new FrontEnd();&lt;br /&gt;
			&lt;br /&gt;
			// set values for the front end used for testing&lt;br /&gt;
			f.setDbmsChoice(dbmsChoice);&lt;br /&gt;
			f.setDbmsHost(dbmsHost);&lt;br /&gt;
			f.setDbmsPort(dbmsPort);&lt;br /&gt;
			f.setDbmsSystemID(dbmsSystemID);&lt;br /&gt;
			f.setDbmsUsername(dbmsUsername);&lt;br /&gt;
			f.setDbmsPassword(dbmsPassword);&lt;br /&gt;
			f.setEvaluationFolder(evaluationFolder);&lt;br /&gt;
			f.setAssignPropFile(assignPropFile);&lt;br /&gt;
			&lt;br /&gt;
			// setup back end and run evaluation&lt;br /&gt;
			BackEnd b = new BackEnd(f);&lt;br /&gt;
			f.setABackEnd(b);&lt;br /&gt;
			b.transferData(f);&lt;br /&gt;
			b.evaluate();&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the evaluate method is completed the testing is ready to begin to validate that the evaluate method did its job correctly. This is done in a few ways. The first way is that the program checks to make sure the summary file was created. This provides proof that the evaluate method at least ran and tried to create something. the code for this test is fairly simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if output file was created&lt;br /&gt;
File testFile = new File(f.getEvaluationFolder() + &amp;quot;\\evaluations\\AAA_grade_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(testFile.exists());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The next test checks to see that the program created the proper number of output files. This should be 1 for each exam that was submitted into the files folder for evaluation plus an additional 3 files one for the summary, one for any problems that were found in the parser, and one containing the student comments. The code for this test is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if there is the proper number of files&lt;br /&gt;
File inputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\files&amp;quot;);&lt;br /&gt;
File outputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\Evaluations&amp;quot;);&lt;br /&gt;
assertEquals(inputFiles.list().length, (outputFiles.list().length - 3));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The final test checked the output summary of the program against a file that was known to be correct for the first 5 sample files that came with the java code. This test used an API for comparing the contents of 2 files to see if they are the same or different. The correct file is located in another folder in the project called TestingFiles. The code for this test is below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if grade summary output is correct for 5 files&lt;br /&gt;
// uses file in testing file to assert output is correct for 5 evaluations&lt;br /&gt;
File compareFile = new File(f.getEvaluationFolder() + &amp;quot;\\TestingFiles\\Correct_5_evals_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(FileUtils.contentEquals(testFile, compareFile));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
all of the tests passed along with manual testing and checking of all 66 sample files included with the project. This meant our refactoring achieved the same goal of the original program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
The software can be downloaded either as an executable or as a the source code which can be run through Java Eclipse or Intelij IDE. Below is the documentation on how to download and run the software.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140130</id>
		<title>CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_Refactor_Evaluation_of_SQL_Queries&amp;diff=140130"/>
		<updated>2021-10-26T23:41:33Z</updated>

		<summary type="html">&lt;p&gt;Ajshipma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
===About SQL File Evaluation===&lt;br /&gt;
&lt;br /&gt;
SQL File Evaluation is a program developed by DR. Paul Wagner to help with the grading of SQL exams given to students in a database systems class. The program parses through tests given to the students and compares their answer queries to the correct answers for the questions. This tool allows the professor to have tests graded in a matter of seconds that could traditionally take hours to grade. When the software is started it provides a GUI with options to connect to either an Oracle or MySQL database to run the answers against and grade the tests. Instructions must create their own assignment properties files which allows them to distribute points accordingly. Once all the inputs have been entered the software will run all of the tests answers, giving points according to the instructor's assignment properties file and produces an output file for each test as well as an overall summary file that tracks all of the students grades.&lt;br /&gt;
&lt;br /&gt;
[[File:SQLFESS.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Project Goal===&lt;br /&gt;
The goal of this project was to refactor the code of the back end of the software to improve clarity and readability. the main focus was on the refactoring of the evaluate method, which was part of the BackEnd class. The original version of the evaluate method was almost 200 lines of code and involved many different processes. Dr. Wagner said the method started out as a few lines but as the code evolved, it grew much larger and needed to be refactored. Our plan for the refactoring of the code involved a few key tasks which were:&lt;br /&gt;
*Breaking up sections of code that were focusing on the same task into separate methods&lt;br /&gt;
*Create checking functions for conditionals that contained a lot of ANDs and ORs &lt;br /&gt;
*Change names of variables that are only a single letter or a few letters to more descriptive names&lt;br /&gt;
*Add comments to describe what every section of code is doing&lt;br /&gt;
*Add comments to methods we created to state their purpose and keep the same styling.&lt;br /&gt;
*Ensure all code complies with SOLID principles&lt;br /&gt;
Following the refactoring, we also created junit tests to ensure the code was still working with the changes we had made to the code. The testing ensured the proper files were created as well as that all the necessary files were created. additionally the testing checks the summary file and compares it to a summary file that is known to be correct to ensure the summary (and all of the files within it are created properly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
Testing was a necessary step in working on the open source software because when we received the code it was working and we needed to ensure it still worked after we made the changes in refactoring. Java has a testing frame work called junit that allowed us to create unit tests and verify the code worked. we implemented these tests on the the Backend method, which was the section of code that we refactored. &lt;br /&gt;
&lt;br /&gt;
The first step in creating the test was to set up both a front and and a back end object so the code was able to run. This allowed for the tests to emulate the program when it was actually running. We manually set up all of the information needed for the code to connect to the the proper MySQL database so it could grade the exams. The code below shows how the unit test was set up to begin testing the back end class. The JFXPanel is needed to make sure the test runs properly as if a user was using the software. At the end of the code the evaluate method is called which is what we refactored.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class BackEndTests extends AbstractTest {&lt;br /&gt;
&lt;br /&gt;
	@Test&lt;br /&gt;
	void test() {&lt;br /&gt;
		try {&lt;br /&gt;
			// initialize jfx for test to run&lt;br /&gt;
			JFXPanel fxPanel = new JFXPanel();&lt;br /&gt;
			&lt;br /&gt;
			// set default values for testing an input&lt;br /&gt;
			// values will need to be changed for information used in personal testing database&lt;br /&gt;
			String dbmsChoice = &amp;quot;MySQL 8.0&amp;quot;;&lt;br /&gt;
			String dbmsHost = &amp;quot;localhost&amp;quot;;&lt;br /&gt;
			String dbmsPort = &amp;quot;3306&amp;quot;;&lt;br /&gt;
			String dbmsSystemID = &amp;quot;evaltest&amp;quot;;&lt;br /&gt;
			String dbmsUsername = &amp;quot;root&amp;quot;;&lt;br /&gt;
			String dbmsPassword = &amp;quot;****&amp;quot;;&lt;br /&gt;
			String evaluationFolder = &amp;quot;C:\\Users\\andrewshipman\\eclipse-workspace\\SQLFE_project&amp;quot;;&lt;br /&gt;
			String assignPropFile = &amp;quot;assignmentProperties-MySQL&amp;quot;;&lt;br /&gt;
			FrontEnd f = new FrontEnd();&lt;br /&gt;
			&lt;br /&gt;
			// set values for the front end used for testing&lt;br /&gt;
			f.setDbmsChoice(dbmsChoice);&lt;br /&gt;
			f.setDbmsHost(dbmsHost);&lt;br /&gt;
			f.setDbmsPort(dbmsPort);&lt;br /&gt;
			f.setDbmsSystemID(dbmsSystemID);&lt;br /&gt;
			f.setDbmsUsername(dbmsUsername);&lt;br /&gt;
			f.setDbmsPassword(dbmsPassword);&lt;br /&gt;
			f.setEvaluationFolder(evaluationFolder);&lt;br /&gt;
			f.setAssignPropFile(assignPropFile);&lt;br /&gt;
			&lt;br /&gt;
			// setup back end and run evaluation&lt;br /&gt;
			BackEnd b = new BackEnd(f);&lt;br /&gt;
			f.setABackEnd(b);&lt;br /&gt;
			b.transferData(f);&lt;br /&gt;
			b.evaluate();&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the evaluate method is completed the testing is ready to begin to validate that the evaluate method did its job correctly. This is done in a few ways. The first way is that the program checks to make sure the summary file was created. This provides proof that the evaluate method at least ran and tried to create something. the code for this test is fairly simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if output file was created&lt;br /&gt;
File testFile = new File(f.getEvaluationFolder() + &amp;quot;\\evaluations\\AAA_grade_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(testFile.exists());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The next test checks to see that the program created the proper number of output files. This should be 1 for each exam that was submitted into the files folder for evaluation plus an additional 3 files one for the summary, one for any problems that were found in the parser, and one containing the student comments. The code for this test is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if there is the proper number of files&lt;br /&gt;
File inputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\files&amp;quot;);&lt;br /&gt;
File outputFiles = new File(f.getEvaluationFolder() + &amp;quot;\\Evaluations&amp;quot;);&lt;br /&gt;
assertEquals(inputFiles.list().length, (outputFiles.list().length - 3));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The final test checked the output summary of the program against a file that was known to be correct for the first 5 sample files that came with the java code. This test used an API for comparing the contents of 2 files to see if they are the same or different. The correct file is located in another folder in the project called TestingFiles. The code for this test is below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// test if grade summary output is correct for 5 files&lt;br /&gt;
// uses file in testing file to assert output is correct for 5 evaluations&lt;br /&gt;
File compareFile = new File(f.getEvaluationFolder() + &amp;quot;\\TestingFiles\\Correct_5_evals_summary.out&amp;quot;);&lt;br /&gt;
assertTrue(FileUtils.contentEquals(testFile, compareFile));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
all of the tests passed along with manual testing and checking of all 66 sample files included with the project. This meant our refactoring achieved the same goal of the original program.&lt;/div&gt;</summary>
		<author><name>Ajshipma</name></author>
	</entry>
</feed>