CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller (Phase 2): Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "==Expertiza== [http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. Instructors have the ability to add new projects,...")
 
No edit summary
Line 100: Line 100:
*reimplementation-back-end/blob/main/db/schema.rb
*reimplementation-back-end/blob/main/db/schema.rb
==Test Plan==
==Test Plan==
This testing plan outlines 10 test cases to validate the functionality of the Assignment Model.
{| class="wikitable" style="margin-left:30px"
* Adding a Participant
|-
! Sr No !! Test Description
|-
| 1 || **team_assignment?**
|-
| 1.1 || Scenario 1: Max_team_size is greater than 0. Expected: true
|-
| 1.2 || Scenario 2: Max_team_size is equal to 0. Expected: false
|-
| 1.3 || Scenario 3: Max_team_size is less than 0. Expected: false
|-
| 2 || **topics**
|-
| 2.1 || Scenario 1: Sign_up_topics is empty. Expected: false
|-
| 2.2 || Scenario 2: Sign_up_topics is not empty. Expected: true
|-
| 3 || **calibrated?**
|-
| 3.1 || Scenario 1: The object is calibrated. Expected: true
|-
| 3.2 || Scenario 2: The object is not calibrated. Expected: false
|-
| 4 || **teams**
|-
| 4.1 || Scenario 1: Teams are present. Expected: true
|-
| 4.2 || Scenario 2: Teams are not present. Expected: false
|-
| 5 || **valid_num_review**
|-
| 5.1 || Scenario 1: Number of reviews required is greater than the number of reviews allowed. Expected: Error message
|-
| 5.2 || Scenario 2: Number of meta-reviews required is greater than the number of meta-reviews allowed. Expected: Error message
|-
| 6 || **dynamic_reviewer_assignment?**
|-
| 6.1 || Scenario 1: Review assignment strategy is RS_AUTO_SELECTED. Expected: true
|-
| 6.2 || Scenario 2: Review assignment strategy is not RS_AUTO_SELECTED. Expected: false
|-
| 7 || **badge?**
|-
| 7.1 || Scenario 1: Has_badge is nil. Expected: false
|-
| 7.2 || Scenario 2: Has_badge is true. Expected: true
|-
| 7.3 || Scenario 3: Has_badge is false. Expected: false
|-
| 8 || **create_node**
|-
| 8.1 || Scenario 1: Parent node exists. Expected: New node created with parent_id set.
|-
| 8.2 || Scenario 2: Parent node does not exist. Expected: New node created with no parent_id set.
|-
| 9 || **varying_rubrics_by_round?**
|-
| 9.1 || Scenario 1: Rubrics of a given type exist in round 2. Expected: true
|-
| 9.2 || Scenario 2: Multiple rubrics of a given type exist in round 2. Expected: true
|-
| 9.3 || Scenario 3: No rubrics of a given type exist in round 2. Expected: false
|-
| 10 || **num_review_rounds**
|-
| 10.1 || Scenario 1: No due dates. Expected: 0
|-
| 10.2 || Scenario 2: Single due date with round 1. Expected: 1
|-
| 10.3 || Scenario 3: Multiple due dates with different rounds. Expected: Highest round number
|-
| 10.4 || Scenario 4: Multiple due dates with the same round number. Expected: Highest round number
|-
| 11 || **review_questionnaire_id**
|-
| 11.1 || Scenario 1: No round_number and topic_id provided. Expected: id of the current round's review questionnaire.
|-
| 11.2 || Scenario 2: No round_number and topic_id provided, no next due date. Expected: nil
|-
| ... || (continue for other scenarios)
|-
| 12 || **pair_programming_enabled?**
|-
| 12.1 || Scenario 1: Pair programming is enabled. Expected: true
|-
| 12.2 || Scenario 2: Pair programming is disabled. Expected: false
|-
| 13 || **staggered_and_no_topic?**
|-
| 13.1 || Scenario 1: Staggered deadline is enabled, topic_id not provided. Expected: true
|-
| 13.2 || Scenario 2: Staggered deadline is enabled, topic_id provided. Expected: false
|}


Steps: Create a user and assignment, call add_participant, check for an increase in Assignment Participants count, and verify correct association
<br>Outcome: Pass if a user is added as a participant.


