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

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

Packages of information are distributed based on the context that they are delivered. For courses, information and functionalities are packaged into Course nodes and team information is packaged into Team nodes. These nodes are supplemented by the base node class in order to inherit basic functionality/attributes such as the type of node, the parent id, identifying whether the node is a leaf or not, etc. This hierarchical structure allows for code reuse and custom implementations to exist alongside default implementations in order to keep functionalities modular and isolated, minimizing the risk of breakage.



Problem Statement

First off, the node models have a problem with repetition in two major areas. First off, Node.rb defines a bunch of functions to fetch a given property such as name, directory, creation_date, etc. These functions all fetch data from the same entity with the same filter parameters. Instead of having five functions, we can consolidate down to one function where a given parameter would be passed in. This parameter could specify which field we want to fetch on a given entity. For example, we could fetch the creation date of an entity by invoking a call like such: node.getProperty("creation_date"). The getProperty function would be responsible for parsing the parameter and determine which field needs to be returned back to the user.

Secondly, there are methods that are repetitive between assignment_node.rb and course_node.rb. In order to reduce repetition, the shared methods can be pulled out into a module, which then the two node models would import in order to use the methods. Some of these repetitive methods are get_instructor_id, retrieve_institution_id, get_private, etc.


Test Plan

Example of test cases added to test review_response_map

review_response_map_test.rb
Test No. Description
1 Tests if the right questionnaire is accessed
2 Tests if the right fields are exported
3 Tests if the metareview_response_maps function is working
4 Tests if the reviewer obtained is the right one
5 Tests if the reviewer can be retrieved with id
6 Tests if the last review for a team is available
7 Tests if the team email functionality is working
8 Tests if the prepare_final_review_versions function is returning right review id

Class Hierarchy

The node.rb model is the base class from which all other nodes inherit from. The children of the node model are assignment_node.rb, course_node.rb, folder_node.rb, questionnaire_node.rb, questionnaire_type_node.rb, team_node.rb, and team_user_node.rb. The functionalities of these nodes are implemented by polymorphism and the subclasses implement the specifications of the base class.