<?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=Svenka15</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=Svenka15"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Svenka15"/>
	<updated>2026-07-01T22:32:45Z</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_2016_E1682:_Improve_score_calculation&amp;diff=106539</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106539"/>
		<updated>2016-12-05T04:51:25Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Usecase Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
Expertiza is an open source project for school assignment management for instructors and students based on the Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and word documents. Expertiza provides a dashboard for all the assignments corresponding to a course and provides absolute control to the Instructors and Teaching Assistants. In addition to assignments, it encompasses peer reviews wherein participants are allowed to provide feedback anonymously about each other's work thereby providing scope for the better outcome. The due_date.rb file is responsible for informing the users about the deadline for submission of the each assignment. Due dates in Expertiza have their association with many other components like assignments, reviews etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The purpose of the project is to improve the functionality of score calculation. The scores in expertiza were calculated by taking the sum of weighted scores to calculate the total every time it is called. This takes considerable amount of time as there is a calculation involved each time. The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Overall Description ==&lt;br /&gt;
Expertiza currently calculates scores dynamically when a page is called by taking the weighted scores of each question into consideration. This calculation is a time consuming process with a considerable overhead that significantly affects the performance. To solve the issue we propose a solution to store the holistic scores in a database, retrieving it every time it is required. This reduces the calculation that is required every time the score is called. When the user wants to check the scores of a completed assignment, a method localDB_calc is called and expertiza retrieves the scores of the student from the database rather than calculating the total from weighted scores. But, when the scores of an ongoing assignment is required, a method on_the_fly_calc is called that calculates the current score of the user. To determine which method will be invoked(on_the_fly_calc and localDB_calc), the current system time will be compared with last_review_deadline   &lt;br /&gt;
* If system time is greater than last_review_deadline, indicating that the deadline has passed, the method localDbcal will retrieve the holistic score from the database   &lt;br /&gt;
* If system time is lesser than last_review_deadline, indicating that the deadline has not passed, the method on_the_fly_cal will calculate the holistic score and display it.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Tasks Identified ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
When the assignment is still ongoing , this method is called and it calculates holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in localdbscores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Once the deadline for an assignment is completed, the method localDB_calc calculates the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from localdbscores and printed.&lt;br /&gt;
&lt;br /&gt;
This method handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
To store the holistic scores when an assignment is completed, a database localdbscores needs to be created. The value from this db is retrieved and displayed when the scores of a completed assignment needs to be viewed. The database Design is shown below.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
A table localdbscores will be created as:&lt;br /&gt;
&lt;br /&gt;
class CreateLocalDB&amp;lt;ActiveRecord::Migration&lt;br /&gt;
&lt;br /&gt;
def self.up&lt;br /&gt;
&lt;br /&gt;
create_table :localdb_scores do |t|&lt;br /&gt;
&lt;br /&gt;
t.column :id, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :score, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :round, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :type, :string&lt;br /&gt;
&lt;br /&gt;
t.column :reference_id, :integer&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
with id, score, round, type, reference_id as its attributes as shown in the table below&lt;br /&gt;
&lt;br /&gt;
&amp;quot;localdbscores&amp;quot; will have the following scores&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Assignment.rb ===&lt;br /&gt;
A new function get_last_review_date is added which takes assignid as a parameter and returns the last review deadline of the assignment. The deadline obtained from AssignmentDueDate for the corresponding assignid is stored in last_review_deadline and is returned.&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCal ===&lt;br /&gt;
ScoreCal stores the score calculated by its sub classes: on_the_fly_cal and LocalDbcal to the database. In the database, a new table localdbscore is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_cal or LocalDbcal is created and the appropriate functions within the classes are called.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_cal ===&lt;br /&gt;
This is a subclass of class Scorecal contains a method calc_score whose functionality is to compute the holistic score. An object of on_the_fly_cal is called when the current time has not yet surpassed the time stored in last_review_deadline variable which contains the review duedate indicating that the assignment is still ongoing and has not been completed. The individual scores are retrieved from the database ScoreView and is stored in QuestionnaireData from which the holistic score of a student is calculated .&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added.&lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDbcal ===&lt;br /&gt;
This is a subclass of Scorecal and contains a function calc_score in class localDbcal. An object of LocalDbcal is called when the current time has surpassed the time stored in last_review_deadline variable which contains the review due date indicating that the assignment has been completed. This subclass retrieves the score from the database localDbscores for a corresponding student. If the score is not found in the database localDbscores, the function calc_score of on_the_fly_cal class is called to calculate the total from the weighted scores of each question. This calculated score is then inserted into the database.&lt;br /&gt;
&lt;br /&gt;
This score is now returned to the view from where it was called.&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== _review_table.html.erb ===&lt;br /&gt;
The current implementation of this was to calculate the score and display it which as we know is a time consuming process. It has been changed to check if the current time has crossed the last_review_deadline obtained in assignments.rb and call the corresponding class as required.&lt;br /&gt;
&lt;br /&gt;
If the current date has surpassed the last_review_deadline, it is an indication that the due date has passed and the class localDbcal is called to retrieve a value from the database as mentioned above. On the other hand, on_the_fly_cal is called when the current date has not surpassed the last_review_deadline, indicating that the assignment is ongoing and the holistic score is calculated and passed to the view.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram2.png]]&lt;br /&gt;
&lt;br /&gt;
==Usecase Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram.png]]&lt;br /&gt;
&lt;br /&gt;
The actors are :&lt;br /&gt;
&lt;br /&gt;
1.Reviewer&lt;br /&gt;
&lt;br /&gt;
2.Reviewee&lt;br /&gt;
&lt;br /&gt;
3.Instructor/TA&lt;br /&gt;
&lt;br /&gt;
The reviewer selects a topic from the list of topics to be reviewed and starts the review. He allots scores out of 5 for every question and the avaerage of this score gets stored in the database when the reviewer clicks on submit. The reviewee views this stored score when he clicks on &amp;quot;view scores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106538</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106538"/>
		<updated>2016-12-05T04:50:03Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Usecase Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
