CSC/ECE 517 Fall 2021 - E2169. Testing - Answer Tagging: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 79: Line 79:
* <code> When only one parameter is passed, the corresponding answer tags should be populated.</code>
* <code> When only one parameter is passed, the corresponding answer tags should be populated.</code>


<code>Edge test case:</code>
<code>Edge test cases:</code>
* <code> When user_id is nil, 0 tags prompts should be returned.</code>
* <code> When user_id is nil, 0 tags prompts should be returned.</code>
* <code> When questionnaire_id is nil, 0 tags prompts should be returned.</code>
* <code> When questionnaire_id is nil, 0 tags prompts should be returned.</code>

Revision as of 01:49, 30 November 2021

Background

Answer tagging (see answer_tab.rb and wiki) helps determine a few metrics on a student’s responses to a questionnaire. Students can tag these metrics for other students for things such as “Positive Tone” or “Suggest Solutions”.

These specs below all need to be further developed to cover missing methods/lines. Some structures currently exist at the top of spec files (such as assignments, participants, etc) to help make writing tests easier. Please feel free to add to these and write extra tests to cover any edge cases you may think of.

As an instructor on an assignment, going to Etc/View Reports/Answer Tagging Report will show student answer tagging. You will be able to see the percentage of answers tagged, # of answers tagged, # not tagged, and # of taggable answers for each student on a questionnaire.

Fig. 1


Project Purpose

The objective of the project is unit testing of functionality in these two ruby files and increasing the coverage.

Answer_tags_controller_spec

Tag_prompt_deployment_spec

Initial Coverage

Answer_tags_controller_spec : 0% Covered

Tag_prompt_deployment_spec : 18% Covered

Missed Methods

  • app/controllers/answer_tags_controller.rb
    • action_allowed?
    • index
    • create_edit
    • destroy
  • app/models/tag_prompt_deployment.rb
    • get_number_of_taggable_answers
    • assignment_tagging_progress


Project Design

In this project, we have two controllers to be tested using Rspec Unit testing.

The ER diagram of the parent tables is given below for reference (Source: Answer_tags).


The flow diagrams below show how controllers in this project are connected with interrelated classes, methods, and views.

Testing Plan

Controller: answer_tags_controller.rb

Existing coverage = 0%

Description: The purpose of this controller is to track down the total number of tags done by the students. The database structure for the answer_tags can be found here [1]

Methods

1. action_allowed? ( params: action )

Description: To allow the functionality only if the accessing user is having student privileges (current_user_has_student_privileges?)

Use cases:

  • When the session is null, Access should be denied
  • When the session is of student type, access should be allowed and operation should be executed.


2. index ( params : assignment_id, questionnaire_id, user_id )

Description: Populates the tags by fetching the records from AnswerTag corresponding to each TagPromptDeployment based on the filers provided as params.

Use cases:

  • When all valid params are passed, the function should populate the answer tags.
  • When user_id is provided, answer tags specific to that user should only be populated.
  • When questionnaire_id is provided, answer tags specific to that questionnaire should only be populated.
  • When assignment_id is provided, answer tags specific to that assignment should only be populated.
  • When only one parameter is passed, the corresponding answer tags should be populated.

Edge test cases:

  • When user_id is nil, 0 tags prompts should be returned.
  • When questionnaire_id is nil, 0 tags prompts should be returned.
  • When assignment_id is nil, 0 tags prompts should be returned.


3. create_edit ( params : answer_id, tag_prompt_deployment_id, value )

Description: Fetches the answer tag with the params provided and then updates the respective tag values by the updated values provided as params.

Use cases:

  • When the existing tag is found based on the params passed, the existing tag should be updated with new values.

Controller: tag_prompt_deployment.rb

Existing coverage = 18%

Description: This Controller is when a user (with instructor privilege) wants to see tagging summary of every user that participated in a tagging assignment.

Methods

1. tag_prompt Description: tag_prompt has existing test cases scoring 18 percentage coverage. Additional testing is not required.

2. get_number_of_taggable_answers ( params: user_id)

Description: To calculate total taggable answers reviewed by a user that participated in the given tagging assignment. user_id is the parameter passed to this method. An individual and his team will have the same score. Fig 1: The last column values are processed by this method.

Use cases:

  • when a team has given any response then count of taggable answer > 0
  • When a question or a response does not exists then count of taggable answer = 0 (extreme case)
  • When answer_length_threshold not set, count taggable answer
  • When answer_length_threshold is set, count taggable answer


3. assignment_tagging_progress

Description: To compute the number of tagged answers, number of untagged answers, and percentage of answers tagged by the users that participated in the tagging Assignment to a particular question. Fig 1: First three columns after the 2nd column onwards are updated with results obtained from this method.

Use cases:

  • When not team participated in the assignment, assert count(user_answer_tagging) =0
  • When the question does not exist, assert count(user_answer_tagging) =0
  • When multiple rounds of review, render ReviewResponseMap and assert response object
  • When single round of review, render ResponseMap and assert response object
  • When answer_length_threshold is SET, number of answers and when answer_length_threshold is NOT SET, number of answers
  • When route is success answer_tagging object structure matching

Edge cases:

  • There are no teams associated with the assignment.
  • There are no questions in the questionnaire that have the question type specified in the TagPromptDeployment object.
  • The assignment is set to vary by round.
  • The assignment is set not to vary by round.
  • There are multiple tags.

Bug Fixing of Additional Issues

Model: tag_prompt_deployment.rb (method: get_number_of_taggable_answers)

An additional issue in the method get_number_of_taggable_answers. The error message is as shown below which indicates string concatenation fails between integer and string data types.

TypeError: no implicit conversion of Fixnum into String at line 23 https://github.com/expertiza/expertiza/blob/beta/app/models/tag_prompt_deployment.rb.

This issue is fixed by correcting the syntax of the two-strings concatenation. After fixing the code is

answers = answers.where(conditions: "length(comments) < #{self.answer_length_threshold}" ) unless self.answer_length_threshold.nil?


Model: tag_prompt_deployment.rb (method: assignment_tagging_progress)

Failure/Error: answers = answers.where("length(comments) > ?", self.answer_length_threshold.to_s) unless self.answer_length_threshold.nil?
     
     NoMethodError:
       undefined method `where' for #<Array:0x00000003424b60>

This issue was resolved by using Arrays.select to achieve the same functionality.

There was another small error in which the TeamsUser user was not found, and the resolution was to find the User model for each TeamsUser.user_id. A similar issue was found with TeamsUser

Results

Test cases are added to cover all functionality. With test cases the new coverage is as follows:

tag_prompt_deployment.rb: Coverage = 99%

answer_tags_controller.rb: Coverage = 100%

Edge cases that are considered in the project are:

- - -


Collaborators

Nicholas Himes (Mentor)

1. Aditya Khadse

2. Alec Landow

3. Rageeni Sah

4. Sayali Pranab

Relevant Links

Main Expertiza repository can be found at GitHubExp

Our forked repository can be found at Github