<?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=Nmathew</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=Nmathew"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Nmathew"/>
	<updated>2026-05-06T12:18: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_2014/final_E1475_nrnn&amp;diff=92404</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92404"/>
		<updated>2014-12-04T02:32:00Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Previous work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not consider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
'''Developer Note''' The name lottery has been retained for most of the files. This is because Intelligent Assignment could be confused with actual assignments. Intelligent Assignment and the subsequent discussion refers to the latest approach used in LotteryController for assigning topics to teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes''' We have avoided separating out AssignmentTopicMetadata from Assignment as this would have caused a lot of dependency conflicts.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Troubleshooting&amp;lt;/b&amp;gt;=&lt;br /&gt;
During our development process, we stumbled upon certain bugs in certain areas which slowed down our process. This is brief summary of those issues and their corresponding fixes. These changes are not the right resolution, however, we have listed it here so that future developers could benefit from these.&lt;br /&gt;
*Error thrown while adding assignments/teams/teamusers&lt;br /&gt;
The model nodes has a method acts_as_nested_sets which causes this issue.&lt;br /&gt;
*Error thrown while loading the sign_up_sheet_controller&lt;br /&gt;
Comment this line &amp;quot;require 'graph/graphviz_dot'&amp;quot;&lt;br /&gt;
*Missing rgt or lft column in nodes table&lt;br /&gt;
Probably because the db migration AddCategories has not been run. The code in that is commented. Uncomment that and run the migration.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92401</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92401"/>
		<updated>2014-12-04T02:25:31Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Associated Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes''' We have avoided separating out AssignmentTopicMetadata from Assignment as this would have caused a lot of dependency conflicts.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Troubleshooting&amp;lt;/b&amp;gt;=&lt;br /&gt;
During our development process, we stumbled upon certain bugs in certain areas which slowed down our process. This is brief summary of those issues and their corresponding fixes. These changes are not the right resolution, however, we have listed it here so that future developers could benefit from these.&lt;br /&gt;
*Error thrown while adding assignments/teams/teamusers&lt;br /&gt;
The model nodes has a method acts_as_nested_sets which causes this issue.&lt;br /&gt;
*Error thrown while loading the sign_up_sheet_controller&lt;br /&gt;
Comment this line &amp;quot;require 'graph/graphviz_dot'&amp;quot;&lt;br /&gt;
*Missing rgt or lft column in nodes table&lt;br /&gt;
Probably because the db migration AddCategories has not been run. The code in that is commented. Uncomment that and run the migration.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92400</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92400"/>
		<updated>2014-12-04T02:16:11Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Associated Code Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes''' We have avoided separating out AssignmentTopicMetadata from Assignment as this would have caused a lot of dependency conflicts.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Associated Code Changes&amp;lt;/b&amp;gt;=&lt;br /&gt;
During our development process, we stumbled upon certain bugs in certain areas which slowed down our process. This is brief summary of those issues and their corresponding fixes. These changes are not the right resolution, however, we have listed it here so that future developers could benefit from these.&lt;br /&gt;
**Error thrown while adding assignments, teams, teamusers&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92399</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92399"/>
		<updated>2014-12-04T02:11:35Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes''' We have avoided separating out AssignmentTopicMetadata from Assignment as this would have caused a lot of dependency conflicts.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Associated Code Changes&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92380</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92380"/>
		<updated>2014-12-04T00:17:12Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* UML Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes''' We have avoided separating out AssignmentTopicMetadata from Assignment as this would have caused a lot of dependency conflicts.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92379</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92379"/>
		<updated>2014-12-04T00:05:04Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Design Patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following principles and patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Using DRY coding practices. The earlier code had a lot of redundant functions such as getTeamsFromId which was violating the DRY principle. We have used the methods provided by the ActiveRecord class making the code structure and easy to understand.&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt; Use of the Model View Controller for maintaining the Intelligent Assignment flow.&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92378</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92378"/>
		<updated>2014-12-03T23:54:15Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Database Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the algorithm, workflow, use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing sign up process==&lt;br /&gt;
The sign up process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the sign up process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to sign up for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded randomly through an algorithm which assigns topics to teams randomly (Lottery System) and does not conider any other criteria which caused the existing system of topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given ''x'' bids (''x'' is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ''p'' number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is ''p'' just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ''q'' which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ''p''+''q'' bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ''p''+''q'' threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, the initial plan was to add new tables. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''sign_up_topics''. There was lot of data redundancy observed and we also required to add an extra field in the table ''sign_up_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
'''Implementation Changes:''' However, because of the way the current database dependencies were strongly coupled, we decided to go ahead by adding a column &amp;quot;Max_Team_Bids&amp;quot; to the Assignments table and a &amp;quot;priority&amp;quot; column to the Bids table. The above approach can be used as a reference for future developers.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Separating out the redundant data from SignUpTopic&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt;&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Flow_Chart.png&amp;diff=92247</id>
		<title>File:Flow Chart.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Flow_Chart.png&amp;diff=92247"/>
		<updated>2014-11-22T15:58:35Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92246</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92246"/>
		<updated>2014-11-22T15:37:45Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Modified version of Stable Matching Algorithm */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids (x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is p just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
[[File: Flow Chart.png|Modified version of Stable Matching|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Separating out the redundant data from SignUpTopic&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt;&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92245</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92245"/>
		<updated>2014-11-22T15:36:58Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Adding algorithm&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off [what does that mean?] the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids (x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system. [Describe the rationale for this.  Is p just the number of slots?]&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.  [I can guess how this might be implemented, but an example would help to clarify.  Also, I am interested in the rationale.]&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost. [It would be better to keep bids, insofar as possible.  Losing one's topic is a &amp;quot;gotcha&amp;quot; of joining a team, and I wouldn't want to see that continue under this system.]&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition (1), a topic would be assigned to the team based on the priority order of the bids that the team specified. [I don't think that this defines an algorithm.  An algorithm needs to be a set of steps in order.  This just describes the result.]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Modified version of Stable Matching Algorithm&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
This flow chart illustrates the algorithm used to assign topics to teams based on the strength of the teams(bidder) and the priority in which they bid for the topic.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Separating out the redundant data from SignUpTopic&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt;&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92106</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92106"/>
		<updated>2014-11-13T12:23:33Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Added Design Patterns&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future scenario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Design Patterns&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The following patterns are used:&lt;br /&gt;
#&amp;lt;b&amp;gt;DRY&amp;lt;/b&amp;gt;: Separating out the redundant data from SignUpTopic&lt;br /&gt;
#&amp;lt;b&amp;gt;MVC&amp;lt;/b&amp;gt;&lt;br /&gt;
#&amp;lt;b&amp;gt;Separation of concerns&amp;lt;/b&amp;gt;: The IntelligentAssignmentTopicController is separated from AssignmentTopicController as the former's functionality is specific and hence should not be part of the general AssignmentTopic Controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92014</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92014"/>
		<updated>2014-11-12T03:45:32Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Use Cases */  Aligned tables&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Enable Intelligent Assignment''' &lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor &lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; |'''Use Case'''&lt;br /&gt;
|width=&amp;quot;700px&amp;quot; |'''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
| width=&amp;quot;700px&amp;quot; |'''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;100px&amp;quot; | '''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 800px; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;100px&amp;quot; |'''Use Case''' &lt;br /&gt;
|width=&amp;quot;700px&amp;quot; | '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92002</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92002"/>
		<updated>2014-11-12T03:09:34Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Use Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 100; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 100; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 100; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 100; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 100; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92000</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=92000"/>
		<updated>2014-11-12T03:07:38Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions discusses the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91999</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91999"/>
		<updated>2014-11-12T03:06:51Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
#The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
#The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
#The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
#The teams should be able to prioritize their bids.&lt;br /&gt;
#The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91996</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91996"/>
		<updated>2014-11-12T03:04:56Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /*  Design Workflow  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91995</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91995"/>
		<updated>2014-11-12T03:04:22Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /*  Introduction  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91992</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91992"/>
		<updated>2014-11-12T03:02:22Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91991</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91991"/>
		<updated>2014-11-12T03:01:13Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* After the Bidding Process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1. The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2. For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
&lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91990</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91990"/>
		<updated>2014-11-12T03:00:06Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* After the Bidding Process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
1) The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
2) For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
&lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91985</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91985"/>
		<updated>2014-11-12T02:55:00Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&lt;br /&gt;
 The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
&lt;br /&gt;
# The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
# For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
&lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91981</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91981"/>
		<updated>2014-11-12T02:51:39Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1475. Intelligent assignment of teams'''&lt;br /&gt;