Expertiza is an open source project for school assignment management for instructors and students based on the Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and word documents. Expertiza provides a dashboard for all the assignments corresponding to a course and provides absolute control to the Instructors and Teaching Assistants. In addition to assignments, it encompasses peer reviews wherein participants are allowed to provide feedback anonymously about each other's work thereby providing scope for the better outcome. The due_date.rb file is responsible for informing the users about the deadline for submission of the each assignment. Due dates in Expertiza have their association with many other components like assignments, reviews etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The purpose of the project is to improve the functionality of score calculation. The scores in expertiza were calculated by taking the sum of weighted scores to calculate the total every time it is called. This takes considerable amount of time as there is a calculation involved each time. The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Overall Description ==&lt;br /&gt;
Expertiza currently calculates scores dynamically when a page is called by taking the weighted scores of each question into consideration. This calculation is a time consuming process with a considerable overhead that significantly affects the performance. To solve the issue we propose a solution to store the holistic scores in a database, retrieving it every time it is required. This reduces the calculation that is required every time the score is called. When the user wants to check the scores of a completed assignment, a method localDB_calc is called and expertiza retrieves the scores of the student from the database rather than calculating the total from weighted scores. But, when the scores of an ongoing assignment is required, a method on_the_fly_calc is called that calculates the current score of the user. To determine which method will be invoked(on_the_fly_calc and localDB_calc), the current system time will be compared with last_review_deadline   &lt;br /&gt;
* If system time is greater than last_review_deadline, indicating that the deadline has passed, the method localDbcal will retrieve the holistic score from the database   &lt;br /&gt;
* If system time is lesser than last_review_deadline, indicating that the deadline has not passed, the method on_the_fly_cal will calculate the holistic score and display it.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Tasks Identified ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
When the assignment is still ongoing , this method is called and it calculates holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in localdbscores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Once the deadline for an assignment is completed, the method localDB_calc calculates the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from localdbscores and printed.&lt;br /&gt;
&lt;br /&gt;
This method handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
To store the holistic scores when an assignment is completed, a database localdbscores needs to be created. The value from this db is retrieved and displayed when the scores of a completed assignment needs to be viewed. The database Design is shown below.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
A table localdbscores will be created as:&lt;br /&gt;
&lt;br /&gt;
class CreateLocalDB&amp;lt;ActiveRecord::Migration&lt;br /&gt;
&lt;br /&gt;
def self.up&lt;br /&gt;
&lt;br /&gt;
create_table :localdb_scores do |t|&lt;br /&gt;
&lt;br /&gt;
t.column :id, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :score, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :round, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :type, :string&lt;br /&gt;
&lt;br /&gt;
t.column :reference_id, :integer&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
with id, score, round, type, reference_id as its attributes as shown in the table below&lt;br /&gt;
&lt;br /&gt;
&amp;quot;localdbscores&amp;quot; will have the following scores&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Assignment.rb ===&lt;br /&gt;
A new function get_last_review_date is added which takes assignid as a parameter and returns the last review deadline of the assignment. The deadline obtained from AssignmentDueDate for the corresponding assignid is stored in last_review_deadline and is returned.&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCal ===&lt;br /&gt;
ScoreCal stores the score calculated by its sub classes: on_the_fly_cal and LocalDbcal to the database. In the database, a new table localdbscore is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_cal or LocalDbcal is created and the appropriate functions within the classes are called.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_cal ===&lt;br /&gt;
This is a subclass of class Scorecal contains a method calc_score whose functionality is to compute the holistic score. An object of on_the_fly_cal is called when the current time has not yet surpassed the time stored in last_review_deadline variable which contains the review duedate indicating that the assignment is still ongoing and has not been completed. The individual scores are retrieved from the database ScoreView and is stored in QuestionnaireData from which the holistic score of a student is calculated .&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added.&lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDbcal ===&lt;br /&gt;
This is a subclass of Scorecal and contains a function calc_score in class localDbcal. An object of LocalDbcal is called when the current time has surpassed the time stored in last_review_deadline variable which contains the review due date indicating that the assignment has been completed. This subclass retrieves the score from the database localDbscores for a corresponding student. If the score is not found in the database localDbscores, the function calc_score of on_the_fly_cal class is called to calculate the total from the weighted scores of each question. This calculated score is then inserted into the database.&lt;br /&gt;
&lt;br /&gt;
This score is now returned to the view from where it was called.&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== _review_table.html.erb ===&lt;br /&gt;
The current implementation of this was to calculate the score and display it which as we know is a time consuming process. It has been changed to check if the current time has crossed the last_review_deadline obtained in assignments.rb and call the corresponding class as required.&lt;br /&gt;
&lt;br /&gt;
If the current date has surpassed the last_review_deadline, it is an indication that the due date has passed and the class localDbcal is called to retrieve a value from the database as mentioned above. On the other hand, on_the_fly_cal is called when the current date has not surpassed the last_review_deadline, indicating that the assignment is ongoing and the holistic score is calculated and passed to the view.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram2.png]]&lt;br /&gt;
&lt;br /&gt;
==Usecase Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram.png]]&lt;br /&gt;
&lt;br /&gt;
The actors are :&lt;br /&gt;
1.Reviewer&lt;br /&gt;
2.Reviewee&lt;br /&gt;
3.Instructor/TA&lt;br /&gt;
&lt;br /&gt;
The reviewer selects a topic from the list of topics to be reviewed and starts the review. He allots scores out of 5 for every question and the avaerage of this score gets stored in the database when the reviewer clicks on submit. The reviewee views this stored score when he clicks on &amp;quot;view scores&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106537</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106537"/>
		<updated>2016-12-05T04:49:20Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106536</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106536"/>
		<updated>2016-12-05T04:48:43Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106535</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106535"/>
		<updated>2016-12-05T04:48:13Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106534</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106534"/>
		<updated>2016-12-05T04:48:03Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106533</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106533"/>
		<updated>2016-12-05T04:47:20Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106532</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106532"/>
		<updated>2016-12-05T04:46:54Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106531</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106531"/>
		<updated>2016-12-05T04:46:25Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Expertiza ===&lt;br /&gt;