* Error When Adding Non-Existing Participant
Steps: Create an assignment, call add_participant with a non-existing user ID, expect a RuntimeError, and check the AssignmentParticipants count remains unchanged.
<br>Outcome: Pass if an error is raised and no participant is added when the user does not exist.
* Error When Adding Duplicate Participant
Steps: Create a user and assignment, add the user as a participant, try to add the same user again, expect a RuntimeError, and check no duplicate participant is added.
<br>Outcome: Pass if an error is raised and no duplicate participant is added.
* Removing a Participant
Steps: Create an assignment and user, add the user as a participant, call remove_participant, check for a decrease in AssignmentParticipants count, and ensure the participant is removed.
<br>Outcome: Pass if a participant is successfully removed.
* Trying to Remove a Non-Participant
Steps: Create an assignment and user, attempt to remove a non-participant, and ensure the AssignmentParticipants count remains unchanged.
<br>Outcome: Pass if no participant is removed when trying to remove a non-participant.
* Successful Assignment of Course
Steps: Create a new assignment and a course, call .assign_courses_to_assignment, and check if the assignment's course_id is set correctly.
<br>Outcome: Pass if the course is successfully assigned to the assignment.
* Error on Reassignment
Steps: Create a new assignment and a course, set the assignment's course_id to the course's ID, try to assign the same course again, and expect an error with a specific message.
<br>Outcome: Pass if an error is raised when trying to reassign the same course.
* Removing Assignment from Course
Steps: Create an assignment and course, assign the course to the assignment, call remove_assignment_from_course, and verify the course_id is set to nil and the modified assignment is returned.
<br>Outcome: Pass if the course is successfully removed, and the modified assignment is returned.
* Error on removing course when course_id is nil
Steps: Create a new assignment and a course, try removing a course from an assignment when course_id is already nil.
<br>Outcome: Pass if an error is raised when trying to remove a course when course_id is nil.
* Copying an Assignment
Steps: Create an assignment, call copy_assignment, and verify the copied assignment has a new name and retains other properties.
<br>Outcome: Pass if a copy of the assignment with a new name is successfully created.
<br> Here is a video of successfully running the test cases:
[https://drive.google.com/file/d/1jfDoyaiux8XXxq3ibklnZrOMKZwf2SVS/view?usp=sharing]


== Manual Testing Using POSTMAN ==
== Manual Testing Using POSTMAN ==

Revision as of 02:23, 16 November 2023

Expertiza

Expertiza is a Ruby on Rails based open source project. Instructors have the ability to add new projects, assignments, etc., as well as edit existing ones. Later on, they can view student submissions and grade them. Students can also use Expertiza to organize into teams to work on different projects and assignments and submit their work. They can also review other students' submissions.

Problem Statement

A reimplementation was required for assignment model and assignment controller. The following tasks were required for the reimplementation :

  1. Creating necessary associations between assignment model and other models such as course, participants, instructor.
  2. Reimplementation for the following methods in assignment model and necessary controller actions and routes :
    • add_participant  : Allows a user with an appropriate role to add a participant to an assignment
    • remove_participant  : Allows a user with an appropriate role to remove a participant from an assignment.
    • assign_courses_to_assignment  : Associates the assignments with a given course.
    • remove_assignment_from_course : Dissociates an assignment from a course.
    • copy_assignment  : Creates a copy of an assignment
    • delete  : CRUD operation for deleting the assignment and necessary dependencies.
    • Writing rspec and rswag test case for assignment model and controller respectively.


Tasks Completed

Migrations - Before starting with the implementation, we created necessary migrations for fixing up the schema. The fields course_id and instructor_id were added to the Assignment Model as attributes instead of being added as foreign key references. Hence necessary migrations were created for removing these fields and adding them as references to the Assignment model.

The following migration files were added : 20231104070639_remove_instructor_id_from_assignments.rb 20231104071922_add_instructor_to_assignments.rb 20231105193016_remove_course_id_from_assignments.rb 20231105193219_add_course_to_assignments.rb

Models -

Assignment_Participant A new model - Assignment_Participant was added as it was missing from the current implementation. This model was required for implementing the add_participant method.

Assignment.rb -

  1. We followed the single responsibility principle where all the methods relevant to assignment instances were implemented in the Assignment model.
  2. The method ‘set_handle’ required as a sub-method for add_participant method was moved to assignment_participant.rb as it is used for setting the handle for a participant instance.
  3. A separate method for deleting the assignment was also not needed in the new implementation as it is already being fulfilled by the CRUD operation in the assignment controller.
  4. The implementation for assign_course_to_assignment seemed incorrect as it was only setting @course variable with the course having course_id. We added the correct method to the new implementation where course_id was assigned to the assignment.


Documentation for methods that were re-implemented:

  • add_participant
    • HTTP Method: POST
    • Endpoint: api/v1/{assignment_id}/add_participant/{user_id}
    • Input: assignment_id, user_id
    • Output: Response code and JSON of assignment participant
    • Description: It allows super admins, admins, instructors, and teaching assistants to add a particular participant (student) from the given assignment.
  • remove_participant
    • HTTP Method: DELETE
    • Endpoint: api/v1/{assignment_id}/remove_participant/{user_id}
    • Input: assignment_id, user_id
    • Output: Response code
    • Description: It allows super admins, admins, instructors, and teaching assistants to remove a particular participant (student) from the given assignment.
  • remove_assignment_from_course
    • HTTP Method: PATCH
    • Endpoint: api/v1/{assignment_id}/remove_assignment_from_course
    • Input: assignment_id
    • Output: Response code and JSON of updated assignment
    • Description: It makes the course_id of the given assignment null (removes the assignment from its course).
  • assign_courses_to_assignment
    • HTTP Method: PATCH
    • Endpoint: api/v1/{assignment_id}/assign_courses_to_assignment/{course_id}
    • Input: assignment_id, course_id
    • Output: Response code and JSON of updated assignment
    • Description: It assigns the given course_id to the given assignment.
  • destroy(delete_assignment)
    • HTTP Method: DELETE
    • Endpoint:api/v1/assignment/{assignment_id}
    • Input: assignment_id
    • Output: Response code
    • Description: It deletes the specified assignment.
  • copy_assignment
    • HTTP Method: POST
    • Endpoint: api/v1/{assignment_id}/copy_assignment
    • Input: assignment_id
    • Output: Response code and JSON of copied assignment.
    • Description: It copies the assignment and stores the copy with the name “Copy of” + the original assignment name.

Controller - Assignment_Controller.rb For the new methods added in the assignment model, we added corresponding actions in the assignment controller with the same name and routes in config.rb as mentioned in above documentation.


Files added / modified

  • reimplementation-back-end/blob/main/app/models/course.rb
  • reimplementation-back-end/blob/main/app/models/assignment.rb
  • reimplementation-back-end/blob/main/app/models/assignment_participant.rb
  • reimplementation-back-end/blob/main/app/controllers/api/v1/assignments_controller.rb
  • reimplementation-back-end/blob/main/config/routes.rb
  • reimplementation-back-end/blob/main/spec/models/assignment_spec.rb
  • reimplementation-back-end/blob/main/spec/factories/factories.rb
  • reimplementation-back-end/blob/main/db/schema.rb

Test Plan

Sr No Test Description
1 **team_assignment?**
1.1 Scenario 1: Max_team_size is greater than 0. Expected: true
1.2 Scenario 2: Max_team_size is equal to 0. Expected: false
1.3 Scenario 3: Max_team_size is less than 0. Expected: false
2 **topics**
2.1 Scenario 1: Sign_up_topics is empty. Expected: false
2.2 Scenario 2: Sign_up_topics is not empty. Expected: true
3 **calibrated?**
3.1 Scenario 1: The object is calibrated. Expected: true
3.2 Scenario 2: The object is not calibrated. Expected: false
4 **teams**
4.1 Scenario 1: Teams are present. Expected: true
4.2 Scenario 2: Teams are not present. Expected: false
5 **valid_num_review**
5.1 Scenario 1: Number of reviews required is greater than the number of reviews allowed. Expected: Error message
5.2 Scenario 2: Number of meta-reviews required is greater than the number of meta-reviews allowed. Expected: Error message
6 **dynamic_reviewer_assignment?**
6.1 Scenario 1: Review assignment strategy is RS_AUTO_SELECTED. Expected: true
6.2 Scenario 2: Review assignment strategy is not RS_AUTO_SELECTED. Expected: false
7 **badge?**
7.1 Scenario 1: Has_badge is nil. Expected: false
7.2 Scenario 2: Has_badge is true. Expected: true
7.3 Scenario 3: Has_badge is false. Expected: false
8 **create_node**
8.1 Scenario 1: Parent node exists. Expected: New node created with parent_id set.
8.2 Scenario 2: Parent node does not exist. Expected: New node created with no parent_id set.
9 **varying_rubrics_by_round?**
9.1 Scenario 1: Rubrics of a given type exist in round 2. Expected: true
9.2 Scenario 2: Multiple rubrics of a given type exist in round 2. Expected: true
9.3 Scenario 3: No rubrics of a given type exist in round 2. Expected: false
10 **num_review_rounds**
10.1 Scenario 1: No due dates. Expected: 0
10.2 Scenario 2: Single due date with round 1. Expected: 1
10.3 Scenario 3: Multiple due dates with different rounds. Expected: Highest round number
10.4 Scenario 4: Multiple due dates with the same round number. Expected: Highest round number
11 **review_questionnaire_id**
11.1 Scenario 1: No round_number and topic_id provided. Expected: id of the current round's review questionnaire.
11.2 Scenario 2: No round_number and topic_id provided, no next due date. Expected: nil
... (continue for other scenarios)
12 **pair_programming_enabled?**
12.1 Scenario 1: Pair programming is enabled. Expected: true
12.2 Scenario 2: Pair programming is disabled. Expected: false
13 **staggered_and_no_topic?**
13.1 Scenario 1: Staggered deadline is enabled, topic_id not provided. Expected: true
13.2 Scenario 2: Staggered deadline is enabled, topic_id provided. Expected: false


Manual Testing Using POSTMAN

Postman was used for manually testing the added method in assignment.rb and their respective controllers actions and routes. Before testing any of these methods using Postman, a request to /login needs to be sent with user_name an password fields which sends a authentication token. This token needs to be added in Postman’s ‘Authorization’ tab as ‘Bearer token’ before any further requests can be made.


  • add_participant - POSTMAN

  • new participant created - rails console

  • remove_participant - POSTMAN

  • remove_assignment_from_course - POSTMAN

  • assign_courses_to_assignment - POSTMAN

  • destroy(delete_assignment) - POSTMAN

  • Copy_assignment- POSTMAN

  • Original Assignment - rails console

  • Copied Assignment - rails console


Team

Mentor
  • Ameya Vaichalkar
Members
  • Bhavya Harchandani <bharcha@ncsu.edu>
  • Akshat Saxena<asaxen24@ncsu.edu>
  • Mitali Sethi <msethi@ncsu.edu>

Pull Request

References