<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mefergio</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mefergio"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mefergio"/>
	<updated>2026-05-13T13:15:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150223</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150223"/>
		<updated>2023-04-26T02:46:52Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. Since there is no back-end with a database, this UI implementation will use dummy JSON objects to replicate the behavior of a back-end database.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor Id, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with dummy JSON objects to populate the table:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Messages will display to indicate a successful or unsuccessful creation. Upon successful creation, a dummy JSON object will be created to mimic the behavior of a record being created in a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with a dummy JSON object being created with valid inputs:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Messages will display to indicate a successful or unsuccessful update. Upon successful update, the matching dummy JSON object will be updated to mimic the behavior of a backend database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the appropriate dummy JSON object being updated upon successful save:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Messages will display to indicate a successful or unsuccessful deletion. Upon successful creation, the matching dummy JSON object will be deleted to mimic the behavior of a record being removed from a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the correct dummy JSON object being deleted upon confirmation:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing for the UI is done via a json server acting as stand-in for the backend, this stand-in does not have all the features of a true back-end but can adequately test the GET, POST, and DELETE restful actions. The json can be hosted by running the following commands:&lt;br /&gt;
  &lt;br /&gt;
  npm instal -g json-server&lt;br /&gt;
  json-server --watch db.json --port 3030&lt;br /&gt;
