CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring & Grades

From Expertiza_Wiki
Jump to navigation Jump to search

Project Overview

In Expertiza, scoring and grades are a large part of its implement that benefit for both instructor and students. They play important role for students to examine others' work and for the instructor to grade students' performance. However, they are not fully tested and considered thoroughly. The main purpose of this project is to refactor grades in beta and adding test cases would be the method to do so.

Objectives

Our objectives for this project are the following:

  • Develop the files below further to cover missing methods and lines.
  • Write extra tests to cover any edge cases that may need to be considered.
  • Increase the coverage of the spec.

Files Involved and original coverage

  • Grades_controller_spec [here]-86%covered
  • Grades_helper_spec [here]-58%covered
  • Response_spec [here]-86.4%covered

Run the file

  rspec ./spec/helpers/Grades_helper_spec.rb
  rspec ./spec/controller/Grades_controller_spec.rb
  rsepc ./spec/model/Response_spec.rb

Test Plan

We look into these file and their related functions. The initial coverage is high, but we still want to add more test cases to cover almost every situation. Therefore, the functions below are what we plan to work on in this project. We are going to run the initial code first and see which lines are not executed and add the corresponding test cases to increase the coverage.

Relevant Methods

Grades_controller_spec

  • action_allowed
  • update
  • save_grade_and_comment_for_submission
  • self_review_finished

Grades_helper_spec

  • accordion_title(last_topic, new_topic)
  • has_team_and_metareview
  • view_heatgrid(participant_id, type)
  • penalty

Response_spec

  • maximum_score
  • email
  • populate_new_response
  • questionnaire_by_answer
  • delete
  • self.calibration_results_info
  • notify_instructor_on_difference
  • done_by_staff_participant?
  • dispaly_as_html
  • construct_review_response

GradesController_spec

action_allowed

This function allows students to view their score and view their team by checking if current user has student privilege. We plan to add test on method of allowing current user to view team. If current user is a student, user id is expected to be found in AssignmentParticipant.


  • Initial Coverage:


  • Test Cases Added:

update

In this function, it returns a message depending on whether the participant grade is nil or not and redirects to a edit action. We plan to add test on computing the message if the participant score is not nil, it is expected to print a sentence like "A score of ... has been saved for ...".



  • Initial Coverage:


  • Test Cases Added:

save_grade_and_comment_for_submission

This function saves the grade and comment after submission. We plan to add a test case that fails to save the submission. When we look up in flash, it is expected to be "$ERROR_INFO".



  • Initial Coverage:


  • Test Cases Added:


self_review_finished

This is a boolean function that tells if the students finished their self reviews or not. We plan to add a test case that shows if the system enables student to self review, which means the student hasn't submit the self review and the test is expected to get false.




  • Initial Coverage:


  • Problem:

The self_review_finished method is a private method, difficult to test every scenarios through the public interface.

GradesHelper_spec

accordion_title(last_topic, new_topic)

This function would render different view according to the comparison of last_topic and new_topic. We plan to create three contexts to test it as below:

1. When last_topic is empty, the function should return view which contains the new_topic
2. last_topic doesn't equal to new_topic, the function should return view which contains the new_topic
3. Other situation, the function should return nothing


  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

has_team_and_metareview?

In this function, we plan to complete cases to cover all the function. The cases include: 1. When an assignment is a team assignment and has meta review, the return values should contain true_num = 2. 2. When an assignment is a team assignment or has meta review, the return values should contain true_num = 1. 3. When an assignment is a personal assignment and doesn't has meta review, the return values should contain true_num = 0.


  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

  • The comment part is the original code that shows bug:

view_heatgrid(participant_id, type)

This function would get all the questionnaires belonging to a participant, and filter questionnaires according to 'type' parameter, and then collect questionnaire to render the target view So, we plan to check if the return value only contends the certain type of questionnaires.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

penalty

This function would calcualte the penalties of an assignment. We plan to give an assignment and check if its field 'is_penalty_calculated' change to 'true'

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

Response_spec

maximum_score

This function returns the highest possible score for this response, and it only accepts the scorable question and non nil answer. We plan to add a test case that a response doesn't have any score, in this case, total_weight is expected to remain 0 and result should be 0 as well.


  • Initial Coverage:


  • Latest Coverage:

  • Test Cases Added:

email

This function finds out which kind of survey is it and searches the parent of the result. Parent is used as a common variable name for either an assignment or a course. We plan to add test case that the type of survey is associated with course, so we would directly get the assignment from participant, which is the response of course survey.



  • Initial Coverage:


  • Latest Coverage:

  • Test Cases Added:

populate_new_response

This function returns a Response object used to populate @response instance object with the correct response according to review round or with a new response object that the controller can use. We plan to add test case that concludes three scenarios: A response exists after the latest submission, A response exists before the latest submission, No response exists in current submission. For the first case, it is expected to get the original response. As for the rest, it is expected to populate new response.


  • Initial Coverage:

  • Latest Coverage:


  • Test Cases Added:

questionnaire_by_answer

In this function, a questionnaire can be found by its answer, and this assignment can be gotten through either participant or map. We plan to add a test case that is to obtain the assignment through participant by a given answer.

  • Initial Coverage:


  • Latest Coverage:

  • Test Cases Added:

delete

Before the response is destroyed, its response scores will also be destroyed.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

self.calibration_results_info(calibration_id, response_id, assignment_id)

This method is used when a student views their calibration results for a particular review/assignment. It should return the reference of calibration response, review response, and questions.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

notify_instructor_on_difference

This method will send a mail via Mailer when the review score is "abnormal," meaning that this score assigned in this review differs from the score assigned to the same work by another review by more than the "Notification Limit" defined on the Rubrics tab for creating/editing this assignment. The method should pass the data with the correct format to the Mailer and deliver the mail.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

done_by_staff_participant?

This method will check if the review is done by a staff, which include TAs and instructors.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

dispaly_as_html(prefix = nil, count = nil, _file_url = nil, show_tags = nil, current_user = nil)

This method will return the data of the repsonse within HTML format, and might invoke several private methods that needs to be test.

  • Initial Coverage:

  • Test Cases Added:

construct_review_response(code, self_id, show_tags = nil, current_user = nil)

This method is a private method in response model, which will only be called by the display_as_html method. In this method, if the response contains additional commends, it will replace '/n' to '
'.

  • Initial Coverage:

  • Latest Coverage:

  • Test Cases Added:

Results

Collaborators

  • Li Yu Shan (lshan3)
  • Chao Ting Hung (chung4)
  • Chen Ni Liu (cliu43)
  • Kan No Lee (klee32)

Relevant Links

Main Expertiza Repository can be found here.

Our forked Repository can be found here.

Demo

URL link of video of Scoring & Grades tests running and passing:

  • Grades_controller_spec [here]
  • Grades_helper_spec [here]
  • Response_spec [here]