Expertiza is an open source project for school assignment management for instructors and students based on the Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and word documents. Expertiza provides a dashboard for all the assignments corresponding to a course and provides absolute control to the Instructors and Teaching Assistants. In addition to assignments, it encompasses peer reviews wherein participants are allowed to provide feedback anonymously about each other's work thereby providing scope for the better outcome. The due_date.rb file is responsible for informing the users about the deadline for submission of the each assignment. Due dates in Expertiza have their association with many other components like assignments, reviews etc.&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The purpose of the project is to improve the functionality of score calculation. The scores in expertiza were calculated by taking the sum of weighted scores to calculate the total every time it is called. This takes considerable amount of time as there is a calculation involved each time. The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Overall Description ==&lt;br /&gt;
Expertiza currently calculates scores dynamically when a page is called by taking the weighted scores of each question into consideration. This calculation is a time consuming process with a considerable overhead that significantly affects the performance. To solve the issue we propose a solution to store the holistic scores in a database, retrieving it every time it is required. This reduces the calculation that is required every time the score is called. When the user wants to check the scores of a completed assignment, a method localDB_calc is called and expertiza retrieves the scores of the student from the database rather than calculating the total from weighted scores. But, when the scores of an ongoing assignment is required, a method on_the_fly_calc is called that calculates the current score of the user. To determine which method will be invoked(on_the_fly_calc and localDB_calc), the current system time will be compared with last_review_deadline   &lt;br /&gt;
* If system time is greater than last_review_deadline, indicating that the deadline has passed, the method localDbcal will retrieve the holistic score from the database   &lt;br /&gt;
* If system time is lesser than last_review_deadline, indicating that the deadline has not passed, the method on_the_fly_cal will calculate the holistic score and display it.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Tasks Identified ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
When the assignment is still ongoing , this method is called and it calculates holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in localdbscores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Once the deadline for an assignment is completed, the method localDB_calc calculates the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from localdbscores and printed.&lt;br /&gt;
&lt;br /&gt;
This method handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
To store the holistic scores when an assignment is completed, a database localdbscores needs to be created. The value from this db is retrieved and displayed when the scores of a completed assignment needs to be viewed. The database Design is shown below.&lt;br /&gt;
&lt;br /&gt;
== Database Design ==&lt;br /&gt;
A table localdbscores will be created as:&lt;br /&gt;
&lt;br /&gt;
class CreateLocalDB&amp;lt;ActiveRecord::Migration&lt;br /&gt;
&lt;br /&gt;
def self.up&lt;br /&gt;
&lt;br /&gt;
create_table :localdb_scores do |t|&lt;br /&gt;
&lt;br /&gt;
t.column :id, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :score, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :round, :integer&lt;br /&gt;
&lt;br /&gt;
t.column :type, :string&lt;br /&gt;
&lt;br /&gt;
t.column :reference_id, :integer&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
with id, score, round, type, reference_id as its attributes as shown in the table below&lt;br /&gt;
&lt;br /&gt;
&amp;quot;localdbscores&amp;quot; will have the following scores&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Assignment.rb ===&lt;br /&gt;
A new function get_last_review_date is added which takes assignid as a parameter and returns the last review deadline of the assignment. The deadline obtained from AssignmentDueDate for the corresponding assignid is stored in last_review_deadline and is returned.&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCal ===&lt;br /&gt;
ScoreCal stores the score calculated by its sub classes: on_the_fly_cal and LocalDbcal to the database. In the database, a new table localdbscore is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_cal or LocalDbcal is created and the appropriate functions within the classes are called.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_cal ===&lt;br /&gt;
This is a subclass of class Scorecal contains a method calc_score whose functionality is to compute the holistic score. An object of on_the_fly_cal is called when the current time has not yet surpassed the time stored in last_review_deadline variable which contains the review duedate indicating that the assignment is still ongoing and has not been completed. The individual scores are retrieved from the database ScoreView and is stored in QuestionnaireData from which the holistic score of a student is calculated .&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added.&lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDbcal ===&lt;br /&gt;
This is a subclass of Scorecal and contains a function calc_score in class localDbcal. An object of LocalDbcal is called when the current time has surpassed the time stored in last_review_deadline variable which contains the review due date indicating that the assignment has been completed. This subclass retrieves the score from the database localDbscores for a corresponding student. If the score is not found in the database localDbscores, the function calc_score of on_the_fly_cal class is called to calculate the total from the weighted scores of each question. This calculated score is then inserted into the database.&lt;br /&gt;
&lt;br /&gt;
This score is now returned to the view from where it was called.&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== _review_table.html.erb ===&lt;br /&gt;
The current implementation of this was to calculate the score and display it which as we know is a time consuming process. It has been changed to check if the current time has crossed the last_review_deadline obtained in assignments.rb and call the corresponding class as required.&lt;br /&gt;
&lt;br /&gt;
If the current date has surpassed the last_review_deadline, it is an indication that the due date has passed and the class localDbcal is called to retrieve a value from the database as mentioned above. On the other hand, on_the_fly_cal is called when the current date has not surpassed the last_review_deadline, indicating that the assignment is ongoing and the holistic score is calculated and passed to the view.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram2.png]]&lt;br /&gt;
&lt;br /&gt;
==Usecase Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:UseCaseDiagram2.png]]&lt;br /&gt;
&lt;br /&gt;
The actors are :&lt;br /&gt;
1.Reviewer&lt;br /&gt;
2.Reviewee&lt;br /&gt;
3.Instructor/TA&lt;br /&gt;
&lt;br /&gt;
The reviewer selects a topic from the list of topics to be reviewed and starts the review. He allots scores out of 5 for every question and the avaerage of this score gets stored in the database when the reviewer clicks on submit. The reviewee views this stored score when he clicks on &amp;quot;view scores&amp;quot;.   &lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106521</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106521"/>
		<updated>2016-12-05T03:23:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram2.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106520</id>
		<title>File:UseCaseDiagram2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram2.png&amp;diff=106520"/>
		<updated>2016-12-05T02:52:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106519</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106519"/>
		<updated>2016-12-05T02:52:32Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Design Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in local_db_scores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from local_db_scores and printed.&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
