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

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 103: Line 103:
*Copied Assignment - rails console
*Copied Assignment - rails console
[[File:CopiedAssignment.jpeg | 500px]]
[[File:CopiedAssignment.jpeg | 500px]]
==Test Plan==
This testing plan outlines 10 test cases to validate the functionality of the Assignment Model.
#Adding a Participant
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.


==Team==
==Team==

Revision as of 03:27, 6 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.


Documentation for methods that were re- implemented:

  1. 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.
  1. 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.
  1. 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).
  1. 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.
  1. destroy(delete_assignment)
    • HTTP Method: DELETE
    • Endpoint:api/v1/assignment/{assignment_id}
    • Input: assignment_id
    • Output: Response code
    • Description: It deletes the specified assignment.
  1. 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.


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/db/schema.rb

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

Test Plan

This testing plan outlines 10 test cases to validate the functionality of the Assignment Model.

  1. Adding a Participant

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

  1. 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.
Outcome: Pass if an error is raised and no participant is added when the user does not exist.

  1. 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.
Outcome: Pass if an error is raised and no duplicate participant is added.

  1. 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.
Outcome: Pass if a participant is successfully removed.

  1. 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.
Outcome: Pass if no participant is removed when trying to remove a non-participant.

  1. 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.
Outcome: Pass if the course is successfully assigned to the assignment.

  1. 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.
Outcome: Pass if an error is raised when trying to reassign the same course.

  1. 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.
Outcome: Pass if the course is successfully removed, and the modified assignment is returned.

  1. 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.
Outcome: Pass if an error is raised when trying to remove a course when course_id is nil.


  1. Copying an Assignment

Steps: Create an assignment, call copy_assignment, and verify the copied assignment has a new name and retains other properties.
Outcome: Pass if a copy of the assignment with a new name is successfully created.

Team

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

Pull Request

References