&lt;br /&gt;
This page discusses the requirements and design specifications of final project E1475. Intelligent Assignment of teams. It starts out by giving an introduction and discussing previous implementations and related work. It then details out the workflow of the proposed implementation and shows the use case diagrams and sequence diagrams associated with it. Finally the page mentions about the class design and database design that would go with the implementation of the project.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Problem Statement&amp;lt;/b&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
According to the existing code workflow, the assignment of topics to teams are based on FCFS (first come first serve) basis, where a team which first signs up for a topic gets the topic while other teams are waitlisted on the same topic. Since ‘sign up time’ is the only factor considered for topic assignment this method causes problems such as:&lt;br /&gt;
&lt;br /&gt;
#The assignment of topics are FCFS, hence not completely fair.&lt;br /&gt;
#Non-uniform distribution of topics among the teams in a class.&lt;br /&gt;
#The current system fails to resolve the problem when many teams bid for handful of topics(among many topics) causing unnecessary additions to the waitlist.&lt;br /&gt;
#The assignment of topics is more focused on individual selection and ‘sign up time’. Factors such as team size are not considered which are important while assigning a topic to the team and potentially can reduce many issues faced by the current system. &lt;br /&gt;
&lt;br /&gt;
To address the above mentioned issues, we have designed an ‘intelligent assignment of topics’ system which tries to address the issues faced by the current system.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Introduction &amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza ==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;ref&amp;gt;[http://expertiza.ncsu.edu/ Expertiza]&amp;lt;/ref&amp;gt; is a project developed using [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails ]&amp;lt;/ref&amp;gt; platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza github]&amp;lt;/ref&amp;gt;. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU [http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;ref&amp;gt;[http://litre.ncsu.edu/ Learning in a Technology-Rich Environment (LITRE)]&amp;lt;/ref&amp;gt; program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
==Existing signup process==&lt;br /&gt;
The signup process for group projects is observed by most students to be a troublesome task  in expertiza. The current sign up process for topics is based on [http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/First-come,_first-served FCFS]&amp;lt;/ref&amp;gt; basis, where a student who signs up for a topic of his/her choice first, gets it. We have discovered some pitfalls with the current ‘topic assignment’ system in Expertiza which arises due to the below mentioned factors.  Due to these reasons, we now try to propose an intelligent system which can addresses many issues faced with the current Expertiza system.&lt;br /&gt;
&lt;br /&gt;
== Pitfalls with the current system ==&lt;br /&gt;
#One student can sign up only for a single topic. In cases where many topics are available, a student is forced to choose a single topic among many available topics which can be a difficult task. To select a single topic which best fits his/her choice among many available topics requires a pre-study of all topics prior to the signup process. Such a pre-requirement is not fulfilled by most  students, which results in a student signing up for a topic which he/she has randomly selected OR because it was among the only available topics.&lt;br /&gt;
#If a student is not able to sign up for a topic of his choice, he can waitlist himself for all the remaining topics, which causes unnecessary traffic in the waitlist queue of a topic. &lt;br /&gt;
#If all the teams choose a handful of topics among many topics, it would also result in unnecessary additions in the waitlist queue for those few topics resulting in a situation where all the topics are not uniformly distributed among all the teams&lt;br /&gt;
#Before, signing up, if more than one student forms a team and if each student belonging to the same team tries to signup for different topics, than those topics are allotted to individual students resulting in a situation where a team can hold more than one topic. Thus other teams are forced to choose from remaining topics which eventually results in longer waitlists.&lt;br /&gt;
&lt;br /&gt;
After observing the above problems with the existing method of ‘topic assignment’ in expertiza, we have proposed and implemented an ‘intelligent assignment of topics’ method to overcome all the shortcomings of the existing system in expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Previous work ==&lt;br /&gt;
Previously in 2012, to address this issue of expertiza, a team proposed a possible solution of [https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ ‘lottery based topic assignment’]&amp;lt;ref&amp;gt;[https://docs.google.com/document/d/1tyWX8njxDLvYpN7wJf5hjA6lnWbzQRP9vUKGxxRjRzo/edit#heading=h.5cgh9aixuut7/ Lottery based topic assignment]&amp;lt;/ref&amp;gt; algorithm. The algorithm works by considering every team as strength of 1, representing the student in the team. After sign up the topic would be allotted to the team based on a lottery system where a team is randomly selected for every topic. However this method failed to address the following issues:&lt;br /&gt;
#It did not consider the case where a team could be of more than one member, hence it allowed every team member to bid for different topics resulting in the same problem as mentioned in point (4) of Pitfalls with the current system.&lt;br /&gt;
#The topics were awarded based on a Lottery system and not based on any other criteria which resulted in topic assignment to be a game of luck factor rather than on individual’s choice.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt; Design Workflow &amp;lt;/b&amp;gt;=&lt;br /&gt;
To address the issues faced by both, the current system and lottery based system, we propose a solution based on ‘intelligent team assignment’ algorithm. The algorithm is based on two important factors:&lt;br /&gt;
&lt;br /&gt;
#Team strength&lt;br /&gt;
#Priority order of the topics submitted by the team.&lt;br /&gt;
&lt;br /&gt;
The algorithm works on bidding process which can be explained as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Before the bidding process ==&lt;br /&gt;
#Initially, every student is a team of 1 member. Before the bidding process takes place, students can merge their teams to form a larger team. The person to whom they have merged becomes the team owner/captain.&lt;br /&gt;
#Every team is given x bids(x is calculated based on the total class strength and total topics proposed), that they can place on each topic of their choice in a priority order where 1 being the highest priority.&lt;br /&gt;
#Every topic is allowed ‘p’ number of maximum bids after which the topic is waitlisted in the system.&lt;br /&gt;
#Teams can also place their bids on waitlisted topics. However, every topic has a threshold ‘q’ which signifies the maximum waitlisted bids allowed for each topic.&lt;br /&gt;
#Thus, if the combined threshold of ‘p+q’ bids for a topic is reached then the topic is no longer available for bidding unless the topic is dropped by a team which reduces the ‘p+q’ threshold value.&lt;br /&gt;
&lt;br /&gt;
== During Bidding Process ==&lt;br /&gt;
#Every team can place their bids on the available topics. Since every team is given ‘x’ bids, each team can bid for ‘x’ topics and list their bids in a priority order.&lt;br /&gt;
#A team can also place their bids on  waitlisted topics. The maximum allowed bids for waitlisted topics is ‘y’ where y is some portion of bids taken from total bids(x) allowed for each team.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== After the Bidding Process ==&lt;br /&gt;
#After the bidding process is complete, the teams can continue to merge to form larger teams.&lt;br /&gt;
#If team A merges with team B, the bids of team A would be lost.&lt;br /&gt;
#The merging of the teams is allowed till the topic assignment date when the teams would finally be assigned the topics by running an algorithm.&lt;br /&gt;
#The teams can also change their submitted topic priority order any number of times before running the ‘topic assignment’ algorithm. &lt;br /&gt;
&lt;br /&gt;
 The algorithm assigns the topic to each teams based on the following factors:&lt;br /&gt;
&lt;br /&gt;
# The team which is close to or has maximum possible team strength has a higher probability of winning the topic they had placed their bid on.&lt;br /&gt;
# For a team which satisfies condition(1), a topic would be assigned to the team based on the priority order of the bids that the team specified.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
#As each team can place their bids on the available topics based on their topic priority. Hence every team gets to choose more than one topic of their choice.&lt;br /&gt;
&lt;br /&gt;
#As every topic has a maximum number of allowed bids, after which the topic is no longer available for bidding, this method addresses the issue where many teams choose only a handful topics among all topics. &lt;br /&gt;
&lt;br /&gt;
#As the maximum allowed bids for waitlisting a topic is also limited for every team, hence the issue of unnecessary additions to waitlist is resolved by this method.&lt;br /&gt;
&lt;br /&gt;
#The teams are assigned topics based on modified [http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Stable_marriage_problem/ Stable marriage problem]&amp;lt;/ref&amp;gt; algorithm which considers factors such as team size and priority ensuring that the topics are no longer assigned based on FCFS basis. Thus this method addresses the most important issue where a topic is not assigned to the team just because the team was late to sign up for the topic as compared to the other teams.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Requirements&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Sequence Diagram&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences.&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Use Cases&amp;lt;/b&amp;gt;=&lt;br /&gt;
[[File:UseCase.png|frame|center|Fig. Use Case Diagram]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Enable Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and allotted the Assignment Topics&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || Intelligent Assignment option is enabled for the assignment. &amp;lt;br/&amp;gt;Students can place their bids for the assignment topics on commencement of the selection process&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which the topic selection process has not yet started. &amp;lt;br/&amp;gt;The instructor checks the “Enable Intelligent Assignment” option and presses Save.&amp;lt;br/&amp;gt;The system saves the instructors choice for the assignment.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Add bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;SignUp sheet with the list of topics is available for the assignment.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic of interest from the list of topics in the SignUp sheet. &amp;lt;br/&amp;gt;The student chooses the priority of the topic.&amp;lt;br/&amp;gt;The system saves the bid for the topic and the corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with the chosen topic.&lt;br /&gt;
|-&lt;br /&gt;
| Alternate Flow || The student has already exceeded the maximum bid limit but still selects a topic.&amp;lt;br/&amp;gt;The system throws an error saying “Bid limit exceeded”&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Delete bids'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student clicks “Delete bid”.&amp;lt;br/&amp;gt;The system removes the bid for the topic.&amp;lt;br/&amp;gt;The system presents the updated view reflecting the changes.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Reorder Priorities'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Student (Team Leader)&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Student is logged into expertiza system . &amp;lt;br/&amp;gt;Student has already selected few topics for bidding.&lt;br /&gt;
|-&lt;br /&gt;
| Trigger || Student selects the assignment in the topic selection phase &lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The student selects the topic for which the bid existed.&amp;lt;br/&amp;gt;The student changes the priority of the topic. &amp;lt;br/&amp;gt;The system updates the bid for the topic with corresponding priority.&amp;lt;br/&amp;gt;The system presents the updated view with reordered topics.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width: 60%; height: 200px&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Use Case''' || '''Run Intelligent Assignment'''&lt;br /&gt;
|-&lt;br /&gt;
| Primary Actor || Instructor&lt;br /&gt;
|- &lt;br /&gt;
| Preconditions || Instructor is logged into the Expertiza system. &amp;lt;br/&amp;gt;Instructor has created an Assignment and enabled the intelligent assignment option.&amp;lt;br/&amp;gt;The due date for the topic selection has passed.&lt;br /&gt;
|-&lt;br /&gt;
| Postconditions || The topics are intelligently assigned to the teams&lt;br /&gt;
|-&lt;br /&gt;
| Basic Flow || The instructor selects the assignment for which topic selection process has completed. &amp;lt;br/&amp;gt;The instructor selects the run intelligent assignment option.&amp;lt;br/&amp;gt;The system performs intelligent assignment of topics and allots topics to teams.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;UML Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
The intelligent assignment controller is dependent on the ''AssignmentTopicController'' and other models like - ''Assignment'', ''AssignmentTopic'' and ''Team''. When the instructor starts the intelligent assignment of topics to teams, ''IntelligentAssignmentController'' triggers the assignment algorithm.&lt;br /&gt;
&lt;br /&gt;
The students interact with ''AssignmentTopicView'' which lists down all the topics for the assignment and allows students to bid for topics with priority. ''AssignmentTopicController'' is responsible for recording all the bids and priorities correctly.&lt;br /&gt;
&lt;br /&gt;
Following is the UML diagram of the O-O design focusing only on the component related to intelligent assignment of topics to teams.&lt;br /&gt;
&lt;br /&gt;
[[File: UML_Design.png|UML Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;Database Design&amp;lt;/b&amp;gt;=&lt;br /&gt;
&lt;br /&gt;
In order to meet other solution requirement, new tables are added. The following diagram represents the new tables in [http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#Crow.27s_foot_notation Crow Foot's Notation]&amp;lt;/ref&amp;gt;. The ''user'' table mentioned is not new and is present only to explain the field - ''ownerId''.&lt;br /&gt;
&lt;br /&gt;
Earlier, all the information in ''AssignmentTopic'' and ''AssignmentTopicMetadata'' tables were in a single table called ''signup_topics''. However, there was lot of data redundancy observed and we also required to add an extra field in the table ''signup_topics''. Therefore, we decided to store the topics related to an assignment according to the diagram. One caveat to this design is that all the topics for an assignment are considered equal in terms of category, maximum bids allowed and maximum bids in waiting list.&lt;br /&gt;
&lt;br /&gt;
The table ''bid'' is supposed to store all the bids on the topics with their priority. The owner of the bid will be recorded too. Current requirement is to have only one bid per topic by an owner. Therefore, we could have ''(ownerId, topicId)'' pair as the primary key. However, in order to support multiple bids in a future sceario, we have used a field ''id'' as the primary key.&lt;br /&gt;
&lt;br /&gt;
Apart from the mentioned new tables, we will be using pre-existing tables to meet our requirements and design.&lt;br /&gt;
&lt;br /&gt;
[[File: DatabaseDesign.png|Database Design|frame|center]]&lt;br /&gt;
&lt;br /&gt;
=&amp;lt;b&amp;gt;References&amp;lt;/b&amp;gt;=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.png&amp;diff=91725</id>
		<title>File:E1475.Sequence Diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.png&amp;diff=91725"/>
		<updated>2014-11-11T20:46:02Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: uploaded a new version of &amp;amp;quot;File:E1475.Sequence Diagram.png&amp;amp;quot;: Fixed a missing arrow&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91665</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91665"/>
		<updated>2014-11-11T09:54:26Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Added Sequence Diagram&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Requirements=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=Sequence Diagram=&lt;br /&gt;
[[File:E1475.Sequence Diagram.png|frame|center|Fig 1. Sequence Diagram]]&lt;br /&gt;
Fig 1. shows the sequence diagram for this feature. The diagram shows the sequences exclusive to this feature. Therefore, this assumes that the assignment/exercise has already been created. &lt;br /&gt;
Once the assignment is created, the instructor can enable the 'intelligent assignment of teams' feature for the particular assignment. Enabling this feature would give the students(or teams) a view to place bids on the topics they like. They can associate each bid with a priority. Once the deadline has passed, the instructor can kickoff the process which performs the automatic assignment. This would in turn start assigning teams with topics based on their bid preferences. &lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.png&amp;diff=91664</id>
		<title>File:E1475.Sequence Diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.png&amp;diff=91664"/>
		<updated>2014-11-11T09:53:05Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.jpg&amp;diff=91663</id>
		<title>File:E1475.Sequence Diagram.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E1475.Sequence_Diagram.jpg&amp;diff=91663"/>
		<updated>2014-11-11T09:50:15Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91662</id>
		<title>CSC/ECE 517 Fall 2014/final E1475 nrnn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1475_nrnn&amp;diff=91662"/>
		<updated>2014-11-11T06:50:09Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Initial commit. Added Requirements&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Requirements=&lt;br /&gt;
&lt;br /&gt;
1) The instructor should be able to create assignments which can utilize intelligent assignment of teams. (It is an optional feature)&lt;br /&gt;
&lt;br /&gt;
2) The instructor should be able to set the maximum number of bids a team can make. Defaulted to 3.&lt;br /&gt;
&lt;br /&gt;
3) The teams should be able place bids on different topics limited to the number set by the instructor for these assignments&lt;br /&gt;
&lt;br /&gt;
4) The teams should be able to prioritize their bids.&lt;br /&gt;
&lt;br /&gt;
5) The instructor should be able to kick off the intelligent assignment of teams.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91661</id>
		<title>CSC/ECE 517 Fall 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91661"/>
		<updated>2014-11-11T06:37:28Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Added page for E1475&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2014/sample_page]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 22 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 19 mx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 3 zq]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 lf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 wl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a a7 ch]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 rs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 jf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 os]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 15 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 10 hu]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 kv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 21 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 24 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 6 rl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 2 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 16 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 rm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 sj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 23 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 rn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 22 sp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss M1454 rss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 gn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 13 va]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 kn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 ks]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 7 kz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_6_bn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 10 zz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 16 va]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a F1415 rv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_3_cp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1b 26 sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_28_cg]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 29 ry]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 30 cs]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_33_jy]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_27_js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1453 syy]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1463 vpd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1465 oak]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1456_kdv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1453_sst]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_E1456_akk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1455_asa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1458_sst]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1457_ags]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1466_gjf]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1452_jns]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1462_nms]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1455_ajp]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1454_ccc]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1450_cxm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1455_skn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_M1450_vda]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1467_rsv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1464_vnn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_M1451_ahs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1451_las]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1461_knn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1460_aua]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1459_jjr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1474_akkn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1472_gjfz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1471_asuv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1475_nrnn]]&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91344</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91344"/>
		<updated>2014-10-31T06:52:48Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Added git pull link based on review comments&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP] (Log in as user2/password. Go to [http://152.46.16.178:3001/analytic/index VCL analytic page])&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/439 Git Pull Link]&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:Probably because of the way ruby makes database queries by default, data fetching takes a long time. The waiting time was in the order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project and to fix the issues mentioned above, additional file changes were made. Following is a list of the changes in more detail:&lt;br /&gt;
&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91326</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91326"/>
		<updated>2014-10-30T17:55:54Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: Added Direct link to analytic page. For ease of reviewing.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP] (Log in as user2/password. Go to [http://152.46.16.178:3001/analytic/index VCL analytic page])&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:Probably because of the way ruby makes database queries by default, data fetching takes a long time. The waiting time was in the order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project and to fix the issues mentioned above, additional file changes were made. Following is a list of the changes in more detail:&lt;br /&gt;
&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91318</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91318"/>
		<updated>2014-10-30T04:10:21Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Summary of Revised Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:Probably because of the way ruby makes database queries by default, data fetching takes a long time. The waiting time was in the order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project and to fix the issues mentioned above, additional file changes were made. Following is a list of the changes in more detail:&lt;br /&gt;
&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle and the DRY Principle&lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91310</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91310"/>
		<updated>2014-10-30T04:01:31Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:Probably because of the way ruby makes database queries by default, data fetching takes a long time. The waiting time was in the order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project and to fix the issues mentioned above, additional file changes were made. Following is a list of the changes in more detail:&lt;br /&gt;
&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91296</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91296"/>
		<updated>2014-10-30T03:46:32Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91294</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91294"/>
		<updated>2014-10-30T03:44:57Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle'''' (data_template function is responsible for all types of charts). It also duplicated some code(code for line and bar) which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
* Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
* Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
* The data part for scatter plots contains unnecessary data which is used as sample data. A large part of can be removed as this data is only for indicating how data should be arranged for scatter plot.&lt;br /&gt;
The new code ''does not'' violate the '''Single Responsibility Principle''' and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91291</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91291"/>
		<updated>2014-10-30T03:38:36Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataAdapter method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Changes made:'''&lt;br /&gt;
&lt;br /&gt;
*The new code ''does not'' violate the Single Responsibility Principle anymore. This is achieved by Separation of Concerns. Each function is divided into a smaller module and focuses on one small task.&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = '''set_template_optional_params'''(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template = '''validate_optional_conf'''(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
*Moved code for validation of optional parameters to function '''''validate_optional_conf'''''&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
The code is a lot more cleaner, readable and maintainable now.&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. It also duplicated some code which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91280</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91280"/>
		<updated>2014-10-30T03:29:48Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataAdapter method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
 #Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
 #Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
  if optionalConf[:subtitle].nil? then&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
  else&lt;br /&gt;
    template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
  end&lt;br /&gt;
  if optionalConf[:y_axis].nil? then&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
  else&lt;br /&gt;
    template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
  end&lt;br /&gt;
  if optionalConf[:x_axis].nil? then&lt;br /&gt;
    template[:xAxis].delete(:title)&lt;br /&gt;
  else&lt;br /&gt;
    template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
  end&lt;br /&gt;
  if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
    template[:xAxis].delete(:categories)&lt;br /&gt;
  else&lt;br /&gt;
    template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
  def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. It also duplicated some code which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91267</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91267"/>
		<updated>2014-10-30T03:24:23Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. It also duplicated some code which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91253</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91253"/>
		<updated>2014-10-30T03:16:57Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. It also duplicated some code which resulted in a violation of a '''DRY Principle'''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design. It also does not violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
  def self.get_bar_template()&lt;br /&gt;
    generic_template = get_generic_template  #Adding :chart object to the generic template&lt;br /&gt;
    generic_template[:chart] = {&lt;br /&gt;
        :type =&amp;gt; 'column'&lt;br /&gt;
    }&lt;br /&gt;
    generic_template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.get_line_template()&lt;br /&gt;
    get_generic_template&lt;br /&gt;
  end&lt;br /&gt;
  def self.get_generic_template() #Currently used for bar and line graphs&lt;br /&gt;
    {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
            :title =&amp;gt;{},&lt;br /&gt;
            :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
            :min =&amp;gt; 0,&lt;br /&gt;
            :title =&amp;gt; {&lt;br /&gt;
                :text =&amp;gt; 'score'&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
            :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
            :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
            :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
            :shared =&amp;gt; true,&lt;br /&gt;
            :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
            :column =&amp;gt; {&lt;br /&gt;
                :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
                :borderWidth =&amp;gt; 0&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
            {&lt;br /&gt;
                :name =&amp;gt; 'review 1',&lt;br /&gt;
                :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 2',&lt;br /&gt;
                :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
            }, {&lt;br /&gt;
                :name =&amp;gt; 'review 3',&lt;br /&gt;
                :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91242</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91242"/>
		<updated>2014-10-30T03:12:14Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      :bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91241</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91241"/>
		<updated>2014-10-30T03:10:57Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
   def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      *''':bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]'''&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91236</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91236"/>
		<updated>2014-10-30T03:09:51Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Refactoring the dataTemplate method */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
def self.data_template()&lt;br /&gt;
    {&lt;br /&gt;
      :pie =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :plotBackgroundColor =&amp;gt; nil,&lt;br /&gt;
          :plotBorderWidth =&amp;gt; nil,&lt;br /&gt;
          :plotShadow =&amp;gt; false&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Title'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {},&lt;br /&gt;
        :yAxis =&amp;gt; {},&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :pointFormat =&amp;gt; '{series.name}: &amp;lt;b&amp;gt;{point.percentage}%&amp;lt;/b&amp;gt;',&lt;br /&gt;
          :percentageDecimals =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :pie =&amp;gt; {&lt;br /&gt;
            :allowPointSelect =&amp;gt; true,&lt;br /&gt;
            :cursor =&amp;gt; 'pointer',&lt;br /&gt;
            :dataLabels =&amp;gt; {&lt;br /&gt;
              :enabled =&amp;gt; true,&lt;br /&gt;
              :color =&amp;gt; '#000000',&lt;br /&gt;
              :connectorColor =&amp;gt; '#000000',&lt;br /&gt;
              :format =&amp;gt; &amp;quot;&amp;lt;b&amp;gt;{point.name}&amp;lt;/b&amp;gt;: {percentage:.2f} %&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :type =&amp;gt; 'pie',&lt;br /&gt;
            :name =&amp;gt; 'XXX pie',&lt;br /&gt;
            :data =&amp;gt; [&lt;br /&gt;
              ['part 1',45.0],&lt;br /&gt;
              ['part 2',26.8],&lt;br /&gt;
              ['part 3',8.5],&lt;br /&gt;
              ['part 4',6.2],&lt;br /&gt;
              ['part 5',0.7]&lt;br /&gt;
            ]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
      *''':bar =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'column'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f}&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :line =&amp;gt; {&lt;br /&gt;
        :title =&amp;gt; {:text =&amp;gt; &amp;quot;Review score for XXXX&amp;quot;},&lt;br /&gt;
        :subtitle =&amp;gt; {:text =&amp;gt; &amp;quot;subtitle here&amp;quot;},&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt;{},&lt;br /&gt;
          :categories =&amp;gt; [ 'Problem1', 'Problem2', 'Problem3', 'Problem4', 'Problem5', 'Problem6', 'Problem7', 'Problem8', 'Problem9', 'Problem10', 'Problem11','Problem12']&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :min =&amp;gt; 0,&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'score'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :tooltip =&amp;gt; {&lt;br /&gt;
          :headerFormat =&amp;gt; '&amp;lt;span style=&amp;quot;font-size:10px&amp;quot;&amp;gt;{point.key}&amp;lt;/span&amp;gt;&amp;lt;table&amp;gt;',&lt;br /&gt;
          :pointFormat =&amp;gt; '&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;color:{series.color};padding:0&amp;quot;&amp;gt;{series.name}: &amp;lt;/td&amp;gt;' +'&amp;lt;td style=&amp;quot;padding:0&amp;quot;&amp;gt;&amp;lt;b&amp;gt;{point.y:.1f} mm&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;',&lt;br /&gt;
          :footerFormat =&amp;gt; '&amp;lt;/table&amp;gt;',&lt;br /&gt;
          :shared =&amp;gt; true,&lt;br /&gt;
          :useHTML =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :column =&amp;gt; {&lt;br /&gt;
            :pointPadding =&amp;gt; 0.2,&lt;br /&gt;
            :borderWidth =&amp;gt; 0&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'review 1',&lt;br /&gt;
            :data =&amp;gt; [9.9, 7.5, 6.4, 9.2, 4.0, 6.0, 5.6, 8.5, 6.4, 4.1, 5.6, 4.4]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 2',&lt;br /&gt;
            :data =&amp;gt;  [3.6, 8.8, 8.5, 3.4, 6.0, 4.5, 5.0, 4.3, 9.2, 8.5, 6.6, 9.3]&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'review 3',&lt;br /&gt;
            :data =&amp;gt; [8.9, 8.8, 9.3, 4.4, 7.0, 8.3, 9.0, 9.6, 5.4, 6.2, 9.3, 5.2]&lt;br /&gt;
          }&lt;br /&gt;
        ]&lt;br /&gt;
      },&lt;br /&gt;
&lt;br /&gt;
      :scatter =&amp;gt; {&lt;br /&gt;
        :chart =&amp;gt; {&lt;br /&gt;
          :type =&amp;gt; 'scatter',&lt;br /&gt;
          :zoomType =&amp;gt; 'xy'&lt;br /&gt;
        },&lt;br /&gt;
        :title =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Height Versus Weight of 507 Individuals by Gender'&lt;br /&gt;
        },&lt;br /&gt;
        :subtitle =&amp;gt; {&lt;br /&gt;
          :text =&amp;gt; 'Source: Heinz  2003'&lt;br /&gt;
        },&lt;br /&gt;
        :xAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :enabled =&amp;gt; true,&lt;br /&gt;
            :text =&amp;gt; 'Height (cm)'&lt;br /&gt;
          },&lt;br /&gt;
          :startOnTick =&amp;gt; true,&lt;br /&gt;
          :endOnTick =&amp;gt; true,&lt;br /&gt;
          :showLastLabel =&amp;gt; true&lt;br /&gt;
        },&lt;br /&gt;
        :yAxis =&amp;gt; {&lt;br /&gt;
          :title =&amp;gt; {&lt;br /&gt;
            :text =&amp;gt; 'Weight (kg)'&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :legend =&amp;gt; {&lt;br /&gt;
          :layout =&amp;gt; 'vertical',&lt;br /&gt;
          :align =&amp;gt; 'left',&lt;br /&gt;
          :verticalAlign =&amp;gt; 'top',&lt;br /&gt;
          :x =&amp;gt; 100,&lt;br /&gt;
          :y =&amp;gt; 70,&lt;br /&gt;
          :floating =&amp;gt; true,&lt;br /&gt;
          :backgroundColor =&amp;gt; '#FFFFFF',&lt;br /&gt;
          :borderWidth =&amp;gt; 1&lt;br /&gt;
        },&lt;br /&gt;
        :plotOptions =&amp;gt; {&lt;br /&gt;
          :scatter =&amp;gt; {&lt;br /&gt;
            :marker =&amp;gt; {&lt;br /&gt;
              :radius =&amp;gt; 5,&lt;br /&gt;
              :states =&amp;gt; {&lt;br /&gt;
                :hover =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; true,&lt;br /&gt;
                  :lineColor =&amp;gt; 'rgb(100,100,100)'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :states =&amp;gt; {&lt;br /&gt;
              :hover =&amp;gt; {&lt;br /&gt;
                :marker =&amp;gt; {&lt;br /&gt;
                  :enabled =&amp;gt; false&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            },&lt;br /&gt;
            :tooltip =&amp;gt; {&lt;br /&gt;
              :headerFormat =&amp;gt; '&amp;lt;b&amp;gt;{series.name}&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;',&lt;br /&gt;
              :pointFormat =&amp;gt; '{point.x} cm, {point.y} kg'&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        :series =&amp;gt; [&lt;br /&gt;
          {&lt;br /&gt;
            :name =&amp;gt; 'Female',&lt;br /&gt;
            :color =&amp;gt; 'rgba(223, 83, 83, .5)',&lt;br /&gt;
            :data =&amp;gt; [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],&lt;br /&gt;
                      [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],&lt;br /&gt;
                      [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],&lt;br /&gt;
                      [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],&lt;br /&gt;
                      [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],&lt;br /&gt;
                      [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],&lt;br /&gt;
                      [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],&lt;br /&gt;
                      [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],&lt;br /&gt;
                      [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],&lt;br /&gt;
                      [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],&lt;br /&gt;
                      [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],&lt;br /&gt;
                      [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],&lt;br /&gt;
                      [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],&lt;br /&gt;
                      [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],&lt;br /&gt;
                      [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],&lt;br /&gt;
                      [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],&lt;br /&gt;
                      [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],&lt;br /&gt;
                      [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],&lt;br /&gt;
                      [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],&lt;br /&gt;
                      [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],&lt;br /&gt;
                      [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],&lt;br /&gt;
                      [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],&lt;br /&gt;
                      [166.8, 56.6], [172.7, 105.2], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],&lt;br /&gt;
                      [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],&lt;br /&gt;
                      [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],&lt;br /&gt;
                      [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],&lt;br /&gt;
                      [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],&lt;br /&gt;
                      [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],&lt;br /&gt;
                      [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],&lt;br /&gt;
                      [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],&lt;br /&gt;
                      [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],&lt;br /&gt;
                      [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],&lt;br /&gt;
                      [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],&lt;br /&gt;
                      [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],&lt;br /&gt;
                      [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],&lt;br /&gt;
                      [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],&lt;br /&gt;
                      [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],&lt;br /&gt;
                      [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],&lt;br /&gt;
                      [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],&lt;br /&gt;
                      [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],&lt;br /&gt;
                      [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],&lt;br /&gt;
                      [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],&lt;br /&gt;
                      [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],&lt;br /&gt;
                      [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],&lt;br /&gt;
                      [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],&lt;br /&gt;
                      [160.0, 55.4], [165.1, 104.1], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],&lt;br /&gt;
                      [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],&lt;br /&gt;
                      [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],&lt;br /&gt;
                      [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],&lt;br /&gt;
                      [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],&lt;br /&gt;
                      [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],&lt;br /&gt;
                      [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]]&lt;br /&gt;
&lt;br /&gt;
          }, {&lt;br /&gt;
            :name =&amp;gt; 'Male',&lt;br /&gt;
            :color =&amp;gt; 'rgba(119, 152, 191, .5)',&lt;br /&gt;
            :data =&amp;gt; [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],&lt;br /&gt;
                      [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],&lt;br /&gt;
                      [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],&lt;br /&gt;
                      [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],&lt;br /&gt;
                      [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],&lt;br /&gt;
                      [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],&lt;br /&gt;
                      [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],&lt;br /&gt;
                      [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],&lt;br /&gt;
                      [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],&lt;br /&gt;
                      [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],&lt;br /&gt;
                      [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],&lt;br /&gt;
                      [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],&lt;br /&gt;
                      [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],&lt;br /&gt;
                      [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 101.6], [175.5, 63.2],&lt;br /&gt;
                      [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],&lt;br /&gt;
                      [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],&lt;br /&gt;
                      [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],&lt;br /&gt;
                      [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],&lt;br /&gt;
                      [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 102.3],&lt;br /&gt;
                      [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],&lt;br /&gt;
                      [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],&lt;br /&gt;
                      [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],&lt;br /&gt;
                      [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],&lt;br /&gt;
                      [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],&lt;br /&gt;
                      [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 116.4], [163.8, 72.2],&lt;br /&gt;
                      [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],&lt;br /&gt;
                      [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],&lt;br /&gt;
                      [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],&lt;br /&gt;
                      [190.5, 108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],&lt;br /&gt;
                      [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],&lt;br /&gt;
                      [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],&lt;br /&gt;
                      [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 102.3], [181.6, 70.5],&lt;br /&gt;
                      [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],&lt;br /&gt;
                      [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],&lt;br /&gt;
                      [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],&lt;br /&gt;
                      [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],&lt;br /&gt;
                      [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],&lt;br /&gt;
                      [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],&lt;br /&gt;
                      [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],&lt;br /&gt;
                      [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],&lt;br /&gt;
                      [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],&lt;br /&gt;
                      [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],&lt;br /&gt;
                      [167.6, 75.5], [186.7, 101.4], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],&lt;br /&gt;
                      [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],&lt;br /&gt;
                      [177.8, 102.5], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],&lt;br /&gt;
                      [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],&lt;br /&gt;
                      [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],&lt;br /&gt;
                      [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],&lt;br /&gt;
                      [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],&lt;br /&gt;
                      [180.3, 83.2], [180.3, 83.2]]&lt;br /&gt;
          }]'''&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91227</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91227"/>
		<updated>2014-10-30T03:06:15Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91223</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91223"/>
		<updated>2014-10-30T03:04:59Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      template = set_pie_data(data,template)&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template = set_template_optional_params(template)&lt;br /&gt;
    else&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      template=validate_optional_conf(optionalConf,template)&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.set_template_optional_params(template)&lt;br /&gt;
    template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
    template.delete(:subtitle)&lt;br /&gt;
    template.delete(:yAxis)&lt;br /&gt;
    template.delete(:xAxis)&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.validate_optional_conf(optionalConf,template)&lt;br /&gt;
    if optionalConf[:subtitle].nil? then&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
    else&lt;br /&gt;
      template[:subtitle]={}&lt;br /&gt;
      template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:y_axis].nil? then&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
    else&lt;br /&gt;
      template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:x_axis].nil? then&lt;br /&gt;
      template[:xAxis].delete(:title)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
      template[:xAxis].delete(:categories)&lt;br /&gt;
    else&lt;br /&gt;
      template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91215</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91215"/>
		<updated>2014-10-30T03:02:02Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''4&lt;br /&gt;
&lt;br /&gt;
  template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
  template.delete(:subtitle)&lt;br /&gt;
  template.delete(:yAxis)&lt;br /&gt;
  template.delete(:xAxis)&lt;br /&gt;
&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91209</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91209"/>
		<updated>2014-10-30T02:59:54Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
    def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91206</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91206"/>
		<updated>2014-10-30T02:58:58Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior&amp;lt;ref&amp;gt;[http://refactoring.com/ Refactoring]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Refactoring adds to the value of any program that has at least one of the following shortcomings&amp;lt;ref&amp;gt;[http://jexp.de/papers/refactoring/refactoring/node9.html#SECTION00330000000000000000 Benefits of Code Refactoring] Michael Hunger. Oct. 25, 2000&amp;lt;/ref&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* Programs that are hard to read are hard to modify.&lt;br /&gt;
* Programs that have duplicate logic are hard to modify&lt;br /&gt;
* Programs that require additional behavior that requires you to change running code are hard to modify.&lt;br /&gt;
* Programs with complex conditional logic are hard to modify.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
Object oriented design a process of planning a software system where objects will interact with each other to solve specific problems. Though an Object oriented language provides us with highly useful and important programming concepts like '''Inheritance''', '''Polymorphism''', '''Abstraction''' and '''Encapsulation''' which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. &lt;br /&gt;
''Object Oriented Design'' Principles are core of OOPS programming&amp;lt;ref&amp;gt;[http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz3Ha8L3cfz] Javin Paul. ''Blogspot''. March 3, 2012&amp;lt;/ref&amp;gt;. It is important to know these design principles, to create clean and modular design. There are a number of design principles that help us produce a more understandable and elegant code. &lt;br /&gt;
Some of these can be looked up [http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html here].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
:The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user     wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
:The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
def self.dataAdapter(type,data,optionalConf)&lt;br /&gt;
    template = data_template[type];&lt;br /&gt;
    if (type == :pie) then&lt;br /&gt;
      data[:type] = 'pie';&lt;br /&gt;
      template[:series] = [data]&lt;br /&gt;
    else&lt;br /&gt;
      template[:series] = data&lt;br /&gt;
    end&lt;br /&gt;
    if optionalConf.nil? then&lt;br /&gt;
      template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      template.delete(:subtitle)&lt;br /&gt;
      template.delete(:yAxis)&lt;br /&gt;
      template.delete(:xAxis)&lt;br /&gt;
    else&lt;br /&gt;
      if template[:subtitle].nil? then&lt;br /&gt;
        template[:subtitle]={}&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:title].nil? then&lt;br /&gt;
        template[:title][:text] = &amp;quot;&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        template[:title][:text] = optionalConf[:title]&lt;br /&gt;
      end&lt;br /&gt;
      if optionalConf[:subtitle].nil? then&lt;br /&gt;
        template.delete(:subtitle)&lt;br /&gt;
      else&lt;br /&gt;
        template[:subtitle][:text]=optionalConf[:subtitle]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:y_axis].nil? then&lt;br /&gt;
        template.delete(:yAxis)&lt;br /&gt;
      else&lt;br /&gt;
        template[:yAxis][:title][:text]=optionalConf[:y_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis].nil? then&lt;br /&gt;
        template[:xAxis].delete(:title)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:title][:text] = optionalConf[:x_axis]&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      if optionalConf[:x_axis_categories].nil? then&lt;br /&gt;
        template[:xAxis].delete(:categories)&lt;br /&gt;
      else&lt;br /&gt;
        template[:xAxis][:categories]=optionalConf[:x_axis_categories]&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    template&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
:The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
:This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design :at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
:The original method was setting up templates for all these different types of graphs in the same method which ''''violated the Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
Going beyond the scope of the project, the code for the analytic controller and helper was analyzed and fixed. &lt;br /&gt;
While testing the chart function file that had been modified, it was noted that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement identified were as follows: &lt;br /&gt;
&lt;br /&gt;
'''Issue 1'''&lt;br /&gt;
----&lt;br /&gt;
:*'Bar graph' was the only chart supported&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
:The modified code now provides support for the line and pie charts along with the bar graphs using the existing underlying framework. &lt;br /&gt;
&lt;br /&gt;
'''Issue 2'''&lt;br /&gt;
----&lt;br /&gt;
:*Probably because of the way ruby makes database queries by default, data fetching takes a long time &lt;br /&gt;
:*Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. &lt;br /&gt;
:*The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not&lt;br /&gt;
&lt;br /&gt;
'''Issue 3'''&lt;br /&gt;
----&lt;br /&gt;
:*The existing implementation does not render the graph when the bar option is selected. &lt;br /&gt;
:*This is because no data types are being displayed for selection, as shown in Figure 1&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, additional file changes were made. Following is a list of the changes in more detail,&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page&lt;br /&gt;
::Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
'''Existing code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &amp;lt;br&amp;gt;&lt;br /&gt;
'''Modified code:'''&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix''''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types&lt;br /&gt;
::In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
::'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data&lt;br /&gt;
::The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		&lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;[http://c2.com/cgi/wiki?SwitchStatementsSmell Switch Statements Smell] CGI Wiki. September 11, 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming '''bar_chart_data'''(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
::The current '''get_chart_data''' which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
'''Existing signature:'''&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
'''Modified signature:'''&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
::The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. Since the pie and line chart types were made functional, the corresponding options were enabled. Since there was no use case for scatter plots at the moment(given the scope), the scatter option still remains disabled. &lt;br /&gt;
::'''Development Note:''' Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
::Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Principles_of_user_interface_design Principles of User Interface design] ''Last Modified'' 24 July 2014&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
=Summary of Revised Design Principles=&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:5%;&amp;quot;|Sr. No.&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|File name&lt;br /&gt;
! style=&amp;quot;width:13%;&amp;quot;|Method Name&lt;br /&gt;
! style=&amp;quot;width:33%;&amp;quot;|Comment on Design Principle&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|''''' 1. '''''&lt;br /&gt;
|chart.rb&lt;br /&gt;
|dataAdapter &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|dataTemplate &lt;br /&gt;
|Violated the Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
|''''' 2. '''''&lt;br /&gt;
|analytic_controller.rb&lt;br /&gt;
|graph_data_type_list &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|init&lt;br /&gt;
|Follows the DRY Principle &lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_graph_data_bundle &lt;br /&gt;
|Eliminated the Switch Statement Smell Principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''3. '''''&lt;br /&gt;
|analytic_helper.rb&lt;br /&gt;
|bar_chart_data&lt;br /&gt;
|Violated the Single Responsibility Principle&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|get_chart_data&lt;br /&gt;
|Promotes DRY principle&lt;br /&gt;
|-&lt;br /&gt;
|'''''4. '''''&lt;br /&gt;
|views/analytic/index.html.erb&lt;br /&gt;
|&lt;br /&gt;
|Promotes Feedback principle in UI design&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91009</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91009"/>
		<updated>2014-10-30T00:01:21Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.&amp;lt;ref&amp;gt;http://refactoring.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
The original method was setting up templates for all these different types of graphs in the same method which violated the ''''Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
We have also gone beyond the scope of the project by analyzing and fixing the code of the analytic controller and helper respectively. When we try to test the chart function file we had modified, we realized that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement we identified were: &lt;br /&gt;
&lt;br /&gt;
*Issue 1&lt;br /&gt;
Currently, the code has support only for bar graphs.&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
We felt that the line and pie charts could be shown as well along with the bar graphs as most of the underlying framework was already present. Hence, we made line and pie charts available along with bar charts.&lt;br /&gt;
*Issue 2&lt;br /&gt;
Probably because of the way ruby makes database queries by default, data fetching takes a long time. Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not.&lt;br /&gt;
*Issue 3&lt;br /&gt;
The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1.&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, we made changes in some other files. Here is a list of those changes in more detail&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page. &lt;br /&gt;
Inside the '''graph_data_type_list''' function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix'''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types.&lt;br /&gt;
In '''init''' function, there is an instance variable called as '''@available_data_types''' which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, '''@generic_supported_types''' which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data. &lt;br /&gt;
The current implementation of '''get_graph_data_bundle''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		+    &lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irrespective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;http://c2.com/cgi/wiki?SwitchStatementsSmell&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming bar_chart_data(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
The current get_chart_data which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
Existing signature&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
Modified signature&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. We have got pie and line chart types working and hence enabled these features. Since there was no use case for scatter plots at the moment(given the scope), we have kept scatter option disabled. &lt;br /&gt;
Development Note: Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Principles_of_user_interface_design&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91007</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91007"/>
		<updated>2014-10-29T23:56:32Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Final Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.&amp;lt;ref&amp;gt;http://refactoring.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
The original method was setting up templates for all these different types of graphs in the same method which violated the ''''Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
We have also gone beyond the scope of the project by analyzing and fixing the code of the analytic controller and helper respectively. When we try to test the chart function file we had modified, we realized that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement we identified were: &lt;br /&gt;
&lt;br /&gt;
*Issue 1&lt;br /&gt;
Currently, the code has support only for bar graphs.&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
We felt that the line and pie charts could be shown as well along with the bar graphs as most of the underlying framework was already present. Hence, we made line and pie charts available along with bar charts.&lt;br /&gt;
*Issue 2&lt;br /&gt;
Probably because of the way ruby makes database queries by default, data fetching takes a long time. Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not.&lt;br /&gt;
*Issue 3&lt;br /&gt;
The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1.&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, we made changes in some other files. Here is a list of those changes in more detail&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page. &lt;br /&gt;
Inside the graph_data_type_list function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix'''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types.&lt;br /&gt;
In init function, there is an instance variable called as @available_data_types which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, @generic_supported_types which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data. &lt;br /&gt;
The current implementation of '''get_graph_data_bundle function''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		+    &lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irresepective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;http://c2.com/cgi/wiki?SwitchStatementsSmell&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming bar_chart_data(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
The current get_chart_data which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
Existing signature&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
Modified signature&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. We have got pie and line chart types working and hence enabled these features. Since there was no use case for scatter plots at the moment(given the scope), we have kept scatter option disabled. &lt;br /&gt;
Development Note: Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Principles_of_user_interface_design&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|center|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|center|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|center|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91005</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91005"/>
		<updated>2014-10-29T23:56:02Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Final Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.&amp;lt;ref&amp;gt;http://refactoring.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
The original method was setting up templates for all these different types of graphs in the same method which violated the ''''Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
We have also gone beyond the scope of the project by analyzing and fixing the code of the analytic controller and helper respectively. When we try to test the chart function file we had modified, we realized that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement we identified were: &lt;br /&gt;
&lt;br /&gt;
*Issue 1&lt;br /&gt;
Currently, the code has support only for bar graphs.&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
We felt that the line and pie charts could be shown as well along with the bar graphs as most of the underlying framework was already present. Hence, we made line and pie charts available along with bar charts.&lt;br /&gt;
*Issue 2&lt;br /&gt;
Probably because of the way ruby makes database queries by default, data fetching takes a long time. Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not.&lt;br /&gt;
*Issue 3&lt;br /&gt;
The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1.&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, we made changes in some other files. Here is a list of those changes in more detail&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page. &lt;br /&gt;
Inside the graph_data_type_list function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix'''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types.&lt;br /&gt;
In init function, there is an instance variable called as @available_data_types which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, @generic_supported_types which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data. &lt;br /&gt;
The current implementation of '''get_graph_data_bundle function''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		+    &lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irresepective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;http://c2.com/cgi/wiki?SwitchStatementsSmell&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming bar_chart_data(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
The current get_chart_data which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
Existing signature&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
Modified signature&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. We have got pie and line chart types working and hence enabled these features. Since there was no use case for scatter plots at the moment(given the scope), we have kept scatter option disabled. &lt;br /&gt;
Development Note: Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Principles_of_user_interface_design&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
&lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|left|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|left|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|left|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91004</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1455 skn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1455_skn&amp;diff=91004"/>
		<updated>2014-10-29T23:55:36Z</updated>

		<summary type="html">&lt;p&gt;Nmathew: /* Final Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''E1455: Refactoring the Chart helper'''=&lt;br /&gt;
=='''Overview'''==&lt;br /&gt;
===Code refactoring===&lt;br /&gt;
''Refactoring'' is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.&amp;lt;ref&amp;gt;http://refactoring.com/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following O-O Design Principles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Project Resources =&lt;br /&gt;
* [https://github.com/noelmathew/expertiza GitHub Repository]&lt;br /&gt;
* [http://152.46.16.178:3001/ VCL IP]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Objective =&lt;br /&gt;
The aim of the project was to refactor the chart helper module of Expertiza. The task was to analyze the helper chart.rb which failed to follow the object oriented design principles. There were two major functions being used in the class, effectively. These two functions were performing all their operations in one single block which led to code duplication and redundancy. Our task involved removing these design errors and making it more elegant and efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Files Modified=&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/chart.rb chart.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/helpers/analytic_helper.rb analytic_helper.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/controllers/analytic_controller.rb analytic_controller.rb]&lt;br /&gt;
* [https://github.com/noelmathew/expertiza/blob/rails4/app/views/analytic/index.html.erb views/analytic/index.html.erb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Requirements =&lt;br /&gt;
The following changes were expected, &lt;br /&gt;
&lt;br /&gt;
* '''self.dataAdapter method'''&lt;br /&gt;
*# Too long, needs to be divided&lt;br /&gt;
*# Too many if-else statements&lt;br /&gt;
&lt;br /&gt;
* '''self.data_template method'''&lt;br /&gt;
*# Needs to be broken down or moved according to requirement&lt;br /&gt;
*# Define each template independently instead of in the same method&lt;br /&gt;
*# Remove unecessary data from :series for scatter plot&lt;br /&gt;
*# Method has duplicate data. Remove the duplicate occurrences&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Design Changes =&lt;br /&gt;
To fulfill the requirements, the following changes were implemented,&lt;br /&gt;
== Refactoring the ''dataAdapter method'' ==&lt;br /&gt;
&lt;br /&gt;
*'''What it does'''&amp;lt;br&amp;gt;&lt;br /&gt;
The ''dataAdapter function'' is basically an initialization function which sets parameters for the graphical plot to some default starting values based on the type of analytic view the user wants to rendered. There was quite a bit of code duplication in the existing function, especially when it came to setting parameters for some specific chart types like pie charts for instance.&lt;br /&gt;
The code in this function violated the ''''Single Responsibility Principle''''.&lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Moved code for setting optional parameters to function '''''set_template_optional_params'''''&lt;br /&gt;
# Moved code for validation of optional parameters to function '''''called validate_optional_conf'''''&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle anymore&lt;br /&gt;
&lt;br /&gt;
== Refactoring the ''dataTemplate method'' ==&lt;br /&gt;
*'''What it does'''&lt;br /&gt;
The main purpose of this method was to set up the data templates for the different varieties of graphs - bar , scatter , pie and line namely.&lt;br /&gt;
This method, again, was too long and executing too many different tasks in the same block of code. Furthermore, there was a lot of code duplication which did not follow object-oriented design at all. There was also hard-coded data which was not serving much purpose which we decided to prune to make the code more elegant. &lt;br /&gt;
The original method was setting up templates for all these different types of graphs in the same method which violated the ''''Single Responsibility Principle''''. &lt;br /&gt;
&lt;br /&gt;
*'''Original code:'''&lt;br /&gt;
&lt;br /&gt;
*'''Changes made:'''&lt;br /&gt;
# Created separate methods for each different plot - ''bar'' , ''line'' , ''pie'' and ''scatter''&lt;br /&gt;
# Created one method called '''''get_generic_template''''' to set up some common parameters which are used by more than one plot.&lt;br /&gt;
# The new code ''does not'' violate the Single Responsibility Principle and also ''supports'' '''Separation of Concerns''' and '''Code Reuse''' which are both good practices when it comes to object-oriented design.&lt;br /&gt;
&lt;br /&gt;
=Bonus Changes=&lt;br /&gt;
&lt;br /&gt;
We have also gone beyond the scope of the project by analyzing and fixing the code of the analytic controller and helper respectively. When we try to test the chart function file we had modified, we realized that the analytic view page that was using the chart helper class had certain issues/areas of improvement. The issues/areas of improvement we identified were: &lt;br /&gt;
&lt;br /&gt;
*Issue 1&lt;br /&gt;
Currently, the code has support only for bar graphs.&lt;br /&gt;
[[File:Existing View.png|frame|center|Figure 1: The existing page]]&lt;br /&gt;
We felt that the line and pie charts could be shown as well along with the bar graphs as most of the underlying framework was already present. Hence, we made line and pie charts available along with bar charts.&lt;br /&gt;
*Issue 2&lt;br /&gt;
Probably because of the way ruby makes database queries by default, data fetching takes a long time. Order of ~10s for simple options(assignment and team comparisons) and ~5 mins for larger comparisons(course comparisons), based on VCL deployed versions. The page just stayed idle with no message. This can be frustrating for the user who is unsure if the chart is going to be rendered or not.&lt;br /&gt;
*Issue 3&lt;br /&gt;
The existing implementation does not render the graph when the bar option is selected. This is because no data types are being displayed for selection, as shown in Figure 1.&lt;br /&gt;
&lt;br /&gt;
=Extra File Changes=&lt;br /&gt;
To render the different types of graph, apart from the given requirement of the project, we made changes in some other files. Here is a list of those changes in more detail&lt;br /&gt;
==app/controllers/analytic_controller.rb==&lt;br /&gt;
The file used for rendering the analytic view. The changes made include: &lt;br /&gt;
*Fixing a bug which was preventing the data type options from being displayed in the analytic view page. &lt;br /&gt;
Inside the graph_data_type_list function, the following line of code was used to get a common list of data types for the graph type and the comparison scope.&lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; @available_data_types[params[:type].to_sym]&lt;br /&gt;
However, this intersection was always evaluating to an empty set because '''@available_data_types[params[:scope].to_sym]''' retrieved a list of symbols and '''@available_data_types[params[:type].to_sym]''' retrieved a list of strings. Hence, the data type list was always empty as can be shown in Figure 1.&lt;br /&gt;
This was corrected by converting the list of string to a list of symbols and then taking an intersection as shown below: &lt;br /&gt;
  data_type_list = @available_data_types[params[:scope].to_sym] &amp;amp; (@available_data_types[params[:type].to_sym].map &amp;amp;:to_sym)&lt;br /&gt;
This change is a ''''bug fix'''.	&lt;br /&gt;
*Moving the common data type options to a separate list for reuse by bar, line and pie chart types.&lt;br /&gt;
In init function, there is an instance variable called as @available_data_types which has an object with key ‘bar’ and value as the list of methods supported by bar graphs. We felt it could be reused by the graphs of type, line and bar. Hence, we moved it to a common variable, @generic_supported_types which could be reused by line, bar and pie graph types. This change follows the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
'''Development Note:''' The bar options have been reused for line and pie graphs. Based on requirements, these can be altered. We have just enabled the functionality for pie and bar so that once the requirements are ready, they can be easily plugged in.&lt;br /&gt;
*Eliminating switch case statements in get_graph_data_bundle and redirecting the call to a more generic function to get the chart data. &lt;br /&gt;
The current implementation of '''get_graph_data_bundle function''' had a set of switch case statements depending on the graph type. &lt;br /&gt;
  case params[:type]		+    &lt;br /&gt;
  when &amp;quot;line&amp;quot;		&lt;br /&gt;
      chart_data = line_graph_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;bar&amp;quot;		&lt;br /&gt;
      chart_data = bar_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;scatter&amp;quot;		&lt;br /&gt;
      chart_data = scatter_plot_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  when &amp;quot;pie&amp;quot;		&lt;br /&gt;
     chart_data = pie_chart_data(params[:scope], params[:id], params[:data_type])		&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
However, since the underlying principle of fetching the graph types is the same, we felt the call should be re-routed to a generic function which can fetch the data irresepective of the graph type. This has helped us to '''eliminate Switch Statement Smell'''&amp;lt;ref&amp;gt;http://c2.com/cgi/wiki?SwitchStatementsSmell&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  chart_data = get_chart_data(params[:type],params[:scope], params[:id], params[:data_type])&lt;br /&gt;
&lt;br /&gt;
==app/helpers/analytic_helper.rb==&lt;br /&gt;
This file is used to redirect the calls to the appropriate method based on the data type selected for comparison and fetch the data to be sent to the Chart helper function. &lt;br /&gt;
Changes in this file include: &lt;br /&gt;
*Renaming bar_chart_data(which was specific and had reusable code) to a more generic function.&lt;br /&gt;
The current get_chart_data which can be used for bar, line and pie charts. The current function’s name indicated that it could be used to retrieve only bar chart data. However the data is independent of the chart type, hence we felt this should be a more generic data fetcher. &lt;br /&gt;
Existing signature&lt;br /&gt;
  def bar_chart_data(object_type, object_id_list, data_type_list) &lt;br /&gt;
Modified signature&lt;br /&gt;
  def get_chart_data(chart_type, object_type, object_id_list, data_type_list). &lt;br /&gt;
&lt;br /&gt;
Also the earlier function was passing ''':bar''' to the initialize method of the chart object. The value was being hardcoded. With the current implementation, the input parameter chart_type is passed to the chart object. This helps in the code being more flexible and the re usability of the code for any type of chart type promotes the '''DRY principle'''.&lt;br /&gt;
&lt;br /&gt;
==app/views/analytic/index.html.erb== &lt;br /&gt;
The file which shows the view for the analytics. The changes made to this file include: &lt;br /&gt;
*Enabling options for line and pie charts. &lt;br /&gt;
The current implementation had only the bar option enabled. The other options(line, pie, scatter) were disabled. We have got pie and line chart types working and hence enabled these features. Since there was no use case for scatter plots at the moment(given the scope), we have kept scatter option disabled. &lt;br /&gt;
Development Note: Pie chart currently only compares based on the first selected data type. It should either render multiple pie charts or provide radio buttons for selecting one data type at a time.&lt;br /&gt;
&lt;br /&gt;
*Displaying user friendly messages while the chart is being generated. &lt;br /&gt;
Currently the page shows an empty chart area when the chart is being rendered. The graph sometimes takes a long time to be rendered as mentioned in the issues. An ideal task would have been to look at the queries being made and make them faster. Given the scope of the project and the time restriction, we thought of adding basic user-friendly message. This feature promotes '''Feedback principle in UI design'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Principles_of_user_interface_design&amp;lt;/ref&amp;gt;&lt;br /&gt;
[[File:PleaseWait.png|frame|center|Figure 2: Message to show chart is being processed]]&lt;br /&gt;
'''Development Note''': The retrieval queries should be inspected to see if the data retrieval can be made faster. &lt;br /&gt;
Since the chart rendering is fired whenever there is a change in selection of the data point and the comparison scope, we have added a friendly error message which tells the user to choose the options.&lt;br /&gt;
[[File:ParametersNotSelected.png|frame|center|Figure 3: Friendly error message to guide users]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Final Result= &lt;br /&gt;
The analytics view now supports line and pie chart options along with the Bar Option(which was not working earlier) &lt;br /&gt;
==Sample Bar Chart==&lt;br /&gt;
[[File:BarChart.png|frame|left|Figure 4: Bar Chart]]&lt;br /&gt;
&lt;br /&gt;
==Sample Line Graph==&lt;br /&gt;
[[File:LineGraph.png|frame|left|Figure 5: Line Graph]]&lt;br /&gt;
&lt;br /&gt;
==Sample Pie Chart==&lt;br /&gt;
[[File:PieChart.png|frame|left|Figure 6: Pie chart]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nmathew</name></author>
	</entry>
</feed>