[[File:UseCaseDiagram2.png]]&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added. &lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
The current system calculates the holistic score every single time from the individual criterion. A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The snapshots prior to and post implementation are shown below :&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106518</id>
		<title>File:UseCaseDiagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106518"/>
		<updated>2016-12-05T02:52:07Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106515</id>
		<title>File:UseCaseDiagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106515"/>
		<updated>2016-12-05T02:50:29Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106514</id>
		<title>File:UseCaseDiagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106514"/>
		<updated>2016-12-05T02:49:20Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:UseCaseDiagram.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106513</id>
		<title>File:UseCaseDiagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UseCaseDiagram.png&amp;diff=106513"/>
		<updated>2016-12-05T02:48:50Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106512</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106512"/>
		<updated>2016-12-05T02:48:32Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Design Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in local_db_scores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from local_db_scores and printed.&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
[[File:UseCaseDiagram.png]]&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added. &lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
The current system calculates the holistic score every single time from the individual criterion. A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The snapshots prior to and post implementation are shown below :&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106510</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=106510"/>
		<updated>2016-12-05T02:39:28Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Observer Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews, as specified in the requirements document are :&lt;br /&gt;
* on_the_fly_calc&lt;br /&gt;
* localDB_calc&lt;br /&gt;
&lt;br /&gt;
=== on_the_fly_calc ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion) and store it in local_db_scores. This stored score is retrieved and printed when the user A clicks on the &amp;quot;Your scores&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
In the current implementation, when a user A wants to view the score given by user B, user A's score(i.e. out of 100) will be calculated everytime using the scores given by user B for each criterion (i.e.. score out of 5).&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== localDB_calc ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”). The query can also ask to print the average of all the scores in round 1 and round2, this average will be retrieved from local_db_scores and printed.&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized).&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
The ScoreCal superclass has 2 subclasses: OnTheFlyCal and LocalDbCal. ScoreCal acts as an interface to obtain the scores, either from OnTheFlyCal or LocalDbCal depending on the last_review_deadline obtained from the get_last_review_date() in the assignment model. This pattern is similar to strategy pattern where the client is the _review_tble.html.erb, interface is the superclass and the subclasses are called accordingly.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
When the user accesses the scores for a review, the current implementation does not store a holistic score but rather calculates the holistic score from the score for every individual criterion. To calculate the total holistic score for a specific round, the individual scores are weighted and added. &lt;br /&gt;
&lt;br /&gt;
This functionality is achieved by on_the_fly_calc.&lt;br /&gt;
&lt;br /&gt;
The current system calculates the holistic score every single time from the individual criterion. A snapshot of the system before implementing the changes is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flycur.png]]&lt;br /&gt;
&lt;br /&gt;
The proposed implementation involves computing the holistic score once and storing it in the local_db_scores database for a particular user and for a specified round. The stored value is accessed and obtained instead of computing the holistic score every single time.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_flyadb.png]]&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The snapshots prior to and post implementation are shown below :&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_loccur.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The proposed implementation retrieves the round wise scores from the local_db_scores database and displays the average score once the deadline has passed rather than computing the average of the weighted scores for every access of the page as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_locadb.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Dataflow diagram (DFD) for the proposed system is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png|center|frame|flowchart]]&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
The testing for model: on_the_fly_calc is carried out by questionnaire_spec.rb in the spec folder. The minimum and maximum score that an user gives for each criterion is checked.&lt;br /&gt;
&lt;br /&gt;
Two more test cases to check whether the average score of each review falls within a given range:(0,100) will be added.&lt;br /&gt;
&lt;br /&gt;
For LocalDB_calc, the average calculated across round 1 and round 2 will be checked to fall within 0 to 100. These test cases will be added to questionnaire_spec.rb.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105428</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105428"/>
		<updated>2016-11-11T19:43:34Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Sub class 2: LocalDB_calc */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews are :&lt;br /&gt;
