CSC/ECE 517 Fall 2019 - E1968. Fixes for adding members to teams

From Expertiza_Wiki
Jump to navigation Jump to search

This wiki page is for the description of changes made under E1968 OSS assignment for Fall 2019, CSC/ECE 517.

Background

This project fixed several bugs related to Assignment teams. Expertiza has Assignment objects, which represent an assignment usually assigned by an in structor for a course. If the instructor allowe teams for the assignment, the participants in that course can create teams with each other. Also, the instructor can create teams or add team membert to a exsiting team. Our project is focused on fixing bugs related to these functionalities.

Problem Description

In this project we fixed three problems, the problems and the way to reproduce them is shown below.
1. Adding a member from the UI (typing the ID into the textbox) raises an error.

   Reproduciton:
   (1)Login as an instructor.
   (2)Go to Assignment tab under Manage.
   (3)Click any assignment for example : OSS project & documentation.
   (4)Select Create Teams.
   (5)Select Add Team Member option for any team. 
   (6)Adding a member from the UI (typing the ID into the textbox) raises an error.

2. Impersonating a student who has an assignment without affiliating to any course will cause an error.

   (1)Login as an instructor.
   (2)Go to the Assignment tab under Manage.
   (3)Click the "+" button and then create a new assignment named "E1968" without choosing any course from the course dropdown menu.
   (4)Go back to the Assignment tab under Manage, and click the "Add participants" of the assignment of "E1968".
   (5)Fill in the form "Enter a user login" with a student's name, for instance, "student7515".
   (6)Go to the Impersonate User tab under Manage, fill in the form "Enter  user account" with the student "student7515".
   (7)Clicking the button "Impersonate" raises an error.

3. Creating a team by uploading a file.

   (1)Login as an instructor.
   (2)Go to Assignment tab under Manage.
   (3)Click any assignment.
   (4)Click Create Teams.
   (5)Click Import Teams.
   (6)Create teams by clicking the button "Import".

Solutions

1. The reason for the first problem was actually due to a key error. In teams_users_controller.rb line 35, 'assignment_id' was used to find AssignmentParticipant. But in the model of AssignmentParticipant, the foreign key name is acctually 'parent_id'. So, by changing it, problem solved.

2. After our inspection into the file of "expertiza/app/controllers/student_task_controller.rb", we found the reason for the second problem was that before we used t.assignment.course.instructor_id, we had to confirm that t.assignment.course was not equal to nil. If there existed an assignment without being subject to any course, when this assignment was assigned to a specific student, it would raise an error when it came to showing the tasks of the student. Thus, in order to show student tasks correctly, we changed the code to at first checking whether the t.assignment.course was nil. If t.assignment was not nil, we could use t.assignment.course.instructor_id to retrieve data needed from the database, otherwise, we used t.assignment.instructor_id directly to retrieve data needed.

3. The third one works fine.

Testing Details

RSpec

For each of the problems, we did feature tests with Rspec. They all follows the reproduction steps decribed above.

Feature Testing

  • Problem 1: assignment_team_member_spec.rb

Following steps needs to be performed to test this code:
1. Login as instructor.
2. Create a course and an assignment under that course.
2. Add at least two students as participants to the assignment.
3. Create a team for the assignment.
4. Add a participant to the team.
5. Check if the student is a team member of that team.

  • Problem 2: impersonate_student_spec.rb

Following steps needs to be performed to test this code:
1. Create data for the test including an instructor, a student and an assignment without being subject to any course.
2. Log in as instructor.
3. Add the student as the participant of the assignment created.
4. Impersonate the student from the instructor account.
5. Check if the page of displaying tasks of the student is correctly shown.

  • Problem 3: assignment_team_import_spec.rb

Following steps needs to be performed to test this code:
1. Login as instructor.
2. Create a course and an assignment under that course.
3. Create teams for the assignment by importing a file.
4. Check if these teams belongs to the assignment.


Run the test locally:

  • Problem 1: The snapshot of results in the console when running rspec spec/features/assignment_team_member_spec.rb


  • Problem 2: The snapshot of results in the console when running rspec spec/features/impersonate_student_spec.rb


According to above snapshot, after we applied changes in original code, the test was able to passed. Besides, we confirmed that our changes were successful by taking the same actions in our browser.


  • Problem 3:The snapshot of results in the console when running rspec spec/features/assignment_team_import_spec.rb