&lt;br /&gt;
The data in db.json can then be accessed through the normal API calls by redirecting them to the base axios API URL in src/hooks/use-api.js to localhost:3030 from localhost:3030.&lt;br /&gt;
&lt;br /&gt;
[[file: questionnaire_api_explaner.png]]&lt;br /&gt;
&lt;br /&gt;
By making this change we redirect all API requests to our json server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[file: q_api_diagram.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: db_json_image.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The axios request will then search the JSON object for the array elements under &amp;quot;questionnaires&amp;quot; populating the table with the array elements. To change the UI back to production all that is needed is to change the axios base URL back to localhost:3000.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150222</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150222"/>
		<updated>2023-04-26T02:43:24Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. Since there is no back-end with a database, this UI implementation will use dummy JSON objects to replicate the behavior of a back-end database.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor Id, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with dummy JSON objects to populate the table:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Messages will display to indicate a successful or unsuccessful creation. Upon successful creation, a dummy JSON object will be created to mimic the behavior of a record being created in a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with a dummy JSON object being created with valid inputs:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Messages will display to indicate a successful or unsuccessful update. Upon successful update, the matching dummy JSON object will be updated to mimic the behavior of a backend database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the appropriate dummy JSON object being updated upon successful save:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Messages will display to indicate a successful or unsuccessful deletion. Upon successful creation, the matching dummy JSON object will be deleted to mimic the behavior of a record being removed from a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the correct dummy JSON object being deleted upon confirmation:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing for the UI is done via a json server acting as stand-in for the backend, this stand-in does not have all the features of a true back-end but can adequately test the GET, POST, and DELETE restful actions. The json can be hosted by running the following commands:&lt;br /&gt;
  &lt;br /&gt;
  npm instal -g json-server&lt;br /&gt;
  json-server --watch db.json --port 3030&lt;br /&gt;
&lt;br /&gt;
The data in db.json can then be accessed through the normal API calls by redirecting them to the base axios API URL in src/hooks/use-api.js to localhost:3030.&lt;br /&gt;
&lt;br /&gt;
[[file: questionnaire_api_explaner.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: q_api_diagram.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: db_json_image.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Above are diagrams explaining how to set up the db test.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150221</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150221"/>
		<updated>2023-04-26T02:43:05Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. Since there is no back-end with a database, this UI implementation will use dummy JSON objects to replicate the behavior of a back-end database.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor Id, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with dummy JSON objects to populate the table:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Messages will display to indicate a successful or unsuccessful creation. Upon successful creation, a dummy JSON object will be created to mimic the behavior of a record being created in a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with a dummy JSON object being created with valid inputs:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Messages will display to indicate a successful or unsuccessful update. Upon successful update, the matching dummy JSON object will be updated to mimic the behavior of a backend database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the appropriate dummy JSON object being updated upon successful save:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Messages will display to indicate a successful or unsuccessful deletion. Upon successful creation, the matching dummy JSON object will be deleted to mimic the behavior of a record being removed from a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the correct dummy JSON object being deleted upon confirmation:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing for the UI is done via a json server acting as stand-in for the backend, this stand-in does not have all the features of a true back-end but can adequately test the GET, POST, and DELETE restful actions. The json can be hosted by running the following commands:&lt;br /&gt;
  &lt;br /&gt;
  npm instal -g json-server&lt;br /&gt;
  json-server --watch db.json --port 3030&lt;br /&gt;
&lt;br /&gt;
The data in db.json can then be accessed through the normal API calls by redirecting them to the base axios API URL in src/hooks/use-api.js to localhost:3030.&lt;br /&gt;
&lt;br /&gt;
[[file: questionnaire_api_explaner.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: q_api_diagram.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: Db_json_image]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Above are diagrams explaining how to set up the db test.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Db_json_image.png&amp;diff=150220</id>
		<title>File:Db json image.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Db_json_image.png&amp;diff=150220"/>
		<updated>2023-04-26T02:41:26Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150219</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150219"/>
		<updated>2023-04-26T02:39:52Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. Since there is no back-end with a database, this UI implementation will use dummy JSON objects to replicate the behavior of a back-end database.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor Id, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with dummy JSON objects to populate the table:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Messages will display to indicate a successful or unsuccessful creation. Upon successful creation, a dummy JSON object will be created to mimic the behavior of a record being created in a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with a dummy JSON object being created with valid inputs:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Messages will display to indicate a successful or unsuccessful update. Upon successful update, the matching dummy JSON object will be updated to mimic the behavior of a backend database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the appropriate dummy JSON object being updated upon successful save:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Messages will display to indicate a successful or unsuccessful deletion. Upon successful creation, the matching dummy JSON object will be deleted to mimic the behavior of a record being removed from a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the correct dummy JSON object being deleted upon confirmation:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing for the UI is done via a json server acting as stand-in for the backend, this stand-in does not have all the features of a true back-end but can adequately test the GET, POST, and DELETE restful actions. The json can be hosted by running the following commands:&lt;br /&gt;
  &lt;br /&gt;
  npm instal -g json-server&lt;br /&gt;
  json-server --watch db.json --port 3030&lt;br /&gt;
&lt;br /&gt;
The data in db.json can then be accessed through the normal API calls by redirecting them to the base axios API URL in src/hooks/use-api.js to localhost:3030.&lt;br /&gt;
&lt;br /&gt;
[[file: questionnaire_api_explaner.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: q_api_diagram.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: db_json_image]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Above are diagrams explaining how to set up the db test.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Q_api_diagram.png&amp;diff=150218</id>
		<title>File:Q api diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Q_api_diagram.png&amp;diff=150218"/>
		<updated>2023-04-26T02:38:06Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_api_explaner.png&amp;diff=150217</id>
		<title>File:Questionnaire api explaner.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_api_explaner.png&amp;diff=150217"/>
		<updated>2023-04-26T02:36:25Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150216</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150216"/>
		<updated>2023-04-26T02:33:12Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. Since there is no back-end with a database, this UI implementation will use dummy JSON objects to replicate the behavior of a back-end database.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor Id, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with dummy JSON objects to populate the table:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Messages will display to indicate a successful or unsuccessful creation. Upon successful creation, a dummy JSON object will be created to mimic the behavior of a record being created in a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with a dummy JSON object being created with valid inputs:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Messages will display to indicate a successful or unsuccessful update. Upon successful update, the matching dummy JSON object will be updated to mimic the behavior of a backend database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the appropriate dummy JSON object being updated upon successful save:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Messages will display to indicate a successful or unsuccessful deletion. Upon successful creation, the matching dummy JSON object will be deleted to mimic the behavior of a record being removed from a database.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below, with the correct dummy JSON object being deleted upon confirmation:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing for the UI is done via a json server acting as stand-in for the backend, this stand-in does not have all the features of a true back-end but can adequately test the GET, POST, and DELETE restful actions. The json can be hosted by running the following commands:&lt;br /&gt;
  &lt;br /&gt;
  npm instal -g json-server&lt;br /&gt;
  json-server --watch db.json --port 3030&lt;br /&gt;
&lt;br /&gt;
The data in db.json can then be accessed through the normal API calls by redirecting them to the base axios API URL in src/hooks/use-api.js to localhost:3030.&lt;br /&gt;
&lt;br /&gt;
[[file: questionnaire_api_explaner.png]]&lt;br /&gt;
&lt;br /&gt;
[[file: q_api_diagram.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Above are diagrams explaining how to set up the db test.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150130</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150130"/>
		<updated>2023-04-25T03:01:20Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. No records will be created, modified, or deleted since there is no database or back-end code to perform these actions.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Since there is no back-end, this page has been spawned with dummy JSON objects. The proper API call is being made in the background, which can be successfully returned upon linking to a back-end with a database server:&lt;br /&gt;
&lt;br /&gt;
[[File:Get_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires/{id} returns details of a particular questionnaire found by its id. From the /questionnaires page described in the previous section, users will have the option to view a specific questionnaire, which will give a more detailed view of that single record. This page will include the following Questionnaire attributes:  ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.'' This page will also display a list of question records related to the questionnaire selected.&lt;br /&gt;
&lt;br /&gt;
=== Implementation === &lt;br /&gt;
&lt;br /&gt;
In the scope of this project, since there is no back-end, the API response to GET /questionnaires/{id} does not return successfully. Once the back-end is implemented to join the front-end, the API will be able to properly render the questionnaire record.&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Create Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Create_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Update Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Update_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful deletion.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Delete' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing of these functions with the actual API cannot be done as the back-end is not yet implemented. The request promises never receive acknowledgment from the back-end, so we test the request by logging the objects in the console to check that the objects being sent are in the correct format. &lt;br /&gt;
&lt;br /&gt;
[[file: console_logging.png]]&lt;br /&gt;
&lt;br /&gt;
To display and test the edit and delete functions, a json filled with test data is used to mimic the initial get request to the back-end. To display this json change line 146 from &amp;quot;data={tableData}&amp;quot; to &amp;quot;data={DATA}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[file: table_data.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data is imported from a local json file, called records.json, that can be used whenever testing independent of the backend is needed.&lt;br /&gt;
&lt;br /&gt;
[[file: records_json.png]]&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Records_json.png&amp;diff=150116</id>
		<title>File:Records json.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Records_json.png&amp;diff=150116"/>
		<updated>2023-04-25T01:48:16Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150115</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150115"/>
		<updated>2023-04-25T01:43:23Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing &amp;amp; Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. No records will be created, modified, or deleted since there is no database or back-end code to perform these actions.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Since there is no back-end, this page has been spawned with dummy JSON objects. The proper API call is being made in the background, which can be successfully returned upon linking to a back-end with a database server:&lt;br /&gt;
&lt;br /&gt;
[[File:Get_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires/{id} returns details of a particular questionnaire found by its id. From the /questionnaires page described in the previous section, users will have the option to view a specific questionnaire, which will give a more detailed view of that single record. This page will include the following Questionnaire attributes:  ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.'' This page will also display a list of question records related to the questionnaire selected.&lt;br /&gt;
&lt;br /&gt;
=== Implementation === &lt;br /&gt;
&lt;br /&gt;
In the scope of this project, since there is no back-end, the API response to GET /questionnaires/{id} does not return successfully. Once the back-end is implemented to join the front-end, the API will be able to properly render the questionnaire record.&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Create Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Create_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Update Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Update_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful deletion.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Delete' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing of these functions with the actual API cannot be done as the back-end is not yet implemented. The request promises never receive acknowledgment from the back-end, so we test the request by logging the objects in the console to check that the objects being sent are in the correct format. &lt;br /&gt;
&lt;br /&gt;
[[file: console_logging.png]]&lt;br /&gt;
&lt;br /&gt;
To display and test the edit and delete functions, a json filled with test data is used to mimic the initial get request to the back-end. To display this json change line 146 form &amp;quot;data={tableData}&amp;quot; to &amp;quot;data={DATA}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[file: table_data.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The data is imported from a local json file, called records.json, that can be used whenever testing independent of the backend is needed.&lt;br /&gt;
&lt;br /&gt;
[[file: records_json.png]]&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Table_data.png&amp;diff=150112</id>
		<title>File:Table data.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Table_data.png&amp;diff=150112"/>
		<updated>2023-04-25T01:38:03Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Console_logging.png&amp;diff=150111</id>
		<title>File:Console logging.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Console_logging.png&amp;diff=150111"/>
		<updated>2023-04-25T01:37:19Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150110</id>
		<title>CSC/ECE 517 Spring 2023 - E2343. Questionnaire UI</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI&amp;diff=150110"/>
		<updated>2023-04-25T01:36:57Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Project Overview and Justification =&lt;br /&gt;
&lt;br /&gt;
The major crux of the reimplementation of Expertiza is the splitting of Expertiza into a [https://github.com/expertiza/reimplementation-front-end React Front-End] with a [https://github.com/expertiza/reimplementation-back-end Ruby Back-End]. This split should yield a simplification of the code base, and make it easier for developers to make changes if the Expertiza environment isn’t as tightly coupled as before the split. The two ends should interact in terms of the RESTful endpoints, thus separating the implementation of the back-end from the front-end makes both ends more flexible.&lt;br /&gt;
&lt;br /&gt;
Later, when the reimplemented [https://github.com/expertiza/reimplementation-back-end Ruby Back-End] is production-ready, it will be connected to the [https://github.com/expertiza/reimplementation-front-end React Front-End].&lt;br /&gt;
&lt;br /&gt;
React is sound choice for the Expertiza front-end to be reimplemented with because it is flexible, allows reusing components, and is easy for multiple developers to work on at once which boosts the speed of development. Additionally, React was designed with high performance in mind leveraging a framework that allows complex applications run incredibly fast. Due to these benefits, and the bonus that it is easy to learn, a strong interface can be developed quickly for the back-end to integrate with.&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to re-implement the front-end for Questionnaires in React for it to later be connected to the back-end questionnaires_controller and questionnaire model when these back-end reimplementations are production-ready.&lt;br /&gt;
&lt;br /&gt;
'''Important note: This project does not have any back-end functionality whatsoever. There are no controllers or methods implemented. This is a reimplementation of the questionnaire user interface intended for the back-end questionnaire reimplementation that other project teams are working on to eventually connect to. No records will be created, modified, or deleted since there is no database or back-end code to perform these actions.'''&lt;br /&gt;
&lt;br /&gt;
= UI Flow =&lt;br /&gt;
&lt;br /&gt;
The below diagram shows how users will interact and move through the questionnaire user interface:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_UI_flow.png||700px]]&lt;br /&gt;
&lt;br /&gt;
= RESTful Endpoints =&lt;br /&gt;
&lt;br /&gt;
The Questionnaire user interface built with React will respond to following HTTP methods and RESTful endpoints. In each section, you will see that the already re-implemented 'Users' UI is  used as the mock-up plan for our design. Since Users has already been reimplemented to create the base UI, we will work off of this and continue this design in our implementation to ensure consistency and ease of use of the application as a whole.&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires will return all questionnaires in the system. The user interface built by React will mimic the existing Expertiza UI to list these returned questionnaires in a table. Table columns will display values for the following Questionnaire attributes: ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the GET /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Columns 'Name,' 'Type', and 'Updated At' will be searchable and sortable like the first three columns in the image above.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Since there is no back-end, this page has been spawned with dummy JSON objects. The proper API call is being made in the background, which can be successfully returned upon linking to a back-end with a database server:&lt;br /&gt;
&lt;br /&gt;
[[File:Get_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
== GET /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
GET /questionnaires/{id} returns details of a particular questionnaire found by its id. From the /questionnaires page described in the previous section, users will have the option to view a specific questionnaire, which will give a more detailed view of that single record. This page will include the following Questionnaire attributes:  ''Name, Type, Updated At, Instructor, Min Question Score, Max Question Score, and Private.'' This page will also display a list of question records related to the questionnaire selected.&lt;br /&gt;
&lt;br /&gt;
=== Implementation === &lt;br /&gt;
&lt;br /&gt;
In the scope of this project, since there is no back-end, the API response to GET /questionnaires/{id} does not return successfully. Once the back-end is implemented to join the front-end, the API will be able to properly render the questionnaire record.&lt;br /&gt;
&lt;br /&gt;
== POST /questionnaires ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to create a new questionnaire. In order to create a questionnaire, a pop-up will display to capture values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once valid values are entered, users will click the 'Create Questionnaire' button found on the form to call the POST HTTP method. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the POST /users page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_create.png||800px]]&lt;br /&gt;
[[File:Create_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_create.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Create_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Create Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Create_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
* Name, Minimum Question Score, and Maximum Question Score are required.&lt;br /&gt;
[[File:Validations1.png||600px]]&lt;br /&gt;
* Minimum Question Score must be 0 or greater.&lt;br /&gt;
[[File:Validations2.png||600px]]&lt;br /&gt;
* Maximum Question Score must be greater than the Minimum Question Score.&lt;br /&gt;
[[File:Validations3.png||600px]]&lt;br /&gt;
&lt;br /&gt;
These validations are the same on the Update Questionnaire form.&lt;br /&gt;
&lt;br /&gt;
== PUT /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires page described in an earlier section, users will have the option to update an existing questionnaire. In order to edit a questionnaire, a pop-up will display to capture changed values for the following fields: ''Name, Type, Min Question Score, Max Question Score, and Private.''&lt;br /&gt;
&lt;br /&gt;
Validations will display upon inputting values into the form. Once desired values are changed, users will click the 'Update Questionnaire' button found on the form to call the PUT /questionnaires/{id} REST endpoint. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful creation.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to the PUT /users/{id} page which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Update_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_edit.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Update Questionnaire' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Update_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
==== Validations implemented: ====&lt;br /&gt;
&lt;br /&gt;
See [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2343._Questionnaire_UI#Validations_implemented: &amp;quot;Validations implemented&amp;quot; section under POST /questionnaires].&lt;br /&gt;
&lt;br /&gt;
== DELETE /questionnaires/{id} ==&lt;br /&gt;
&lt;br /&gt;
From the /questionnaires and /questionnaires/{id} pages described in earlier sections, users will have the option to delete an existing record.&lt;br /&gt;
&lt;br /&gt;
When a user chooses this option, they will be presented with a pop-up to confirm that the user wants to delete the record to prevent any accidental deletions. If the user is certain they would like to delete the record, they will then click the 'Delete' button found on this confirmation pop-up. Once the back-end is connected, messages will then display to indicate a successful or unsuccessful deletion.&lt;br /&gt;
&lt;br /&gt;
This will look similar in design to DELETE /users/{id} which has already been reimplemented using React shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_user_design_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_user_design2.png||800px]]&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
This has now been implemented according to plan, as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Index_questionnaire_implemented_delete.png||800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_questionnaire_implemented.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the API makes the proper call when the 'Delete' button is clicked. This currently returns with a '404 (Not Found)' error due to the lack of a back-end:&lt;br /&gt;
&lt;br /&gt;
[[File:Delete_apicall.png||800px]]&lt;br /&gt;
&lt;br /&gt;
Once the back-end is implemented to connect with the front-end, the API will be able to return successfully since a database server will be found in the back-end.&lt;br /&gt;
&lt;br /&gt;
= React Components =&lt;br /&gt;
&lt;br /&gt;
The following image shows how the files will be organized to create the necessary components of the Questionnaire UI:&lt;br /&gt;
&lt;br /&gt;
[[File:ReactComponentFiles.png||700px]]&lt;br /&gt;
&lt;br /&gt;
Our main focus will be to ensure that the different tasks in Questionnaires.js are clearly defined since this will be the main component file. Here is a snippet of how the create action will be implemented as an example for how we plan to ensure single responsibility and prevent design smells:&lt;br /&gt;
&lt;br /&gt;
 const onCreateQuestionnaireHandler = useCallback(&lt;br /&gt;
    (questionnaire) =&amp;gt; {&lt;br /&gt;
      if (questionnaire &amp;amp;&amp;amp; questionnaire.name) {&lt;br /&gt;
        console.log(questionnaire);&lt;br /&gt;
        setQuestionnaireData((prevData) =&amp;gt; [...prevData, questionnaire]);&lt;br /&gt;
        dispatch(alertActions.showAlert({&lt;br /&gt;
          variant: &amp;quot;success&amp;quot;,&lt;br /&gt;
          message: `Questionnaire ${questionnaire.name} created successfully!`&lt;br /&gt;
        }));&lt;br /&gt;
      }&lt;br /&gt;
      setShowCreate(false);&lt;br /&gt;
    },&lt;br /&gt;
    [setQuestionnaireData, dispatch]&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= Testing &amp;amp; Test Plan =&lt;br /&gt;
&lt;br /&gt;
Testing of these functions with the actual API cannot be done as the back-end is not yet implemented. The request promises never receive acknowledgment form the back-end, so we test the request by logging the objects in the console to display that the objects being sent are in the correct format. &lt;br /&gt;
&lt;br /&gt;
[[file: console_logging.png]]&lt;br /&gt;
&lt;br /&gt;
To display and test the edit and delete functions, a json filled with test data is used to mimic the initial get request to the back-end. To display this json change line 146 form &amp;quot;data={tableData}&amp;quot; to &amp;quot;data={DATA}&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[file: table_data.png]]&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Delete_user_design.png&amp;diff=149903</id>
		<title>File:Delete user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Delete_user_design.png&amp;diff=149903"/>
		<updated>2023-04-24T01:10:38Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Delete user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Update_user_design.png&amp;diff=149902</id>
		<title>File:Update user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Update_user_design.png&amp;diff=149902"/>
		<updated>2023-04-24T01:09:25Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Update user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149901</id>
		<title>File:Create user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149901"/>
		<updated>2023-04-24T01:09:07Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Create user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149900</id>
		<title>File:Create user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149900"/>
		<updated>2023-04-24T01:08:55Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Create user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149899</id>
		<title>File:Create user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_user_design.png&amp;diff=149899"/>
		<updated>2023-04-24T01:07:53Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Create user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Index_user_design.png&amp;diff=149898</id>
		<title>File:Index user design.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Index_user_design.png&amp;diff=149898"/>
		<updated>2023-04-24T01:05:20Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:Index user design.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148522</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148522"/>
		<updated>2023-03-28T01:27:52Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Creating a method to find topic_id from current user */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Creating a method to find topic_id from current user ====&lt;br /&gt;
One of the unifying themes of the current implementation of these methods is their use of the topic_id argument. The topic_id can be easily found using the assignment id and the participant's id,&lt;br /&gt;
and we can increase reliability and usability by changing the argument for these classes into participant id.&lt;br /&gt;
Below is the implementation of the find_topic_id class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_topic_id(participant_id)&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This method invokes the SingedUpTeam class' topic_id method and gives it the assignment id and the participant id.&lt;br /&gt;
Additionally, the function will return nil, if a nil participant id is given to the function. This is to retain some of the functionality of the student_task view page without changing the view page too much.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = find_topic_id(participant_id)&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;br /&gt;
&lt;br /&gt;
A new rspec file was created in the spec/lib/ folder called due_date_mix_in_spec.rb&lt;br /&gt;
&lt;br /&gt;
The tests for the *_allowed methods were written in the following manor as exemplified by the submission_allowed method.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#submission_allowed' do&lt;br /&gt;
    it 'returns true when the next topic due date is allowed to submit sth' do&lt;br /&gt;
      #allow(assignment).to receive(:check_condition).with('submission_allowed_id', 123).and_return(true)&lt;br /&gt;
      #expect(assignment.submission_allowed(123)).to be true&lt;br /&gt;
      assignment_due_date = double('AssignmentDueDate')&lt;br /&gt;
      assignment_topic_id = double('AssignmentTopicId')&lt;br /&gt;
      allow(SignedUpTeam).to receive(:topic_id).with(1, 1).and_return(assignment_topic_id) # 1,1&lt;br /&gt;
      allow(DueDate).to receive(:get_next_due_date).with(1, assignment_topic_id).and_return(assignment_due_date)&lt;br /&gt;
      allow(assignment_due_date).to receive(:submission_allowed_id).and_return(1)&lt;br /&gt;
      allow(DeadlineRight).to receive(:find).with(1).and_return(double('DeadlineRight', name: 'OK'))&lt;br /&gt;
      expect(assignment.submission_allowed(1)).to be true&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These tests were modified to allow for the tests to access the methods and objects now being used within the methods.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148067</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148067"/>
		<updated>2023-03-23T00:23:21Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Updating Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Creating a method to find topic_id from current user ====&lt;br /&gt;
One of the unifying themes of the current implementation of these methods is their use of the topic_id argument. The topic_id can be easily found using the assignment id and the participant's id,&lt;br /&gt;
 and we can increase reliability and usability by changing the argument for these classes into participant id.&lt;br /&gt;
Below is the implementation of the find_topic_id class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_topic_id(participant_id)&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This method invokes the SingedUpTeam class' topic_id method and gives it the assignment id and the participant id.&lt;br /&gt;
Additionally, the function will return nil, if a nil participant id is given to the function. This is to retain some of the functionality of the student_task view page without changing the view page too much.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = find_topic_id(participant_id)&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;br /&gt;
&lt;br /&gt;
A new rspec file was created in the spec/lib/ folder called due_date_mix_in_spec.rb&lt;br /&gt;
&lt;br /&gt;
The tests for the *_allowed methods were written in the following manor as exemplified by the submission_allowed method.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  describe '#submission_allowed' do&lt;br /&gt;
    it 'returns true when the next topic due date is allowed to submit sth' do&lt;br /&gt;
      #allow(assignment).to receive(:check_condition).with('submission_allowed_id', 123).and_return(true)&lt;br /&gt;
      #expect(assignment.submission_allowed(123)).to be true&lt;br /&gt;
      assignment_due_date = double('AssignmentDueDate')&lt;br /&gt;
      assignment_topic_id = double('AssignmentTopicId')&lt;br /&gt;
      allow(SignedUpTeam).to receive(:topic_id).with(1, 1).and_return(assignment_topic_id) # 1,1&lt;br /&gt;
      allow(DueDate).to receive(:get_next_due_date).with(1, assignment_topic_id).and_return(assignment_due_date)&lt;br /&gt;
      allow(assignment_due_date).to receive(:submission_allowed_id).and_return(1)&lt;br /&gt;
      allow(DeadlineRight).to receive(:find).with(1).and_return(double('DeadlineRight', name: 'OK'))&lt;br /&gt;
      expect(assignment.submission_allowed(1)).to be true&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These tests were modified to allow for the tests to access the methods and objects now being used within the methods.&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148009</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148009"/>
		<updated>2023-03-22T22:53:29Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Creating a method to find topic_id from current user ====&lt;br /&gt;
One of the unifying themes of the current implementation of these methods is their use of the topic_id argument. The topic_id can be easily found using the assignment id and the participant's id,&lt;br /&gt;
 and we can increase reliability and usability by changing the argument for these classes into participant id.&lt;br /&gt;
Below is the implementation of the find_topic_id class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def find_topic_id(participant_id)&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This method invokes the SingedUpTeam class' topic_id method and gives it the assignment id and the participant id.&lt;br /&gt;
Additionally, the function will return nil, if a nil participant id is given to the function. This is to retain some of the functionality of the student_task view page without changing the view page too much.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = find_topic_id(participant_id)&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2323_check_condition_dif.PNG&amp;diff=148006</id>
		<title>File:E2323 check condition dif.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2323_check_condition_dif.PNG&amp;diff=148006"/>
		<updated>2023-03-22T22:45:51Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Mefergio uploaded a new version of File:E2323 check condition dif.PNG&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148004</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=148004"/>
		<updated>2023-03-22T22:43:26Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = find_topic_id(participant_id)&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147745</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147745"/>
		<updated>2023-03-22T02:24:34Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&amp;lt;br&amp;gt;Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147744</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147744"/>
		<updated>2023-03-22T02:24:18Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
Below is a text diff run on the current implementation of check_condition and the updated refactoring of submission allowed to compare the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
Major Changes Include:&lt;br /&gt;
*Argument is now the participant user_id and not topic_id&lt;br /&gt;
*Finding right_id no longer invokes the send method.&lt;br /&gt;
*The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147737</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147737"/>
		<updated>2023-03-22T02:14:51Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&lt;br /&gt;
Finding right_id no longer invokes the send method.&lt;br /&gt;
The conditional statement at the end of the method was also simplified as Deadline is tristate and an additional &amp;quot;or&amp;quot; statement is not needed.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2323_check_condition_dif.PNG&amp;diff=147731</id>
		<title>File:E2323 check condition dif.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2323_check_condition_dif.PNG&amp;diff=147731"/>
		<updated>2023-03-22T02:04:08Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147730</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147730"/>
		<updated>2023-03-22T02:03:36Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:e2323_check_condition_dif.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147729</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147729"/>
		<updated>2023-03-22T02:02:58Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&lt;br /&gt;
[[File:Capture.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147728</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147728"/>
		<updated>2023-03-22T02:02:27Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
[[File:Capture.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147727</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147727"/>
		<updated>2023-03-22T02:00:36Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* Refactor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to search for a due date, we need to have the assignment id and the topic_id. The assignment id is given by the params. &lt;br /&gt;
So if we refactor the method to accept the current participant as an argument, we need to add methods to find the topic_id.&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147722</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147722"/>
		<updated>2023-03-22T01:46:20Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
This method was refactored into the form below. Majorly the argument was changed from topic_id to participant_id in order to make the code more readable, and therefore the function of this method can be parsed more quickly.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(participant_id = nil)&lt;br /&gt;
    # Find topic id for given participant for selected assignment&lt;br /&gt;
    # Return nil if no participant is given&lt;br /&gt;
    topic_id = if participant_id.nil?&lt;br /&gt;
                 yield nil&lt;br /&gt;
               else&lt;br /&gt;
                 SignedUpTeam.topic_id(id, participant_id)&lt;br /&gt;
               end&lt;br /&gt;
    # only need to pass @particpiant to search, can this be done locally&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    # find the quiz allowed id, then check if that deadline is passed&lt;br /&gt;
    right_id = next_due_date.submission_allowed_id&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    # check is assignment action deadline is ok or late (i.e. not no)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name != 'No')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147718</id>
		<title>CSC/ECE 517 Spring 2023 - E2323. Refactor DueDate functionality from assignment.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2323._Refactor_DueDate_functionality_from_assignment.rb&amp;diff=147718"/>
		<updated>2023-03-22T01:37:17Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: Created page with &amp;quot;== E2323. Refactor DueDate functionality from assignment.rb ==  __TOC__  ===About Expertiza===  [http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E2323. Refactor DueDate functionality from assignment.rb ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Project Overview and Mission ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project was to: reduce the length of assignment.rb by removing some related methods into a mixin, refactor several methods using topic_id and check_condition to be more readable, and reduce the use of complex data structures in these methods. The methods removed from assignment.rb include:&lt;br /&gt;
&lt;br /&gt;
*check_condition(column, topic_id)&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
*next_due_date(topic_id)&lt;br /&gt;
*current_stage(topic_id)&lt;br /&gt;
*num_review_rounds  &lt;br /&gt;
*number_of_current_round(topic_id)&lt;br /&gt;
&lt;br /&gt;
Additionally, the check_conditon method was removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=== Refactoring Subjects===&lt;br /&gt;
==== Creating MixIn of Methods ====&lt;br /&gt;
&lt;br /&gt;
All of the methods in this project take topic_id as an argument and therefore could be moved into a mixin. This serves the dual purpose of reducing the length of assignment.rb and allowing other parts of the project to access the due_date functionality. &lt;br /&gt;
&lt;br /&gt;
The methods in the scope of this project were moved from app/models/assignment.rb to lib/due_date_mix_in.rb and placed within the module &amp;quot;DueDateMixIn&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Refactoring *_allowed Methods ====&lt;br /&gt;
===== Current Functions =====&lt;br /&gt;
The following methods all used the check_condition method using a topic_id argument:&lt;br /&gt;
*submission_allowed(topic_id)&lt;br /&gt;
*can_review(topic_id)&lt;br /&gt;
*quiz_allowed(topic_id)&lt;br /&gt;
*metareview_allowed(topic_id)&lt;br /&gt;
&lt;br /&gt;
This method can thus be refactored as a group into a more readable and understandable form.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Check whether review, metareview, etc.. is allowed&lt;br /&gt;
  # The permissions of TopicDueDate is the same as AssignmentDueDate.&lt;br /&gt;
  # Here, column is usually something like 'review_allowed_id'&lt;br /&gt;
  def check_condition(column, topic_id = nil)&lt;br /&gt;
    next_due_date = DueDate.get_next_due_date(id, topic_id)&lt;br /&gt;
    return false if next_due_date.nil?&lt;br /&gt;
&lt;br /&gt;
    right_id = next_due_date.send column&lt;br /&gt;
    right = DeadlineRight.find(right_id)&lt;br /&gt;
    right &amp;amp;&amp;amp; (right.name == 'OK' || right.name == 'Late')&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This was implemented in the other methods like in the example below:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Determine if the next due date from now allows for submissions&lt;br /&gt;
  def submission_allowed(topic_id = nil)&lt;br /&gt;
    check_condition('submission_allowed_id', topic_id)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation can be confusing as it relies on passing a string and topic_id, which are not immediately evident in their function.&lt;br /&gt;
&lt;br /&gt;
===== Refactor =====&lt;br /&gt;
&lt;br /&gt;
=== Updating Tests ===&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023&amp;diff=147689</id>
		<title>CSC/ECE 517 Spring 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023&amp;diff=147689"/>
		<updated>2023-03-22T00:50:06Z</updated>

		<summary type="html">&lt;p&gt;Mefergio: /* OSS Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - E2320. Reimplement the Question hierarchy]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - E2312 + E2313. Reimplement response.rb and responses_controller.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - CSC517. Support provisioning MongoDb via NDB Kubernetes Operator]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - E2316. Reimplement sign_up_sheet_controller.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - E2315. Reimplement signed_up_team.rb, sign_up_topic.rb, sign_up_sheet.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring_2023 - E2323. Refactor DueDate functionality from assignment.rb]]&lt;/div&gt;</summary>
		<author><name>Mefergio</name></author>
	</entry>
</feed>