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

From Expertiza_Wiki
Revision as of 02:23, 16 November 2023 by Asaxen24 (talk | contribs)
Jump to navigation Jump to search

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