CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging
E2505. Testing - Answer Tagging
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.
Expertiza
In accordance with the Ruby on Rails framework, Expertiza is an open source software project (OSS) led by Dr. Edward Gehringer. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.
Objective
Our objective is to test two files which are part of this process. We are testing a controller for answer tags which is responsible for fetching, creating, editing and deleting answer tags for a given assignment, questionnaire and user. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.
Controller and Spec Files
Answer Tags
- answer_tags_controller.rb with initial coverage of 0%
- answer_tags_controller_spec.rb
Tag Prompt Deployment
- tag_prompt_deployment.rb with initial coverage of 17.65%
- tag_prompt_deployment_spec.rb
Testing Implementation
Answer Tags Controller
This controller [1] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags.
Methods
action_allowed? : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.
- Use Cases:
- - When it is a student session, access to index should be allowed.
- - When it is a student session, access to create_edit should be allowed.
- - When the session user is a student, access to unsupported actions like destroy or show should be denied.
- - When the session user is a **teaching assistant**, access to `index` should be allowed.
- - When the session user is a **teaching assistant**, access to `create_edit` should be allowed.
- Edge Cases:
- - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.
- - When a user with no role assigned tries to access index or create_edit, access should be denied.
- - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.
- - When the action parameter is missing or unrecognized, access should be denied regardless of user role.
index : Returns all the tag prompt deployments in JSON format
- Use Cases:
- * For any authenticated user above student access:
- - When anyone above student privilege is authorized
- - When there are no tag prompts deployed, a empty list should be displayed.
- - When there is 1 tag prompt deployed, 1 should be displayed.
- - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.
- - When there is an answer tag associated with an user_id, it should be filtered by an user_id.
- - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.
- - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.
- - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.
- - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.
- - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.
- - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.
- - When provided with one incorrect and one correct param, then no records should be returned.
- * When there are multiple tags are present for an assignment, all related tags should be returned.
- * When a user request is made, it should return records related to current user only.
- Edge Cases:
- * When user_id is undefined, an empty list of tags prompts should be returned.
- * When assignment_id is undefined, an empty list of tags prompts should be returned.
- * When questionnaire_id is undefined, an empty list of tags prompts should be returned.
- * When an unauthorized user tries to access the #index, the user should be returned to root_page.
- * When an invalid parameter is passed, the system should not break and should return valid results.
- * When there are large number of answer tags, the tags are handled properly.
create_edit : Allows the creation or updating of an answer tag for the current student.
- Use Cases:
- - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.
- - When a student accesses an existing tag, the tag is updated with the new provided value.
- - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.
- - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.
- Edge Cases:
- - When no answer_id is provided, the system raises an error and does not create or update the tag.
- - When no tag_prompt_deployment_id is provided, the system raises an error.
- - When no value is provided, the tag creation/update is rejected with an error.
- - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.
Tag Prompt Deployment Controller
The controller [2] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.
Methods
tag_prompt : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.
- Use Cases:
- * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.
- Edge Cases:
- * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.
get_number_of_taggable_answers : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.
- Use Cases:
- * When user_id is nil, it should return an error message.
- * When answer_length_threshold is null, it should return a count of tangible answers.
- * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.
- Edge Cases:
- * When there are no responses, it should return zero as the count of taggable answers.
- * When questions are empty, it should return count of taggable answers as zero.
assignment_tagging_progress : Accesses the percentage progress of answer tagging.
- Use Cases:
- * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.
- * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.
- Edge Cases:
- * When no questions are found, it should return an empty list.
- * When there are no teams or questions, it should return an empty list.
Testing Details
Demo Videos
Using RSpec
We implemented tests in answer_tags_controller_spec.rb and tag_prompt_deployment_spec.rb.
How to See Test Coverage
- Run RSpec for [3],
sudo su
,yum install lynx
, thenlynx ./coverage/index.html
- Run RSpec for [4],
sudo su
,yum install lynx
, thenlynx ./coverage/index.html
Results
Both files are 100% covered and additional testing was added to ensure a solid groundwork.
answer_tags_controller_spec.rb
- Coverage: 100%
- Hits/line: 63.2
tag_prompt_deployment_spec.rb
- Coverage: 100%
- Hits/line: 5.2
Future Work
1. Modify base files
a. correct several method names (ex: not named after a verb (assignment_tagging_progress)) b. make tag_prompt_deployment.rb more readable and better commented c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)