<?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=Agupta38</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=Agupta38"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Agupta38"/>
	<updated>2026-08-09T06:37:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137197</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137197"/>
		<updated>2020-11-17T06:38:16Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of parsing user comments functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this parsing answer query into &amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; is of one of the most important task of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored(Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
We have made video demonstration of our project but we have made a small gif to give brief idea of how parsing and evaluation is being done.&lt;br /&gt;
So once you run the application, it start parsing the student answer files. Once parsed, then it moves to evaluation state. After evaluation is done, User/ Instructor can see the grade summary in grade_summary file generated.&lt;br /&gt;
&lt;br /&gt;
[[File:Gif.gif]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - https://www.youtube.com/watch?v=cNIVvMuNcOc&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137193</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137193"/>
		<updated>2020-11-17T06:35:39Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of parsing user comments functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this parsing answer query into &amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; is of one of the most important task of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored(Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
We have made video demonstration of our project but we have made a small gif to give brief idea of how parsing and evaluation is being done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - https://www.youtube.com/watch?v=cNIVvMuNcOc&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Gif.gif&amp;diff=137191</id>
		<title>File:Gif.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Gif.gif&amp;diff=137191"/>
		<updated>2020-11-17T06:32:34Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:Gif.gif&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Gif.gif&amp;diff=137190</id>
		<title>File:Gif.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Gif.gif&amp;diff=137190"/>
		<updated>2020-11-17T06:30:42Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137189</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137189"/>
		<updated>2020-11-17T06:29:48Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of parsing user comments functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this parsing answer query into &amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; is of one of the most important task of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored(Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Gif.gif]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
We have made video demonstration of our project but we have made a small gif to give brief idea of how parsing and evaluation is being done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - https://www.youtube.com/watch?v=cNIVvMuNcOc&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137188</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=137188"/>
		<updated>2020-11-17T06:28:37Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of parsing user comments functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this parsing answer query into &amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; is of one of the most important task of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored(Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
We have made video demonstration of our project but we have made a small gif to give brief idea of how parsing and evaluation is being done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - https://www.youtube.com/watch?v=cNIVvMuNcOc&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136984</id>
		<title>File:DiffGetAnswerquery.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136984"/>
		<updated>2020-11-16T07:28:16Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:DiffGetAnswerquery.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136983</id>
		<title>File:DiffGetAnswerquery.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136983"/>
		<updated>2020-11-16T07:27:52Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:DiffGetAnswerquery.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136982</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136982"/>
		<updated>2020-11-16T07:25:16Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of parsing user comments functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this parsing answer query into &amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; is of one of the most important task of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored(Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136981</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136981"/>
		<updated>2020-11-16T07:19:46Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
Segregation of this functionality into above method of one of the most important and critical tasks of refactoring. Diff Comparison in figure shown below highlights how some of the code from the original single monolith function/method &amp;lt;code&amp;gt;readSubmission&amp;lt;/code&amp;gt; was refactored (Trimmed) by above new method &lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136980</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136980"/>
		<updated>2020-11-16T07:15:44Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136979</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136979"/>
		<updated>2020-11-16T07:14:57Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffParseComments.jpg&amp;diff=136978</id>
		<title>File:DiffParseComments.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffParseComments.jpg&amp;diff=136978"/>
		<updated>2020-11-16T07:14:31Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136975</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136975"/>
		<updated>2020-11-16T07:11:18Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
[[File:DiffParseComments_def.jpg]|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136949</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136949"/>
		<updated>2020-11-16T06:10:23Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg|1100px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136948</id>
		<title>File:DiffGetAnswerquery.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136948"/>
		<updated>2020-11-16T06:00:03Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:DiffGetAnswerquery.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136947</id>
		<title>File:DiffGetAnswerquery.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136947"/>
		<updated>2020-11-16T06:00:00Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:DiffGetAnswerquery.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136946</id>
		<title>File:DiffGetAnswerquery.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DiffGetAnswerquery.jpg&amp;diff=136946"/>
		<updated>2020-11-16T05:59:26Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136945</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136945"/>
		<updated>2020-11-16T05:59:06Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:DiffGetAnswerquery.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136944</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136944"/>
		<updated>2020-11-16T05:58:10Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136943</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136943"/>
		<updated>2020-11-16T05:57:12Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:GetAnswerquery_3.jpg&amp;diff=136942</id>
		<title>File:GetAnswerquery 3.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:GetAnswerquery_3.jpg&amp;diff=136942"/>
		<updated>2020-11-16T05:48:32Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:GetAnswerquery 3.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:GetAnswerquery_3.jpg&amp;diff=136941</id>
		<title>File:GetAnswerquery 3.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:GetAnswerquery_3.jpg&amp;diff=136941"/>
		<updated>2020-11-16T05:46:50Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136940</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136940"/>
		<updated>2020-11-16T05:45:47Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Code updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===General Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
# The readSumissions function contains 6 new functions defined within Submission.java and 3 new functions defined within Utilities.java. The function now follows the SOLID and DRY principles which are achieved by doing the following.&lt;br /&gt;
## Extracting lines of code into the methods getFileMetadata and reachFirstQuestion to make them adhere to single responsibility.&lt;br /&gt;
## Extracting the regex code that makes comparison for a new question in method Utilities.isQuestionFound and achieving interface segregation and DRY.&lt;br /&gt;
# The method skipExtraQueries and getQuestionNumber are added in Utilities.java to parsing anomalies in file such as extra statements before first question and add pattern support for special characters('.' and ')') before a question. &lt;br /&gt;
# The methods getAnswerQuery and ParseComments replace the lines of code which optimize file reading using buffered reader, improving performance and also improving code readability.&lt;br /&gt;
# The file SubmissionTests.java is added in JUnit folder to test the new readsubmissions method and provides a 100 percent coverage.   &lt;br /&gt;
# Travis CI is created for the original open source repo for providing feature to run build and provide coverage whenever a commit is pushed into the repository.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
===Flowchart===&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Finite State Machine===&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
===Code updates===&lt;br /&gt;
The main focus of our refactoring is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. The file changes are given below and the entire diff is available in the pull request added in references.&lt;br /&gt;
&lt;br /&gt;
'''readSubmission method Changes'''&lt;br /&gt;
&lt;br /&gt;
1. The general changes include removing usage of several boolean flags and declaring all called variables at the start of the function.&lt;br /&gt;
[[File:GeneralChanges.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. These changes are added to encapsulate the part of readSubmissions that gets the file headers present at the beginning of the line and also parses everything before reaching the first question.&lt;br /&gt;
[[File:Metadata.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. The method isQuestionFound is used to replace redeclaration of pattern and matcher. The definition is added in &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt; and details are added below in this document.&lt;br /&gt;
[[File:find_replace_questionFound.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. The method getQuestionNumber replaces the code that was used to store the question number in variable &amp;lt;code&amp;gt;qNumStr&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:QuestionNum_used.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. The methods below replace the lines of code that parse the comments to get the question and answer in the file and store it in &amp;lt;code&amp;gt;QuestionAnswer&amp;lt;/code&amp;gt; arrayList. Also the method reachNewQuestion replaces the code that finds the next question.&lt;br /&gt;
&lt;br /&gt;
[[File:ParseComments.jpg]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Method Definitions Implemented'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;parseComments&amp;lt;/code&amp;gt; - The method definition to parse all comments using the BufferedReader instance before reaching the AnswerQuery. &lt;br /&gt;
[[File:ParseComments_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getanswerQuery&amp;lt;/code&amp;gt; - The method definition to get AnswerQuery from the line and return the answer as a string. &lt;br /&gt;
[[File:GetAnswerquery_1.jpg]]&lt;br /&gt;
[[File:GetAnswerquery_2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:GetAnswerquery_3.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getFileMetadata&amp;lt;/code&amp;gt; The method definition that abstracts out the code to get the file name and the student's name. &lt;br /&gt;
[[File:metadata_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachFirstQuestion&amp;lt;/code&amp;gt; The method definition that abstracts out the code that parses file to reach the first question. &lt;br /&gt;
[[File:reachFirstqn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;reachNextQuestion&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that parses file for comments before reaching the next question. &lt;br /&gt;
[[File:reachNextQn.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;writeToQuestionAnswerList&amp;lt;/code&amp;gt; The method definition that is abstracting out the code that writes the Question and Answer pair in the QuestionAnswer arraylist. &lt;br /&gt;
&lt;br /&gt;
[[File:questionAnswer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The secondary file that is refactored is &amp;lt;code&amp;gt;Utilities.java&amp;lt;/code&amp;gt;. The file changes are below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getQuestionNumber&amp;lt;/code&amp;gt; The method is implemented to read the line and extract the string that marks the question number using regex pattern matching.&lt;br /&gt;
[[File:questionnumber.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;isQuestionFound&amp;lt;/code&amp;gt; The method that is used to extract declaration of pattern match statements. This helps avoid the use of regex in the file and provides encapsulation like other helper functions.&lt;br /&gt;
&lt;br /&gt;
[[File:isquestionFound_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;skipExtraQueries&amp;lt;/code&amp;gt; The method is implemented to remove any extra queries or anomalies in the file such as incompatible format in instructor comment. This works by parsing the line and matching the regex for instructor comment and not saving any information that does not match the regex.&lt;br /&gt;
&lt;br /&gt;
[[File:skipqueries_def.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
 QuestionAnswer a = answers.get(0);&lt;br /&gt;
 assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
    &lt;br /&gt;
 String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
       &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
       &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
       &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
    //Test cross join&lt;br /&gt;
    &lt;br /&gt;
 a = answers.get(5);&lt;br /&gt;
 qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
     &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
     &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    MINUS\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
     &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
 assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from 154 LoC to 43 LoC.&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle by creating 7 methods which improves code maintainability.&lt;br /&gt;
#Created 2 methods to solve issue in parsing files with unusual occourences and increasing robustness of application. &lt;br /&gt;
#Improved coverage of method readSubmission to 100%.&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
# Improve support for Travis CI and integrate with the main repository.&lt;br /&gt;
# Replace hard coded character matching with general regex matching for all methods in Utilites.java like skipInstructorComments, processUserComments, etc.&lt;br /&gt;
# Include option to perform JUnit testing with MySQL DB connnector which is currently exclusive for Oracle DB. &lt;br /&gt;
# Migrate the code to support the latest eclipse IDE and drivers and make JavaScript replacement for Nashorn Engine.&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
# Repository of the main project - https://github.com/wagnerpj42/SQL-File-Evaluation&lt;br /&gt;
# Project Board - https://github.com/nickrgarner/SQL-File-Evaluation/projects/1&lt;br /&gt;
# Youtube link of the screencast - TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136568</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136568"/>
		<updated>2020-10-29T02:12:30Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''File(s) being Refactored'''==&lt;br /&gt;
The main file that needs to be refactored is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136567</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136567"/>
		<updated>2020-10-29T02:11:51Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136566</id>
		<title>File:Submission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136566"/>
		<updated>2020-10-29T02:11:28Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:Submission.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136565</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136565"/>
		<updated>2020-10-29T02:09:07Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is &amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void &amp;lt;code&amp;gt;readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter)&amp;lt;/code&amp;gt; which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136564</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136564"/>
		<updated>2020-10-29T02:08:14Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is  (&amp;lt;code&amp;gt;Submission.java&amp;lt;/code&amp;gt;). You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136563</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136563"/>
		<updated>2020-10-29T02:05:38Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136562</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136562"/>
		<updated>2020-10-29T02:05:26Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===Reference===&lt;br /&gt;
Below is the github link of this application&lt;br /&gt;
https://github.com/wagnerpj42/SQL-File-Evaluation&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136561</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136561"/>
		<updated>2020-10-29T02:04:54Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. Below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===Reference===&lt;br /&gt;
Below is the github link of this application&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136560</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136560"/>
		<updated>2020-10-29T02:04:10Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Proposed Future Scope */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
===Reference===&lt;br /&gt;
Below is the github link of this application&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136559</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136559"/>
		<updated>2020-10-29T02:03:05Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java. You can see it highlighted below. You can also see in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
It has a function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
You can also view the complete function in the reference github link&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity. below you could see many line of logic where SQL query is being read from students answer is refactored into a separate function. This is not yet final but still will give reader an idea of what we are planning to do. In future as we move forward this block would be modified accordingly&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Diff.jpg&amp;diff=136549</id>
		<title>File:Diff.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Diff.jpg&amp;diff=136549"/>
		<updated>2020-10-29T01:45:53Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136548</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136548"/>
		<updated>2020-10-29T01:45:22Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As of now we have created &lt;br /&gt;
&lt;br /&gt;
[[File:Diff.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ReadSubmission.jpg&amp;diff=136547</id>
		<title>File:ReadSubmission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ReadSubmission.jpg&amp;diff=136547"/>
		<updated>2020-10-29T01:43:30Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:ReadSubmission.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ReadSubmission.jpg&amp;diff=136546</id>
		<title>File:ReadSubmission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ReadSubmission.jpg&amp;diff=136546"/>
		<updated>2020-10-29T01:42:03Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136533</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136533"/>
		<updated>2020-10-29T01:02:18Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long. Below is snippet of the function&lt;br /&gt;
&lt;br /&gt;
[[File:ReadSubmission.jpg]]&lt;br /&gt;
&lt;br /&gt;
The initial approach is to divide the code logic into functions to give it more modularity.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136530</id>
		<title>File:Submission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136530"/>
		<updated>2020-10-29T00:59:17Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:Submission.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136529</id>
		<title>File:Submission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136529"/>
		<updated>2020-10-29T00:58:32Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:Submission.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136528</id>
		<title>File:Submission.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission.jpg&amp;diff=136528"/>
		<updated>2020-10-29T00:57:39Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136527</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136527"/>
		<updated>2020-10-29T00:57:18Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.jpg]]&lt;br /&gt;
&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136526</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136526"/>
		<updated>2020-10-29T00:56:33Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
&lt;br /&gt;
[[File:Submission.png]]&lt;br /&gt;
&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136523</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136523"/>
		<updated>2020-10-29T00:53:38Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136522</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136522"/>
		<updated>2020-10-29T00:53:09Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Refractory of File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
The main file that needs to be refactored is Submission.java.&lt;br /&gt;
Its has function public void readSubmission(String submissionFileName, PrintWriter commWriter, PrintWriter parseWriter) which is the main work horse but is around 280 lines long.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136518</id>
		<title>CSC/ECE 517 Fall 2020 - SQLFE. Refactor Submission.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_SQLFE._Refactor_Submission.java&amp;diff=136518"/>
		<updated>2020-10-29T00:38:31Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /* Finite State Machine */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
The SQLFE (SQL File Evaluation) open source software system automatically grades a set of files containing SQL queries.  This project, written in Java, focuses on redesigning and rewriting one large method that parses one student submission file and builds a data structure for later evaluation. &lt;br /&gt;
&lt;br /&gt;
===About SQLFE===&lt;br /&gt;
: SQLFE is an open source software tool to assist computer science instructors by automatically grading assignments or tests involving multiple submitted files consisting of SQL queries added to a template submission file.  Developed by Paul Wagner and others at the University of Wisconsin – Eau Claire, SQLFE allows instructors to specify a weighted set of tests for each assignment question, which are then used to evaluate a submitted query and/or compare that submitted query against an instructor-supplied solution query.  &lt;br /&gt;
:SQLFE also generates a detailed output file for each submission, which can be returned as feedback.  SQLFE reduces instructor grading time for SQL queries and allows quicker, more detailed feedback as compared to hand grading.  SQLFE source code, sample submission and instructor-generated files, and documentation can be found at https://github.com/wagnerpj42/SQL-File-Evaluation .  &lt;br /&gt;
: SQLFE is written entirely in Java.  Since SQLFE executes SQL queries as part of its evaluation, it must be connected to an SQL database management system (DBMS).   Currently Oracle and MySQL DBMSs are supported.&lt;br /&gt;
&lt;br /&gt;
:Here is what the home page of SQLFE looks like:  &lt;br /&gt;
:[[File:sqlfe1.png]]&lt;br /&gt;
:On the left side are the settings to connect to a DB server of your choice, either Oracle or MySQL. The right side menu is used to select which student submissions to read.&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
: Mentor: Dr. Paul Wagner&lt;br /&gt;
# Jack Maccdonald (jmmacdo4)&lt;br /&gt;
# Nick Garner (nrgarner)&lt;br /&gt;
# Sumitosh Pal (spal3)&lt;br /&gt;
# Abhishek Gupta (agupta38)&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Submission.java is the main file in SQLFE responsible for parsing student submissions. As the capabilities of SQLFE have increased, so has the complexity and responsibilities of the readSubmission method. At over 200 LoC, this method has become bloated and cumbersome. The challenge for this team is to refactor readSubmission and Submission.java to maintain proper functionality with proper code structure that will lend itself to future development.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
     ---------------------------------Maybe need to rephrase these points a bit, or maybe not--------------------------- ------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
# Restructure and rewrite the readSubmission() method in the Submission.java class, adding any new sub-methods desired, to accurately and efficiently parse any student submission file that follows the assignment instructions.&lt;br /&gt;
#* Each question number and submitted SQL query for that question should be placed in a new QuestionAnswer object in the class-level answers arraylist variable.&lt;br /&gt;
#* Any user SQL comments (either -- single line SQL comments or /* */ multi-line SQL comments) should be written out to the AAA_student_comments.out file through the commWriter object.  Each user SQL comment line may be written out separately, though if possible it would be fine to write out any user SQL comment as a whole, especially for multi-line /* */ comments.&lt;br /&gt;
#* Any parsing problems that cannot be handled should be identified and written out to the AAA_parse_problems.out file through the parseWriter object.&lt;br /&gt;
# Optionally use utility methods in the Utilities.java class without modifing or removing any existing methods in Utilities.java as they are used elsewhere. Any new or modified methods should be given new method names if they remain in the Utilities.java class file.&lt;br /&gt;
# Place sub-methods created as part of the new readSubmission() method functionality in either Submission.java or Utilities.java as design logic dictates.&lt;br /&gt;
# Good functionality and good code commenting is expected. &lt;br /&gt;
#* Optionally provide suggestions for improving the Submission class overall.&lt;br /&gt;
#* Report any issues or possible improvements in working on this project by communicating them to Paul Wagner&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
   ----------------------------------------------------------------------Till here--------------------------------------------------------------------------- &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Initial Approach===&lt;br /&gt;
* '''Make use of the BufferedReader class to parse input files on a per-character basis.''' This will allow us to detect things like comment syntax, improper formatting of solutions, and many other criteria to control the parsing exactly as desired by the project mentor.&lt;br /&gt;
* '''Use a Finite State Machine to build submissions.''' One of the challenges with any parsing method is the variety of input available that can create tricky edge cases. We intend to help control this with a well defined finite state machine to keep track of what sort of text we are currently parsing. For example, if we parse the opening to a comment, we will treat all subsequent text as a comment until we parse a comment close. This will also allow us to define discrete transition methods and states to drastically reduce the current readSubmission method's code complexity.&lt;br /&gt;
* '''Abstract commonly used code to helper methods in Utility.java.''' We will be looking closely for opportunities to abstract out commonly used to code to helper functions. These can be used in conjunction with the aforementioned boolean flags to help parse large chunks of input depending on surrounding syntax.&lt;br /&gt;
* '''Create unit and user tests for Submission.java.''' Currently, only the classes dealing with grading have attached unit tests. We will be creating unit tests as well as user tests through the UI to help ensure that our refactor of readSubmission is working properly. More details below in Test Plan.&lt;br /&gt;
&lt;br /&gt;
=='''Rationale'''==&lt;br /&gt;
Most of the requirements from Dr. Wagner are related to making the readSubmission() method in Submission.java modular i.e refactor/split the function accordingly to meet standard function requirements. These can involve using helper functions from Utilities.java as well. Secondary requirements are handling several scenarios in the submission document that might appear due to students’ mistakes or other factors. &lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
Initially, we would fork the repository and create another branch where we will commit our changes. Dr Wagner has agreed to add us team members as collaborators for open source SQLFE, so we can create a branch and add changes to it. &lt;br /&gt;
We also intend to add unit tests using JUnit4. After all the changes have been reviewed we would merge the changes back to main/master.&lt;br /&gt;
&lt;br /&gt;
===Changes introduced===&lt;br /&gt;
'''TBD'''&lt;br /&gt;
&lt;br /&gt;
=='''Flowchart'''==&lt;br /&gt;
The diagram below shows the overall flow of the SQLFE java application from starting the application to closing the window. The part highlighted in red contains the section that our project will focus upon primarily.&lt;br /&gt;
[[File:FlowchartSQLFE.jpg]]&lt;br /&gt;
&lt;br /&gt;
=='''Finite State Machine'''==&lt;br /&gt;
The diagram below shows our plan for controlling the flow of parsing in readSubmission. We will be using states with controlled transitions to track where we are in the submission and to build valid QuestionAnswer objects to interact with the grading utility.&lt;br /&gt;
[[File:SQLFEFSM.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Refractory of File'''==&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
Currently, our main focus with testing is the creation of unit and user tests for the Submission.java class. This will involve creating test submission files with edge case text in them to try and break the parser.&lt;br /&gt;
&lt;br /&gt;
Examples include:&lt;br /&gt;
* Student answers inline with instructor comments&lt;br /&gt;
* Student comments written with instructor comment syntax&lt;br /&gt;
* Student answers with no terminating semicolon&lt;br /&gt;
* Student answers with inline comments&lt;br /&gt;
* Student comments with no termination&lt;br /&gt;
* Non-ASCII characters&lt;br /&gt;
* Submissions with question numbering different from the assignment&lt;br /&gt;
&lt;br /&gt;
Here are some simple unit test examples. The first tests a simple multi line join command. The second one makes sure we pick up a more complicated command with different indentation and a nested cross join.&lt;br /&gt;
&lt;br /&gt;
            QuestionAnswer a = answers.get(0);&lt;br /&gt;
            assertEquals(&amp;quot;1&amp;quot;, a.getQNumStr());&lt;br /&gt;
            String qString = &amp;quot;SELECT CustID, FName, LName, AccClosedDate\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer C\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;JOIN Account A ON (C.CustID = A.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE A.AccOpenLocation = 'Central' AND A.AccClosedDate &amp;gt;= '01-MAR-2017'&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
            //Test cross join&lt;br /&gt;
            a = answers.get(5);&lt;br /&gt;
            qString = &amp;quot;SELECT CustID, FName, LName\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;FROM Customer\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;WHERE CustID IN(\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    CROSS JOIN Account A1\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;        MINUS\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    SELECT CustID\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    FROM Customer C2\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    JOIN Account A2 ON (C2.CustID = A2.Customer)\n&amp;quot; +&lt;br /&gt;
                    &amp;quot;    WHERE AccStatus = 'Active')&amp;quot;;&lt;br /&gt;
            assertEquals(qString, a.getActualQuery().toString());&lt;br /&gt;
&lt;br /&gt;
In addition, we will be devising a series of blackbox user tests to ensure that our updates to readSubmission do not break any functionality in the UI. This will involve users attempting use cases such as creating an assignment, grading a single submission, and grading a batch of submissions.&lt;br /&gt;
&lt;br /&gt;
Beyond testing, we will be implementing some repository features to help improve the project’s accessibility for Open Source work. This includes setting up continuous integration features like TravisCI and Coveralls, to ensure that proposed changes do not break the build or significantly lower code coverage.&lt;br /&gt;
&lt;br /&gt;
=='''Results'''==&lt;br /&gt;
&lt;br /&gt;
===Impact===&lt;br /&gt;
#Refactored readSubmission from XX LoC to YY LoC&lt;br /&gt;
#Abstracted commonly used behavior to maintain DRY principle&lt;br /&gt;
#Improved speed of submission parsing by ZZ%&lt;br /&gt;
&lt;br /&gt;
===Added Features===&lt;br /&gt;
Continuous integration: TravisCI and Coveralls run unit tests on every commit to maintain code quality.&lt;br /&gt;
&lt;br /&gt;
===Proposed Future Scope===&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2064._Refactor_reputation_web_service_controller.rb&amp;diff=135703</id>
		<title>CSC/ECE 517 Fall 2020 - E2064. Refactor reputation web service controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2020_-_E2064._Refactor_reputation_web_service_controller.rb&amp;diff=135703"/>
		<updated>2020-10-20T03:08:12Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: /*  Refactor send_post_request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Introduction to Expertiza'''===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. &lt;br /&gt;
Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.&lt;br /&gt;
==='''About Reputation Web Service Controller'''===&lt;br /&gt;
Expertiza allows student work to be peer-reviewed, since peers can provide more feedback than the instructor can. However, if we want to assure that all students receive competent feedback, or even use peer-assigned grades, we need a way to judge which peer reviewers are most credible. The solution is the reputation system. Reputation systems have been deployed as web services, peer-review researchers will be able to use them to calculate scores on assignments, both past and present (past data can be used to tune the algorithms).&lt;br /&gt;
For this project, our team's job is to refactor the file: reputation_web_service_controller.rb. This file is the controller to calculate the reputation scores. A “reputation” measures how close a reviewer’s scores are to other reviewers’ scores. This controller implements the calculation of reputation scores.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=='''Issues to be fixed'''==&lt;br /&gt;
&lt;br /&gt;
reputation_web_service_controller.rb is a fairly complex file. It contains a lot of methods that are long and hard to understand (for e.g. send_post_request). These methods need to be broken down into simpler and more specific methods that are easier to read/understand. Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
# There is a lot of unused/commented code, which should be removed.&lt;br /&gt;
# Figure out what the code is doing and write appropriate comments for it.&lt;br /&gt;
# Rename bad method names such as (db_query, json_generator). Method names should be verbs, and should say what the method does.  Method names should not be so general that they could apply to many different methods..&lt;br /&gt;
# In the case of db_query, the name should say what it queries for. Also, this method not only queries, but calculates sums.  Since each method should do only one thing, the code for calculating sums should be in another method. And there should be comments in the code!&lt;br /&gt;
#json_generator should be generate_json. There needs to be a method comment saying what the parameters are.&lt;br /&gt;
# In  send_post_request, there are references to specific assignments, such as 724, 735, and 756. They were put in to gather data for a paper published in 2015. They are no longer relevant and should be removed. send_post_request is 91 lines long, far too long.&lt;br /&gt;
#There is a password for a private key in the code (and the code is open-sourced!) It should be in the db instead.&lt;br /&gt;
#Fix spelling of “dimention”&lt;br /&gt;
#client is a bad method name; why is stuff being copied from class variables to instance variables?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=='''Steps taken to resolve the issues'''==&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Refactor db_query===&lt;br /&gt;
&lt;br /&gt;
  Renaming of bad method names such as (&amp;lt;code&amp;gt;db_query&amp;lt;/code&amp;gt;). Method names should be verbs, and should say what the method does. &lt;br /&gt;
Method names should not be so general that they could apply to many different methods.&lt;br /&gt;
The other problem with the method was that it did not follow the good practice of having each method perform only one task. &lt;br /&gt;
This method got the review responses with a db query.&lt;br /&gt;
Also, it iterated over the review responses to perform a calculation of peer review grades.&lt;br /&gt;
&lt;br /&gt;
We have split the method into two to have the review responses do only the get responses part.&lt;br /&gt;
&lt;br /&gt;
[[File:snip7.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The code for calculating sums should be in another method. ===&lt;br /&gt;
  The result of this method is stored and we have created a new method &amp;lt;code&amp;gt;calculate_peer_review_grades&amp;lt;/code&amp;gt; and moved the calculation part to it. &amp;lt;br&amp;gt;&lt;br /&gt;
We also added a comment to indicate the calculate weighted sum part.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:snip8.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  And then, we have changed the call to the &amp;lt;code&amp;gt; get review responses&amp;lt;/code&amp;gt; and the new method calculate peer review grades accordingly&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:snip3.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, we have changed &amp;lt;code&amp;gt;db_query_with_quiz_scores&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;calculate_quiz_scores&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:snip5.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===''' Change name of json_generator'''===&lt;br /&gt;
  &lt;br /&gt;
  json_generator method should be &amp;lt;code&amp;gt;generate_json&amp;lt;/code&amp;gt;&lt;br /&gt;
Also,there needs to be a method comment saying what the parameters are.&lt;br /&gt;
We have added the method comments with parameter information as seen below.&lt;br /&gt;
&lt;br /&gt;
[[File:snip4.png]]&lt;br /&gt;
&lt;br /&gt;
===''' Refactor send_post_request'''===&lt;br /&gt;
&lt;br /&gt;
 “In (&amp;lt;code&amp;gt;send_post_request&amp;lt;/code&amp;gt;), there are references to specific assignments, such as 724, 735, and 756. &lt;br /&gt;
  They were put in to gather data for a paper published in 2015. They are no longer relevant and should be removed.&lt;br /&gt;
  send_post_request is 91 lines long, far too long”&lt;br /&gt;
&lt;br /&gt;
We observed that encryption of request being sent to evaluate Algorithm and decryption of response is written in (&amp;lt;code&amp;gt;send_post_request&amp;lt;/code&amp;gt;) only that is why send post is 91 lines long.&lt;br /&gt;
We have created two separate methods &lt;br /&gt;
(&amp;lt;code&amp;gt;encrypt_request&amp;lt;/code&amp;gt;)&lt;br /&gt;
(&amp;lt;code&amp;gt;decrypt_response&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
In the image below we can see that we have separated Encryption functionality from (&amp;lt;code&amp;gt;send_post_request&amp;lt;/code&amp;gt;) to (&amp;lt;code&amp;gt;encrypt_request&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[File:encryption-separated.jpg]]&lt;br /&gt;
&lt;br /&gt;
On the similar lines we have separated Decryption functionality from (&amp;lt;code&amp;gt;send_post_request&amp;lt;/code&amp;gt;) to (&amp;lt;code&amp;gt;decrypt_response&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
[[File:decryption-separated.jpg]]&lt;br /&gt;
&lt;br /&gt;
(&amp;lt;code&amp;gt;encrypt_request&amp;lt;/code&amp;gt;) has been refactored as follows &lt;br /&gt;
&lt;br /&gt;
[[File:encrypt_request.png]]&lt;br /&gt;
&lt;br /&gt;
(&amp;lt;code&amp;gt;decrypt_response&amp;lt;/code&amp;gt;) has been refactored as follows&lt;br /&gt;
&lt;br /&gt;
[[File:decrypt_request.png]]&lt;br /&gt;
&lt;br /&gt;
===''' Fixed spelling of dimention'''===&lt;br /&gt;
&lt;br /&gt;
[[File:capture2.png]]&lt;br /&gt;
&lt;br /&gt;
==='''Updating client method'''===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We changed the class variables in the code to instance variables because we realized that the send_post_request method and client method were the only methods using the class variables.&lt;br /&gt;
A client.html.erb file was used to call our controller to fill out a form for send_post_request which set values of class variables then immediately redirected control to the client method which set the instance variables to those class variables. The instance variables were then used in the rest of the client.html.erb file. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of setting class variables to instance variables with a function was redundant, so we removed simply set the instance variables within the send_post_request method and took them out of the client method.&lt;br /&gt;
The client method did have a few actions that it completed besides setting class variables which we have left in the method until we can find a solution to replacing them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:old-client-method.png|frame|none|alt=Alt text|Old client method]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:new-client-method-and-helpers-new.png|frame|none|alt=Alt text|Newest client method]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reason why we kept the client method's name is because the routes.rb file specifies the client method in the code and we haven't fully tracked down the impact of that yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing == &lt;br /&gt;
=== Test Plan === &lt;br /&gt;
There was no existing tests available for the Reputation web service controller. &lt;br /&gt;
Since we are refactoring it, Our testing plan is to have an automated testing to ensure that the refactoring such as splitting a method into separate methods does not affect the existing implementation.&lt;br /&gt;
We also added steps for the manual testing to make sure the page loads as expected after the refactoring.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For the automated testing, We are using Rspec tests. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===RSpec===&lt;br /&gt;
We have tested the two new methods created during refactoring and also a renamed method. &lt;br /&gt;
The test coverage has increased a bit by 0.6% to 44%.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The tests we created can also be manually run with command &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;rspec spec/controllers/reputation_web_controller_spec.rb. &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:snip13.png]]&lt;br /&gt;
&lt;br /&gt;
===Manual UI Testing===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To test our program you must login to the site here: http://152.7.98.78:8080/&lt;br /&gt;
&lt;br /&gt;
Username: instructor6&lt;br /&gt;
Password: password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then if this page &amp;quot;Manage content&amp;quot; doesn't show up, go to Manage... -&amp;gt; Assignments&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then on the CSC 517, Fall 2017 Row, click on &amp;quot;Add Participants&amp;quot; in the actions column. This is also indicated by a blue shirted person.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once in there, copy on of the student names (such as student7487) and then go to Manage... -&amp;gt; Impersonate User and enter their name (student7487) into the text field.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After impersonating them, you should be able to see their assignments. Click on any of their assignments such as &amp;quot;Program 1&amp;quot;, then click on &amp;quot;Alternate View&amp;quot; to the right of &amp;quot;Your Scores&amp;quot;. This will take you to a site that shows a Reputation Score like in the screenshot below. This proves that our controller has given the information to this view for the  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=='''Modified Files'''==&lt;br /&gt;
&amp;lt;code&amp;gt;reputation_web_service_controller.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''New Files'''==&lt;br /&gt;
&amp;lt;code&amp;gt;reputation_web_service_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
'''Project Mentor:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Saurabh Shingte&lt;br /&gt;
&lt;br /&gt;
'''Project Members:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Abhishek Gupta &amp;lt;br&amp;gt;&lt;br /&gt;
Skieler Capezza&amp;lt;br&amp;gt;&lt;br /&gt;
Ummu Kolusum Yasmin Ahamed Adam&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/srcapezza/expertiza/tree/beta Project Repo]&amp;lt;br&amp;gt;&lt;br /&gt;
*[https://github.com/expertiza/expertiza/pull/1790 Github Pull Request]&lt;br /&gt;
*[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
*[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
*[http://research.csc.ncsu.edu/efg/expertiza Expertiza project Details]&lt;br /&gt;
*[https://www.youtube.com/channel/UCdKXzox7hrWjfOMML6FzTWg Expertiza YouTube Channel]&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Decrypt_request.png&amp;diff=135699</id>
		<title>File:Decrypt request.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Decrypt_request.png&amp;diff=135699"/>
		<updated>2020-10-20T03:04:47Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: Agupta38 uploaded a new version of File:Decrypt request.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Decrypt_request.png&amp;diff=135698</id>
		<title>File:Decrypt request.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Decrypt_request.png&amp;diff=135698"/>
		<updated>2020-10-20T03:04:08Z</updated>

		<summary type="html">&lt;p&gt;Agupta38: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Agupta38</name></author>
	</entry>
</feed>