CSC/ECE 517 Spring 2023 - E2337. Reimplement node hierarchy

From Expertiza_Wiki
Revision as of 00:21, 13 April 2023 by Ashon (talk | contribs) (→‎Class Hierarchy)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

The node models in Expertiza act as a kind of Decorator for underlying database models. They allow relevant information to be accessed and displayed readily. Nodes are hierarchical; they can have arbitrarily deep trees of child and parent nodes. This hierarchical structure allows code reuse and custom implementations to exist alongside default implementations to keep functionalities modular and isolated, minimizing the risk of breakage.

Problem Statement

The existing code for the node hierarchy is largely sufficient, but the documentation and testing are lacking. This project aims to reimplement the existing code but with better naming conventions, documentation, and more comprehensive testing.

Goals:

  • Improve method naming conventions where possible.
  • Refactor specific implementations, such as self.get(), where possible to provide uniformity and avoid DRY issues.
  • Add appropriate comments in existing code in each file, which makes it easier to understand the functionality.
  • Create a method to return true/false based on courses.private [Line 46 & 48 in course_node.rb].
  • Update tests to ensure more comprehensive coverage.

Class Hierarchy

Method names listed in red are existing functions that will be renamed

The Node model is the base class from which all other nodes inherit. The children of the node model are AssignmentNode, CourseNode, FolderNode, QuestionnaireNode, QuestionnaireTypeNode, TeamNode, and TeamUserNode. Node classes take advantage of polymorphism to interact and create the hierarchy, and specific functionality is implemented in the child classes.

Test Plan

course_node_test.rb
Test No. Method Description
1 create_course_node Tests if a course node is saved with data
2 get_course_query_conditions Tests when show and current user are set and you are not a TA
3 table Tests that the table returns courses
4 get_course_query_conditions Tests when show and current user are set and you are a TA
5 get_courses_managed_by_user Tests that user id is returned when you are not a TA
6 get_parent_id Tests returning id of parent folder when parent is found
7 get_parent_id Tests returning nil when parent is not found
8 get_children Tests returning assignment node when children are found
9 get_private Tests whether the course returned is private
10 get_survey_distribution_id Tests that the course returns a survey distribution id
questionnaire_node_test.rb
Test No. Method Description
1 get Tests the questionnaire returns when the user is a teaching assistant
2 get Tests the questionnaire returns when the user is not a teaching assistant
3 get Tests the questionnaire returns with association with student when the user is not a teaching assistant and show is enabled
4 get Tests the questionnaire returns with association with student when the user is a teaching assistant and show is enabled and parent id is enabled
5 table Tests the return of name of table
6 is_leaf Test whether the node is a leaf
7 get_modified_date Test when the questionnaire was last changed
8 get_created_date Test when the questionnaire was created
9 get_private Test when the questionnaire is private
10 get_instructor_id Test whether the instructor id is associated with questionnaire
11 get_name Test whether the questionnaire name is returned
questionnaire_type_node_test.rb
Test No. Method Description
1 get_name Tests the name of the table is returned
2 get Tests the nodes that are associated with the parent
3 get_partial_name Tests the return of the questionnaire_type_actions
4 get Tests the return of the name of the associated tree folder
5 get_children Tests the return of the children
folder_node_test.rb
Test No. Method Description
1 get_name Tests the name of the folder is found
2 get Tests fetching of folder node where type is unknown and the parent is not known
3 get_partial_name Tests the partial name is returned correctly
4 get_child_type Tests the return of child type from the tree folder
5 get_children Tests the return of children with the given parameters
assignment_node_test.rb
Test No. Method Description
1 table Tests the return of the assignments table
2 get Tests the list of assignment nodes are returned based on query parameters
3 is_leaf Tests if the node is a leaf
4 belongs_to_course Tests if the node belongs to course
5 get_instructor_id Tests the instructor id is returned
6 retrieve_institution_id Tests the institution id is returned
7 get_private Tests the private field is returned
8 get_max_team_size Tests the max team size is returned
9 get_is_intelligent Tests the is_intelligent field is returned
10 get_require_quiz Tests the get_required_quiz field is returned
11 get_allow_suggestions Tests the get_allow_suggestions field is returned
12 get_teams Tests the get_teams field is returned
team_node_test.rb
Test No. Method Description
1 table Tests the teams table is returned
2 get Tests that the team node is fetched by parent id
3 get_name Tests the name is returned correctly by ip address
4 get_children Tests the children of the node are fetched properly
team_user_node_test.rb
Test No. Method Description
1 table Tests the teams table is returned
2 get_name Tests that the team user node is fetched by parent id
3 get Tests the name is returned correctly by ip address
4 is_leaf Tests that the node is a leaf