&lt;br /&gt;
=== OnTheFlyCalc: ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== LocalDBCalc: ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart12.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105427</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105427"/>
		<updated>2016-11-11T19:43:08Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* LocalDBCalc: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews are :&lt;br /&gt;
&lt;br /&gt;
=== OnTheFlyCalc: ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== LocalDBCalc: ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
[[File:Flowchart12.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105426</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=105426"/>
		<updated>2016-11-11T19:42:46Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
The methodology behind score calculation in expertiza can be significantly improved. The design behind calculating and storing scores can be tweaked to offer significant performance improvements. To achieve this, it is ideal to store overall holistic stores in addition to individual criterion scores. &lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The current drawback of the expertiza system lies in  how the scores are stored: Expertiza stores the scores based on each response to each criterion, but no holistic scores are stored. As a result of this mechanism, the process slows down. This means that if we need to know what score user A gives to user B based on 100, we have to rely on the code to calculate it (since in answers table we only have the score that A gives B on each criterion).&lt;br /&gt;
&lt;br /&gt;
To overcome this bottleneck, two additional mechanisms can be included for handling the holistic scores.&lt;br /&gt;
&lt;br /&gt;
== Proposed changes ==&lt;br /&gt;
The two suggested mechanisms for handling the storage and calculation of holistic scores for peer-reviews are :&lt;br /&gt;
&lt;br /&gt;
=== OnTheFlyCalc: ===&lt;br /&gt;
Calculate holistic scores over a set of data (in this case, a set of record in answers table, namely the responses from user A to user B on each criterion)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of an ongoing assignment.&lt;br /&gt;
&lt;br /&gt;
=== LocalDBCalc: ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
:total=0&lt;br /&gt;
&lt;br /&gt;
:self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
:total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
[[File:Flowchart12.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=104957</id>
		<title>CSC/ECE 517 Fall 2016 E1682: Improve score calculation</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1682:_Improve_score_calculation&amp;diff=104957"/>
		<updated>2016-11-09T19:51:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;E1682. Improve score calculation&lt;br /&gt;
=== LocalDBCalc: ===&lt;br /&gt;
Calculate the holistic score over a single db query (in this case, a query would be: “get the score that user A gives user B on assignment 999 on round 2”)&lt;br /&gt;
&lt;br /&gt;
Handles the calculation of reputations for each reviewer in the case of a finished assignment. (all the reputations are calculated and stored since they are finalized)&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== Parent Class:ScoreCalc ===&lt;br /&gt;
ScoreCalc stores the score calculated by its sub classes: on_the_fly_calc and LocalDBcalc to the database. In the database, a new table local_db_scoresn is created with the schema as explained in section 2.2. Depending upon the deadline_type, object of either on_the_fly_calc or LocalDBcalc is created and the appropriate functions within the classes are called. &lt;br /&gt;
&lt;br /&gt;
==== Database design ====&lt;br /&gt;
A table local_db_scores will be created as:&lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;local_db_scores&amp;quot;,force::cascade do|t|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;local_db_scores&amp;quot; will have the following scores &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;id&amp;quot;,         limit: 24&lt;br /&gt;
|id&lt;br /&gt;
|Primary Key, Auto generated&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.string    &amp;quot;Type&amp;quot;,      limit: 255&lt;br /&gt;
|Type&lt;br /&gt;
|Type of score: either final or intermediate&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer    &amp;quot;Score&amp;quot;,  limit: 24&lt;br /&gt;
|Score&lt;br /&gt;
|Total score calculated based on each response to each criterion&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer   &amp;quot;Round&amp;quot;,  limit:24&lt;br /&gt;
|Round&lt;br /&gt;
|The completed round number&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|t.integer  &amp;quot;Reference_id&amp;quot; , limit:45&lt;br /&gt;
|Reference_id&lt;br /&gt;
|Acts as the foreign Key&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Sub class 1: on_the_fly_calc ===&lt;br /&gt;
An object of on_the_fly_calc is called when the deadline_type is not &amp;quot;review of review&amp;quot; which means that the assignment is ongoing and has not been completed and stores the scores till the current stage that will change once the assignment passes the deadline&lt;br /&gt;
&lt;br /&gt;
The function compute_total_scores(scores) is used to calculate the total score based on each response to each criterion. The function is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
&lt;br /&gt;
=== Sub class 2: LocalDB_calc ===&lt;br /&gt;
An object of LocalDB_calc is called when the deadline_type is &amp;quot;review of review&amp;quot; which means that the assignment is completed and stores the final score in the database local_db_scores after computing it rather than computing it every time the score is required.&lt;br /&gt;
&lt;br /&gt;
Function compute_total_scores(scores) is added to the class which calculates the total score based on each response to each criterion. The function(polymorphism) is as below:&lt;br /&gt;
&lt;br /&gt;
def compute_total_scores(scores) &lt;br /&gt;
&lt;br /&gt;
total=0&lt;br /&gt;
&lt;br /&gt;
self.questionnaires.each{|questionnaire| total+=questionnaire.get_weighted_score(self,scores)}&lt;br /&gt;
&lt;br /&gt;
total &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
The value in variable &amp;quot;total&amp;quot; needs to be stored in local_db_scores under &amp;quot;Score&amp;quot; and will be retrieved by using another function retrieve_total_score to display the total score instead of calculating it every time a user wants to view the scores.&lt;br /&gt;
[[File:Flowchart12.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103973</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103973"/>
		<updated>2016-10-29T06:34:22Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* 2. Use find_by instead of dynamic find_by_name. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:&lt;br /&gt;
&lt;br /&gt;
[[File:Find by nameee.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
&lt;br /&gt;
And another example: &lt;br /&gt;
&lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
&lt;br /&gt;
These assignments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;br /&gt;
&lt;br /&gt;
===Results and grades===&lt;br /&gt;
&lt;br /&gt;
The grades of the 6 files changed after the duplicates were removed &lt;br /&gt;
Before modification :&lt;br /&gt;
[[File:Originalgrades.png]]&lt;br /&gt;
After modification:&lt;br /&gt;
[[File:Modifiedgrades.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_nameee.png&amp;diff=103972</id>
		<title>File:Find by nameee.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_nameee.png&amp;diff=103972"/>
		<updated>2016-10-29T06:34:08Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name1.png&amp;diff=103971</id>
		<title>File:Find by name1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name1.png&amp;diff=103971"/>
		<updated>2016-10-29T06:33:03Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by.png&amp;diff=103970</id>
		<title>File:Find by.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by.png&amp;diff=103970"/>
		<updated>2016-10-29T06:29:28Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Find by.png&amp;amp;quot;: correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;displays the changes of done in E1642&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by.png&amp;diff=103969</id>
		<title>File:Find by.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by.png&amp;diff=103969"/>
		<updated>2016-10-29T06:28:18Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Find by.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;displays the changes of done in E1642&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103968</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103968"/>
		<updated>2016-10-29T06:24:52Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:&lt;br /&gt;
&lt;br /&gt;
[[File:Find_by_name.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Find by.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
&lt;br /&gt;
And another example: &lt;br /&gt;
&lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
&lt;br /&gt;
These assignments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;br /&gt;
&lt;br /&gt;
===Results and grades===&lt;br /&gt;
&lt;br /&gt;
The grades of the 6 files changed after the duplicates were removed &lt;br /&gt;
Before modification :&lt;br /&gt;
[[File:Originalgrades.png]]&lt;br /&gt;
After modification:&lt;br /&gt;
[[File:Modifiedgrades.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103967</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103967"/>
		<updated>2016-10-29T06:23:04Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* 2. Use find_by instead of dynamic find_by_name. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:&lt;br /&gt;
&lt;br /&gt;
[[File:Find_by_name.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
&lt;br /&gt;
[[File:Find by.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;br /&gt;
&lt;br /&gt;
===Results and grades===&lt;br /&gt;
&lt;br /&gt;
The grades of the 6 files changed after the duplicates were removed &lt;br /&gt;
Before modification :&lt;br /&gt;
[[File:Originalgrades.png]]&lt;br /&gt;
After modification:&lt;br /&gt;
[[File:Modifiedgrades.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103966</id>
		<title>File:Similarcode.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103966"/>
		<updated>2016-10-29T06:20:40Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Similarcode.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Modifiedgrades.png&amp;diff=103965</id>
		<title>File:Modifiedgrades.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Modifiedgrades.png&amp;diff=103965"/>
		<updated>2016-10-29T06:19:18Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Modifiedgrades.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Originalgrades.png&amp;diff=103964</id>
		<title>File:Originalgrades.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Originalgrades.png&amp;diff=103964"/>
		<updated>2016-10-29T06:18:52Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Originalgrades.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Modifiedgrades.png&amp;diff=103963</id>
		<title>File:Modifiedgrades.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Modifiedgrades.png&amp;diff=103963"/>
		<updated>2016-10-29T06:17:33Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Originalgrades.png&amp;diff=103962</id>
		<title>File:Originalgrades.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Originalgrades.png&amp;diff=103962"/>
		<updated>2016-10-29T06:16:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103961</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103961"/>
		<updated>2016-10-29T06:16:40Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* Results and grades */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:[[File:Fine_by.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;br /&gt;
&lt;br /&gt;
===Results and grades===&lt;br /&gt;
&lt;br /&gt;
The grades of the 6 files changed after the duplicates were removed &lt;br /&gt;
Before modification :&lt;br /&gt;
[[File:Originalgrades.png]]&lt;br /&gt;
After modification:&lt;br /&gt;
[[File:Modifiedgrades.png]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Final.png&amp;diff=103960</id>
		<title>File:Final.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Final.png&amp;diff=103960"/>
		<updated>2016-10-29T06:15:50Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Final.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Final.png&amp;diff=103959</id>
		<title>File:Final.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Final.png&amp;diff=103959"/>
		<updated>2016-10-29T06:11:58Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Final.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103957</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103957"/>
		<updated>2016-10-29T06:10:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* 6. Indentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:[[File:Fine_by.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;br /&gt;
&lt;br /&gt;
===Results and grades===&lt;br /&gt;
&lt;br /&gt;
The grades of the 6 files changed after the duplicates were removed &lt;br /&gt;
Before modification :&lt;br /&gt;
[[File:final.png]]&lt;br /&gt;
After modification:&lt;br /&gt;
[[File:image.pnf]]&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103654</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103654"/>
		<updated>2016-10-29T02:16:26Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: topic changed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2016/E1672 &lt;br /&gt;
Remove duplicated code in feature tests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:[[File:Fine_by.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103653</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103653"/>
		<updated>2016-10-29T02:15:34Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2015/E1672 &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Similar code was found &lt;br /&gt;
[[File:Similarcode.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
New functions were added to remove duplicates&lt;br /&gt;
&lt;br /&gt;
[[File:Similarcode2.png|thumb|code similarity]]&lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:[[File:Fine_by.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name.png&amp;diff=103652</id>
		<title>File:Find by name.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name.png&amp;diff=103652"/>
		<updated>2016-10-29T02:14:11Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Find by name.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103650</id>
		<title>File:Fine by.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103650"/>
		<updated>2016-10-29T02:12:17Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Fine by.png&amp;amp;quot;: correct&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103649</id>
		<title>File:Fine by.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103649"/>
		<updated>2016-10-29T02:11:09Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Fine by.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103648</id>
		<title>File:Fine by.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Fine_by.png&amp;diff=103648"/>
		<updated>2016-10-29T02:10:26Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Fine by.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name.png&amp;diff=103645</id>
		<title>File:Find by name.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_name.png&amp;diff=103645"/>
		<updated>2016-10-29T02:09:29Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Find by name.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Useless.png&amp;diff=103534</id>
		<title>File:Useless.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Useless.png&amp;diff=103534"/>
		<updated>2016-10-29T01:09:22Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Useless.png&amp;amp;quot;: cropped&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103529</id>
		<title>File:Similarcode.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103529"/>
		<updated>2016-10-29T01:08:15Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: uploaded a new version of &amp;amp;quot;File:Similarcode.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode2.png&amp;diff=103525</id>
		<title>File:Similarcode2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode2.png&amp;diff=103525"/>
		<updated>2016-10-29T01:07:33Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103523</id>
		<title>File:Similarcode.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Similarcode.png&amp;diff=103523"/>
		<updated>2016-10-29T01:07:14Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103498</id>
		<title>User:Svenka15</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Svenka15&amp;diff=103498"/>
		<updated>2016-10-29T01:00:16Z</updated>

		<summary type="html">&lt;p&gt;Svenka15: /* 2. Use find_by instead of dynamic find_by_name. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC/ECE 517 Fall 2015/E1672 &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project mainly focuses on removing duplicated codes in feature tests and using Code Climate Chrome Extension and Travis CI to evaluate the modified code.&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and the code is available on Github. It's a web portal used by students for assignment submission and team selection among other activities as listed below &lt;br /&gt;
* It allows students to submit their work- either a wiki page or a deployed link.&lt;br /&gt;
* Review other’s work and grade them.&lt;br /&gt;
* Make changes according to user reviews&lt;br /&gt;
* Allows the instructor to create new assignments and customize new or existing assignments. &lt;br /&gt;
* Allows the instructor to create a list of topics the students can sign up for. &lt;br /&gt;
* Students can bid for topics of their interest by assigning priorities to the topics&lt;br /&gt;
* Students can form teams in Expertiza to work on various projects and assignments.&lt;br /&gt;
&lt;br /&gt;
=== Project Description ===&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the files in spec/features folder, to be specific: assignment_creation_spec.rb, instructor_interface_spec.rb, questionnaire_spec.rb, quiz_spec.rb, delayed_mailer_spec.rb and scheduled_task_spec.rb. It focuses on removing the duplicate codes, following DRY concepts, change DateTime class object invocation, etc. The goal of this project is to attempt to make this part of the application easier to read, maintain and improve the quality of the code. The existing redundant codes, use of long methods, incorrect method invocation and other errors are pointed out by the Code climate extension which are modified in this project. The code climate extension also provides a rating for all files as well as an overall score for the entire application, to help us make proper modifications.&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
The following tasks were accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
Install the Code Climate Chrome Extension, and when you go to Expertiza repo, you will see the extension will highlight the duplication code. Improved the clarity of code by improving the variable and parameter names. Remove the duplicated code by extracting a new method, moving code to before(:each) block, etc. Long character strings were taken and given appropriate names. Improve the Code Climate rating of classes whose original rating is F. Do not delete existing test cases and keep them pass TravisCI after refactoring. Files modified in current project&lt;br /&gt;
&lt;br /&gt;
Six files in spec/features that are to be modified are :&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/quiz_spec.rb quiz_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/delayed_mailer_spec.rb delayed_mailer_spec.rb] &lt;br /&gt;
* [https://github.com/expertiza/expertiza/blob/master/spec/features/scheduled_task_spec.rb scheduled_task_spec.rb]&lt;br /&gt;
&lt;br /&gt;
=== '''Code Climate''' ===&lt;br /&gt;
Code Climate is a open and extensible platform for static analysis and works on the principle: healthy code ships faster. Code climate platform leads to healthier code by clear and actionable static analysis regardless of the technology used. &lt;br /&gt;
&lt;br /&gt;
The static analysis engines and all the static analysis code used are published under Open Source licenses. This paves way for the users to dig in and understand how the code is being evaluated.&lt;br /&gt;
&lt;br /&gt;
The rating and GPA provided by Code Climate extension is an estimate of the quality of the code. The ratings vary from A to F and the GPA varies from 1 to 5. Code with a higher GPA is expected to have higher quality.&lt;br /&gt;
&lt;br /&gt;
'''Getting started with Code Climate''' &lt;br /&gt;
&lt;br /&gt;
To get started with Code Climate the following 4 steps are to be followed &lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Create an account with Code Climate and add the first repository]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-with-code-climate Configure and customise your analysis] &lt;br /&gt;
* [https://docs.codeclimate.com/docs/workflow Add Code Climate to your work flow]&lt;br /&gt;
* [https://docs.codeclimate.com/docs/getting-started-test-coverage Set up test coverage] &lt;br /&gt;
&lt;br /&gt;
==== User perspective ====&lt;br /&gt;
* [https://codeclimate.com Download Code climate] and allow the extension to be used with your browser&lt;br /&gt;
* Sign into your Github account and add the repository to be checked by clicking the extension from your browser.&lt;br /&gt;
 [[File:Code Climate.png]]&lt;br /&gt;
* Manually add the repository from the dashboard.&lt;br /&gt;
[[File:Dash board.png]]&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
Similar code found in 1 other location (mass = 50) Duplicated code can lead to software that is hard to understand and difficult to change. Refactorings -Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm Use find_by instead of dynamic find_by_name. Do not use DateTime.now without zone.&lt;br /&gt;
&lt;br /&gt;
The files in the project include duplicated code which violates DRY concept and is to be removed. The various changes that can be made to the files are explained.&lt;br /&gt;
&lt;br /&gt;
=== 1. Similar code found in 1 other location ===&lt;br /&gt;
When there is duplicated code within the file or between files of the same project, the code can be created as a function with variables that are assigned based on the different cases. This function can be called wherever the functionality is required to be fulfilled and also by passing the required parameters. This makes the code more readable and in fact, much easier to understand. By writing similar lines of code again and again, we only increase the number of lines and decrease the efficiency of the code.For example, the following error was pointed out by Code Climate Extension in [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb]&lt;br /&gt;
&lt;br /&gt;
//image &lt;br /&gt;
&lt;br /&gt;
=== 2. Use find_by instead of dynamic find_by_name. ===&lt;br /&gt;
In the different spec files, find_by_name function is used to identify variables according to their name. find_by can be used to match the argument with the variable directly, instead of making sure if the function parameters are matching with the given file.&lt;br /&gt;
&lt;br /&gt;
For example in file [https://github.com/expertiza/expertiza/blob/master/spec/features/assignment_creation_spec.rb assignment_creation_spec.rb], find_by_name was detected:[[File:Find by name.png]]&lt;br /&gt;
&lt;br /&gt;
This was corrected to find_by &lt;br /&gt;
[[File:Fine_by.png]]&lt;br /&gt;
&lt;br /&gt;
The grade of the code improved when find_by_name was changed to find_by.&lt;br /&gt;
&lt;br /&gt;
=== 3. Refactoring - Extract Method,Extract Class,Form Template Method,Introduce Null Object,Pull Up Method,Pull Up Field,Substitute Algorithm ===&lt;br /&gt;
&lt;br /&gt;
Refactoring is the process of improving a source code without altering the external behaviour. It improves Extensibility and Maintainability. We can implement refactoring using one of the methods mentioned above.&lt;br /&gt;
&lt;br /&gt;
A common code that is present across files can be added to rails_helper.rb and called across files when needed. One example of this is the cod in integration_test_instructor_interface function which was typed out without being encapsulated as a function  in both [https://github.com/expertiza/expertiza/blob/master/spec/features/instructor_interface_spec.rb instructor_interface_spec.rb] and [https://github.com/expertiza/expertiza/blob/master/spec/features/questionnaire_spec.rb questionnaire_spec.rb].&lt;br /&gt;
[[File:Rails helper.rb.png]]&lt;br /&gt;
 A common definition was added to rails_helper.rb for the integration_test_instructor_interface function as shown below&lt;br /&gt;
[[File:Rails helper.rb modified.png]]&lt;br /&gt;
&lt;br /&gt;
=== 4. Useless Assignments of Variables ===&lt;br /&gt;
&lt;br /&gt;
Same variables may be assigned values through the program which may not be used later. These assignments are said to be useless as the new value never gets used anywhere. These lines can be removed from the program as they do not implement anything and are of no use.&lt;br /&gt;
[[File:Uselessassignment.png]]&lt;br /&gt;
And another example: &lt;br /&gt;
[[File:Useless.png|thumb|Useless assignment]]&lt;br /&gt;
These assignenments were removed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 5.Do not use DateTime.now without Time.zone.now ===&lt;br /&gt;
&lt;br /&gt;
To use the current time in the program, we need use Time.zone.now instead of DateTime.now. The latter uses the system's date and time as it is part of the Ruby standard library. It is better to use Time.zone.now because it returns the time that is corrected according to our corresponding Time zone as it has been extended by ActiveSupport. Example is as given :&lt;br /&gt;
[[File:Timezone.png]]&lt;br /&gt;
[[File:Timelocal.png]]&lt;br /&gt;
&lt;br /&gt;
=== 6. Indentation ===&lt;br /&gt;
&lt;br /&gt;
Programs need to be indented properly. 2 White spaces are used to write statements within any block. Accordingly, the end of the block statements also follow the corresponding white spaces. Indentation improves code readability and makes it easy for the user/programmer to understand what happens within the program.&lt;/div&gt;</summary>
		<author><name>Svenka15</name></author>
	</entry>
</feed>