<?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=Aanilku</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=Aanilku"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Aanilku"/>
	<updated>2026-10-13T14:21:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106884</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106884"/>
		<updated>2016-12-15T16:54:04Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: |&amp;amp;controller_name|method|roleid|userid|event: {login|submission|.....}|event_description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
[[File:view2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each log entry has a serial number, timestamp, name of the event, description of the event, type of the user involved in the event and userID of the user.&lt;br /&gt;
We have provided the option to search the logs by user type, userID, event type and time.&lt;br /&gt;
You can notice that there is a second search field below just above  the table. It does an in page search of the results that are currently loaded. Its faster if you dont want the latest logs. It will search only the records that were present in the log file when the page was loaded. If you want to search the latest logs, i.e logs that have been added after the page was loaded, you need to use the first search button. This search will be comparatively slower as it involves a controller hit and redirection back to the view page.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written a feature test in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
&lt;br /&gt;
====Test 1====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;br /&gt;
This project can be easily extended by adding more log statements to additional or new events by simply making a log entry with our logger object in the specified format. If proper format is followed, it will get picked up by the parser and will be visible in the view.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
We learned a lot doing this project. It was a good experience contributing to open source software. We got a chance to add an entire model, view and controller to the existing codebase.  We also had to read through all the existing controller code to insert logging statements at proper locations to log user activity. This was a good learning experience.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106883</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106883"/>
		<updated>2016-12-15T16:53:18Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Future Extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
[[File:view2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each log entry has a serial number, timestamp, name of the event, description of the event, type of the user involved in the event and userID of the user.&lt;br /&gt;
We have provided the option to search the logs by user type, userID, event type and time.&lt;br /&gt;
You can notice that there is a second search field below just above  the table. It does an in page search of the results that are currently loaded. Its faster if you dont want the latest logs. It will search only the records that were present in the log file when the page was loaded. If you want to search the latest logs, i.e logs that have been added after the page was loaded, you need to use the first search button. This search will be comparatively slower as it involves a controller hit and redirection back to the view page.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written a feature test in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
&lt;br /&gt;
====Test 1====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;br /&gt;
This project can be easily extended by adding more log statements to additional or new events by simply making a log entry with our logger object in the specified format. If proper format is followed, it will get picked up by the parser and will be visible in the view.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
We learned a lot doing this project. It was a good experience contributing to open source software. We got a chance to add an entire model, view and controller to the existing codebase.  We also had to read through all the existing controller code to insert logging statements at proper locations to log user activity. This was a good learning experience.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106882</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106882"/>
		<updated>2016-12-15T04:20:29Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
[[File:view2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each log entry has a serial number, timestamp, name of the event, description of the event, type of the user involved in the event and userID of the user.&lt;br /&gt;
We have provided the option to search the logs by user type, userID, event type and time.&lt;br /&gt;
You can notice that there is a second search field below just above  the table. It does an in page search of the results that are currently loaded. Its faster if you dont want the latest logs. It will search only the records that were present in the log file when the page was loaded. If you want to search the latest logs, i.e logs that have been added after the page was loaded, you need to use the first search button. This search will be comparatively slower as it involves a controller hit and redirection back to the view page.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written a feature test in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
&lt;br /&gt;
====Test 1====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;br /&gt;
This project can be easily extended by adding more log statements to additional or new events by simply making a log entry with our logger object in the specified format. If proper format is followed, it will get picked up by the parser and will be visible in the view.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106881</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106881"/>
		<updated>2016-12-15T03:41:26Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* New Views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
[[File:view2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each log entry has a serial number, timestamp, name of the event, description of the event, type of the user involved in the event and userID of the user.&lt;br /&gt;
We have provided the option to search the logs by user type, userID, event type and time.&lt;br /&gt;
You can notice that there is a second search field below just above  the table. It does an in page search of the results that are currently loaded. Its faster if you dont want the latest logs. It will search only the records that were present in the log file when the page was loaded. If you want to search the latest logs, i.e logs that have been added after the page was loaded, you need to use the first search button. This search will be comparatively slower as it involves a controller hit and redirection back to the view page.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;br /&gt;
This project can be easily extended by adding more log statements to additional or new events by simply making a log entry with our logger object in the specified format. If proper format is followed, it will get picked up by the parser and will be visible in the view.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:View2.png&amp;diff=106880</id>
		<title>File:View2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:View2.png&amp;diff=106880"/>
		<updated>2016-12-15T03:35:07Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:View.png&amp;diff=106879</id>
		<title>File:View.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:View.png&amp;diff=106879"/>
		<updated>2016-12-15T03:32:50Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106878</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106878"/>
		<updated>2016-12-15T03:28:33Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Future Extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;br /&gt;
This project can be easily extended by adding more log statements to additional or new events by simply making a log entry with our logger object in the specified format. If proper format is followed, it will get picked up by the parser and will be visible in the view.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106877</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106877"/>
		<updated>2016-12-15T03:26:56Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Future Extension==&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106852</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106852"/>
		<updated>2016-12-13T21:33:54Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
*application_controller.rb&lt;br /&gt;
*admin_controller.rb&lt;br /&gt;
*advice_controller.rb&lt;br /&gt;
*assignment_questionnaire_controller.rb&lt;br /&gt;
*assignment_signups_controller.rb&lt;br /&gt;
*assignments_controller.rb&lt;br /&gt;
*auth_controller.rb&lt;br /&gt;
*course_controller.rb&lt;br /&gt;
*impersonate_controller.rb&lt;br /&gt;
*import_file_controller.rb&lt;br /&gt;
*invitation_controller.rb&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*response_controller.rb&lt;br /&gt;
*review_mapping_controller.rb&lt;br /&gt;
*submitted_content_controller.rb&lt;br /&gt;
*teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events. We have added a total of 45 logging statements for different events.&lt;br /&gt;
&lt;br /&gt;
The new code in the other controllers are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
*logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
*log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106845</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106845"/>
		<updated>2016-12-13T15:59:07Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* New Views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events.&lt;br /&gt;
&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The new code we added are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
*view_logs.html.erb&lt;br /&gt;
This is the view we created for viewing the logs records. The used is also given an option to filter the logs based on time, userid, user type and event type.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106844</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106844"/>
		<updated>2016-12-13T15:54:11Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Changes in existing files====&lt;br /&gt;
We have defined a logger object in the application_controller that points to our new log file: events.log.&lt;br /&gt;
Since this is defined in the application controller, it will be accessible in all the controllers and there is no need to redefine it again in the other controllers where we use it to log events.&lt;br /&gt;
&lt;br /&gt;
We have also inserted new code in the following controllers:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The new code we added are simple logging statements to log events, does not affect the functionality of the existing code in any way.&lt;br /&gt;
&lt;br /&gt;
====New Controllers====&lt;br /&gt;
logger_controller.rb&lt;br /&gt;
We created a new controller for reading and filtering the log records. &lt;br /&gt;
This has two actions, for viewing the logs and for filtering the logs based on input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Models===&lt;br /&gt;
log_entry.rb&lt;br /&gt;
This model was created to represent each log statement in the record. It contains fields that pertain to a log entry like the time, userid, event and log description&lt;br /&gt;
&lt;br /&gt;
===New Views===&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106843</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106843"/>
		<updated>2016-12-13T15:41:13Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Interpreting the Logs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Implementation====&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106736</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106736"/>
		<updated>2016-12-11T04:03:07Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|roleid| userid|event: {login|submission|.....}|event description]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106735</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=106735"/>
		<updated>2016-12-11T03:49:43Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Overall Process.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the '''ActiveSupport::Logger''' class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*'''UNKNOWN''' : An unknown message that should always be logged.&lt;br /&gt;
*'''FATAL'''   : A unhandleable error that results in a program crash&lt;br /&gt;
*'''ERROR'''   : A handleable error condition&lt;br /&gt;
*'''WARN'''    : Warnings&lt;br /&gt;
*'''INFO'''    : Useful info about system operation&lt;br /&gt;
*'''DEBUG'''   : Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Design==&lt;br /&gt;
====Logging====&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Log Events.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:LogToGUI.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
====RSpec Testing====&lt;br /&gt;
We have written feature tests in RSpec for the logger module. We have created a new class: logger_spec.rb for the test cases.&lt;br /&gt;
====Test 1====&lt;br /&gt;
Check if the link redirects to the log view page when you click on it. &lt;br /&gt;
&lt;br /&gt;
====Test 2====&lt;br /&gt;
If the user having less privileges than an admin tries to access the log viewer page, then he/she gets a authentication failure message.&lt;br /&gt;
&lt;br /&gt;
====Test 3====&lt;br /&gt;
Tests if the search functionality is working properly or not. Tests by searching with a user ID and checks if the results contain only results for that particular user ID.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105381</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105381"/>
		<updated>2016-11-11T00:29:24Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Interpreting the Logs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;br /&gt;
&lt;br /&gt;
This is a rough sketch of what the page will look like:&lt;br /&gt;
[[File:sketch.png|frame]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It will have a text field to specify the user ID, a drop down menu to select the event and two date picker fields to specify the begin and end dates for the logs&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Sketch.png&amp;diff=105380</id>
		<title>File:Sketch.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Sketch.png&amp;diff=105380"/>
		<updated>2016-11-11T00:26:41Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:MockScreen.png&amp;diff=105379</id>
		<title>File:MockScreen.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:MockScreen.png&amp;diff=105379"/>
		<updated>2016-11-11T00:21:01Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105165</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105165"/>
		<updated>2016-11-10T01:57:09Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* What we plan to implement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. &lt;br /&gt;
&lt;br /&gt;
Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. &lt;br /&gt;
&lt;br /&gt;
We plan on improving the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities.  We will also be adding more log statements which will make it easier to track all student, TA and instructor activities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105160</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105160"/>
		<updated>2016-11-10T01:54:54Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Instructor/TA/Admin Activity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
Creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. We improve the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105159</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105159"/>
		<updated>2016-11-10T01:54:20Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. We improve the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105158</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105158"/>
		<updated>2016-11-10T01:53:30Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
===The Idea===&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. We improve the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 [TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}]&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 [TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}]&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105156</id>
		<title>CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1703:_Logging_for_Expertiza&amp;diff=105156"/>
		<updated>2016-11-10T01:52:29Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: Created page with &amp;quot;==Introduction== Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Currently, Expertiza doesn’t log anything, beyond the events in the console log.  But often we need to know when a student logged in, reserved a topic, dropped off a team, etc. This will help the admin/instructor verify claims made by the student saying that he had submitted something or did some other activity that but didnt get reflected in expertiza due to a bug, a network issue or something else that went wrong.&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
In a production environment, logs are the best way to debug the application when something goes wrong. In the absence of logs, it is very difficult for a developer/support technician to debug and analyze what went wrong.&lt;br /&gt;
&lt;br /&gt;
===The Idea===&lt;br /&gt;
&lt;br /&gt;
==Events to Log==&lt;br /&gt;
====Student Activity====&lt;br /&gt;
Logins, logouts, signups, submission of files/links (although there is already a log of when links are submitted), issuing invitations, joining teams, dropping off teams, requesting reviews, submitting reviews (or author feedback, or teammate reviews, or meta-reviews), undoing any of these operations.  &lt;br /&gt;
&lt;br /&gt;
====Instructor/TA/Admin Activity====&lt;br /&gt;
creating/editing courses and assignments, giving grades, impersonating other users, adding TAs, adding participants to courses or assignments, assigning reviewers.&lt;br /&gt;
&lt;br /&gt;
==What we plan to implement==&lt;br /&gt;
There are two parts to this project:&lt;br /&gt;
*Logging the events and other information that will help in debugging&lt;br /&gt;
*Creating a GUI to interpret the logs and show events for a particular user in a particular time frame.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We are planning to use the logging framework that comes inbuilt with rails. Rails makes use of the ActiveSupport::Logger class to write log information. Each log statement in the program  has a level associated with it which indicates their importance. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hierarchy of log messages is as below:&lt;br /&gt;
*UNKNOWN: An unknown message that should always be logged.&lt;br /&gt;
*FATAL: A unhandleable error that results in a program crash&lt;br /&gt;
*ERROR: A handleable error condition&lt;br /&gt;
*WARN: Warnings&lt;br /&gt;
*INFO: Useful info about system operation&lt;br /&gt;
*DEBUG: Low level info for developers to help with debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the config file, we can specify the level of logs to be printed. A log statement in the program will be printed only if its level is equal to or higher than the level set in the config file. Usually in production, we set the level to INFO or WARN and in in a development environment, we set it to debug which will print out all the finer details of the state of the system which helps in debugging.&lt;br /&gt;
Currently, the expertiza code contains very little logging statement and it does not record student/instructor or TA activity. The current logs are also  of little or no help to a developer/ support technician trying to debug the code when something goes wrong. We improve the current log statements by adding more information to it so that it becomes more useful to the person trying to debug the code and will also record all student, TA and instructor activities. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the second part of the project, we will create a view that is accessible only to the admin from his console. This view will list out the events by interpreting the logs and give an option to filter it based on user and date.&lt;br /&gt;
&lt;br /&gt;
==Approch==&lt;br /&gt;
====Logging====&lt;br /&gt;
We are planning to standardize the log statements by giving them a predefined format. This will also help us in the second part of the project which is to interpret the logs and display student activities in a GUI.&lt;br /&gt;
This is the format we propose:&lt;br /&gt;
*INFO:&lt;br /&gt;
 TimeStamp: | controller_name|method|  roleid| userid|event: {login|submission|.....}&lt;br /&gt;
 We will use this to log entry into methods and to log events like login, submission, joining teams, leaving teams, creating assignments, inviting other user to team etc.&lt;br /&gt;
*DEBUG:&lt;br /&gt;
 TimeStamp: controller_name| method_name|roleid| userid|{variable_name, variable_value}&lt;br /&gt;
 We will use this to print out values of key variables which the developer/debugger can use for debugging.&lt;br /&gt;
&lt;br /&gt;
In the production environment, we will limit the logs to INFO mode, i.e it will print out only the errors and events.&lt;br /&gt;
&lt;br /&gt;
In development environment, we will set the logger mode to DEBUG. This will print out all the logs including errors, events and debug statements. This will help the developer in debugging the code when something goes wrong.&lt;br /&gt;
&lt;br /&gt;
====Interpreting the Logs====&lt;br /&gt;
This is the second part of the project. We will be creating a GUI to interpret and make sense of all the log data. The GUI will display the events for each user. We will also give an option to filter the event listing  based on date and events.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=105017</id>
		<title>CSC/ECE 517 Fall 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=105017"/>
		<updated>2016-11-09T21:41:42Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Final Project Design Document */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.example.com link title]==Calibration Assignment Submissions==&lt;br /&gt;
*[[Calibration Assignment Submission (Firebrick JS)]]&lt;br /&gt;
*[[Calibration Assignment Submission (Active Job)]]&lt;br /&gt;
==Writing Assignments 2==&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1666. Test team functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1631. Refactoring Bidding Interface]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1671. Unit Tests for participants.rb Hierarchy]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1668.Test e-mailing functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1658. Refractor lottery_controller.rb and write integration tests]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1660. Review requirements and thresholds]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1650. Sort instructor views alphabetically by default]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1644. Refactor and test Teams Controller]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1645. Refactoring Tree Display Controller]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1659. Refactor on_the_fly_calc.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1657. Introduce a Student View for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1642. Refactor review_response_map.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1633. Refactor different question types from quiz feature]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1664:_Feature_Test_Assignment_Creation]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1666. Test team functionality]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1654. Improve_date-picker_and_deadlines]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1652 Fix teammate advertisements and requests to join a team ]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1662. UI issues/fixes]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1673. Refactor question_type.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1675. Timestamp for student file &amp;amp; hyperlink submissions]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1640. Refactor response.rb and response_helper.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1634. Refactor and write unit test of due_date.rb and deadline_helper.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/M1654._Improve_network_security_features]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1670._Unit_tests_for_answers.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1641. Refactor review_mapping_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/M1652_Implement_ImageMap_Support_Servo]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/E1648/Add_past_due_assignment]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1656. Improve imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2016/M1653_Implement_HTML_form_validation]]&lt;br /&gt;
==Final Project Design Document==&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1696  Improve Self-Review]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1676  Role-based reviewing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1680. Improve survey functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1693. Drag-and-drop interface for creating rubrics]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1688. Send feedback to support + tree display improvement]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1707: Top trading cycles to exclude previous teammates]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1678: Review configuration options]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1682: Improve score calculation]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1684: Feature Test for Assignment Submission]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza]]&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104830</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104830"/>
		<updated>2016-11-09T03:26:56Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassigned team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
1. For the action run_intelligent_assignmnent, we have two test cases:  &lt;br /&gt;
* webservice call should be successful  &lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future.&lt;br /&gt;
&lt;br /&gt;
* should return json response &lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
*should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
* should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
* should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
* sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
As a result of our work, the code quality of the controller lottery_controller.rb has improved a lot. Code Climate has given it the highest possible rating. The original code had a code climate rating of F. We worked on all the issues pointed out by  code climate and and improved the rating to A. &amp;lt;br&amp;gt;&lt;br /&gt;
Initially, there was only one test case and only one of the methods in the controller was covered. We have also added RSpec test cases for all the methods in the the controller and hence the test coverage has increased. &amp;lt;br&amp;gt;&lt;br /&gt;
This was a very good learning experience. We learnt how to write test cases in RSpec and got a chance to contribute to Open Source Software. Another major take away from the project was the chance that we got to read and understand code written by other people. This is very important skill to have when you work in the industry and can be sometimes more difficult than writing code from scratch.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104699</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104699"/>
		<updated>2016-11-08T01:53:40Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassigned team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
1. For the action run_intelligent_assignmnent, we have two test cases:  &lt;br /&gt;
* webservice call should be successful  &lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future.&lt;br /&gt;
&lt;br /&gt;
* should return json response &lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
*should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
* should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
* should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
* sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104695</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104695"/>
		<updated>2016-11-08T01:46:56Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassigned team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
* For the action run_intelligent_assignmnent, we have two test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. webservice call should be successful  &amp;lt;br&amp;gt;&lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. should return json response  &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1.should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
2. should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
1. sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104694</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104694"/>
		<updated>2016-11-08T01:46:12Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassigned team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_assignmnent, we have two test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. webservice call should be successful  &amp;lt;br&amp;gt;&lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. should return json response  &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1.should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
2. should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
1. sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104690</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104690"/>
		<updated>2016-11-08T01:45:14Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_assignmnent, we have two test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. webservice call should be successful  &amp;lt;br&amp;gt;&lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. should return json response  &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1.should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
2. should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
1. sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104647</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104647"/>
		<updated>2016-11-05T04:25:01Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;br /&gt;
Initially, the lottery controller had only one test case: for the action run_intelligent_bid.&lt;br /&gt;
We added one more test case for run_intelligent_bid and also added test cases for all the other actions in the controller.&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_assignmnent, we have two test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. webservice call should be successful  &amp;lt;br&amp;gt;&lt;br /&gt;
This is to check if the web service is getting called. But the URL given in the code is currently is of a web service that is currently down. Hence for testing purposes we have used a dummy URL.&lt;br /&gt;
This can be replaced with the correct URL to the web service when it becomes available in the future. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. should return json response  &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks if the response from the web service is in JSON format or not. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the action run_intelligent_bid, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1.should do intelligent assignment  &amp;lt;br&amp;gt;&lt;br /&gt;
This was an already existing test case. It tests whether the assignment received is intelligent or not.&amp;lt;br&amp;gt;&lt;br /&gt;
2. should exit gracefully when assignment not intelligent  &amp;lt;br&amp;gt;&lt;br /&gt;
This checks if the control redirects to main page in case the assignment received is not intelligent. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action create_new_teams_for_bidding_response, we have the following test cases:  &amp;lt;br&amp;gt;&lt;br /&gt;
1. should create team and return teamid  &amp;lt;br&amp;gt;&lt;br /&gt;
This test checks if the method is creating the team for bidding by taking in the assignment as parameter. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the action auto_merge_teams, we have written the following test cases: &amp;lt;br&amp;gt;&lt;br /&gt;
1. sorts the unassigned teams &amp;lt;br&amp;gt;&lt;br /&gt;
This test case checks whether the method is able to sort teams which have not been assigned to any assignments yet.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104556</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104556"/>
		<updated>2016-11-04T23:36:43Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Split the function into smaller pieces to keep up with coding conventions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Test Cases===&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104175</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104175"/>
		<updated>2016-11-01T21:04:33Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Splited the function into smaller pieces to keep up with coding conventions.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104174</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=104174"/>
		<updated>2016-11-01T21:03:35Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]  &lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;br /&gt;
&lt;br /&gt;
Before:  &lt;br /&gt;
&lt;br /&gt;
          if bid_record.nil?&lt;br /&gt;
          bids &amp;lt;&amp;lt; 0&lt;br /&gt;
          else&lt;br /&gt;
          bids &amp;lt;&amp;lt; bid_record.priority ||= 0&lt;br /&gt;
          end&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:  &lt;br /&gt;
&lt;br /&gt;
 bids &amp;lt;&amp;lt; bid_record.nil? ? 0 : bid_record.priority ||= 0&lt;br /&gt;
&lt;br /&gt;
Assignment using if condition was changed to conditional operator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
assignment = Assignment.find_by_id(params[:id])&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
assignment = Assignment.find_by(id: params[:id])&lt;br /&gt;
&lt;br /&gt;
Changed to find_by from find_by_id &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, :content_type =&amp;gt; :json, :accept =&amp;gt; :json&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
response = RestClient.post url, data.to_json, content_type: :json, accept: :json&lt;br /&gt;
&lt;br /&gt;
Changed to the latest ruby convention for HashMaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids, index|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s, &lt;br /&gt;
                                       parent_id: assignment.id, &lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id) &lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
def create_new_teams_for_bidding_response(teams, assignment)&lt;br /&gt;
    teams.each_with_index do |user_ids|&lt;br /&gt;
      new_team = AssignmentTeam.create(name: assignment.name + '_Team' + rand(1000).to_s,&lt;br /&gt;
                                       parent_id: assignment.id,&lt;br /&gt;
                                       type: 'AssignmentTeam')&lt;br /&gt;
      parent = TeamNode.create(parent_id: assignment.id, node_object_id: new_team.id)&lt;br /&gt;
      user_ids.each do |user_id|&lt;br /&gt;
        team_user = TeamsUser.where(user_id: user_id, team_id: new_team.id).first rescue nil&lt;br /&gt;
        team_user = TeamsUser.create(user_id: user_id, team_id: new_team.id) if team_user.nil?&lt;br /&gt;
        TeamUserNode.create(parent_id: parent.id, node_object_id: team_user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Removed unused variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by_id(params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by_id(params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
unless Assignment.find_by(id: params[:id]).is_intelligent # if the assignment is intelligent then redirect to the tree display list&lt;br /&gt;
      flash[:error] = &amp;quot;This action not allowed. The assignment &amp;quot; + Assignment.find_by(id: params[:id]).name + &amp;quot; does not enabled intelligent assignments.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changed find_by_id to find_by&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
  unassignedTeams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty?}&lt;br /&gt;
    unassignedTeams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size}&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? and !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        #takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.inject(Hash.new(0)) { |h,v| h[v] += 1; h}&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by { |v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority]}&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
 unassigned_teams = AssignmentTeam.where(parent_id: params[:id]).reject {|t| !SignedUpTeam.where(team_id: t.id).empty? }&lt;br /&gt;
    unassigned_teams.sort! {|t1, t2| TeamsUser.where(team_id: t2.id).size &amp;lt;=&amp;gt; TeamsUser.where(team_id: t1.id).size }&lt;br /&gt;
    team_bids = []&lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      topic_bids = []&lt;br /&gt;
      sign_up_topics.each do |topic|&lt;br /&gt;
        student_bids = []&lt;br /&gt;
        TeamsUser.where(team_id: team.id).each do |s|&lt;br /&gt;
          student_bid = Bid.where(user_id: s.user_id, topic_id: topic.id).first rescue nil&lt;br /&gt;
          if !student_bid.nil? &lt;br /&gt;
            if !student_bid.priority.nil?&lt;br /&gt;
            student_bids &amp;lt;&amp;lt; student_bid.priority&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
        # takes the most frequent priority as the team priority&lt;br /&gt;
        freq = student_bids.each_with_object(Hash.new(0)) do |v, h|&lt;br /&gt;
          h[v] += 1&lt;br /&gt;
        end&lt;br /&gt;
        topic_bids &amp;lt;&amp;lt; {topic_id: topic.id, priority: student_bids.max_by {|v| freq[v] }} unless freq.empty?&lt;br /&gt;
      end&lt;br /&gt;
      topic_bids.sort! {|b| b[:priority] }&lt;br /&gt;
      team_bids &amp;lt;&amp;lt; {team_id: team.id, bids: topic_bids}&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Used snake case naming convention. &lt;br /&gt;
Removed and condition inside if and converted it to nested if condition check.&lt;br /&gt;
Replaced inject with each_with_obj.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&lt;br /&gt;
def auto_merge_teams(unassignedTeams, _finalTeamTopics)&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    unassignedTeams = Team.where(id: unassignedTeams).sort_by {|t| !t.users.size }&lt;br /&gt;
    unassignedTeams.each do |team|&lt;br /&gt;
      sortedBids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sortedBids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winningTeam = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winningTeam).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winningTeam)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After:&lt;br /&gt;
&lt;br /&gt;
before_action :fetch_assignment, only: [:auto_merge_teams]&lt;br /&gt;
  before_action :sort_unassigned_teams, only: [:auto_merge_teams]&lt;br /&gt;
  def auto_merge_teams(unassigned_teams, _final_team_topics)  &lt;br /&gt;
    # Sort unassigned&lt;br /&gt;
    &lt;br /&gt;
    unassigned_teams.each do |team|&lt;br /&gt;
      sorted_bids = Bid.where(user_id: team.id).sort_by(&amp;amp;:priority) # Get priority for each unassignmed team&lt;br /&gt;
      sorted_bids.each do |b|&lt;br /&gt;
        # SignedUpTeam.where(:topic=&amp;gt;b.topic_id).first.team_id&lt;br /&gt;
        winning_team = SignedUpTeam.where(topic: b.topic_id).first.team_id&lt;br /&gt;
        next unless TeamsUser.where(team_id: winning_team).size + team.users.size &amp;lt;= assignment.max_team_size # If the team can be merged to a bigger team&lt;br /&gt;
        TeamsUser.where(team_id: team.id).update_all(team_id: winning_team)&lt;br /&gt;
        Bid.delete_all(user_id: team.id)&lt;br /&gt;
        Team.delete(team.id)&lt;br /&gt;
        break&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  def fetch_assignment&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
  end  &lt;br /&gt;
  &lt;br /&gt;
  def sort_unassigned_teams&lt;br /&gt;
    unassigned_teams = Team.where(id: unassigned_teams).sort_by {|t| !t.users.size }&lt;br /&gt;
  end  &lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_old.png&amp;diff=103914</id>
		<title>File:Cc old.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_old.png&amp;diff=103914"/>
		<updated>2016-10-29T05:24:03Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: uploaded a new version of &amp;amp;quot;File:Cc old.png&amp;amp;quot;: code climate before&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;code climate before&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_old.png&amp;diff=103912</id>
		<title>File:Cc old.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_old.png&amp;diff=103912"/>
		<updated>2016-10-29T05:21:41Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: code climate before&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;code climate before&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103178</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103178"/>
		<updated>2016-10-28T22:21:51Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103169</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103169"/>
		<updated>2016-10-28T22:15:51Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame|left]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103162</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103162"/>
		<updated>2016-10-28T22:11:42Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png|frame]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png|frame]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103151</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103151"/>
		<updated>2016-10-28T22:08:53Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103140</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103140"/>
		<updated>2016-10-28T22:01:49Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
[[File:Ccbefore.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Ccbefore.png&amp;diff=103136</id>
		<title>File:Ccbefore.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Ccbefore.png&amp;diff=103136"/>
		<updated>2016-10-28T22:00:48Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103129</id>
		<title>CSC/ECE 517 Fall 2016/E1658. Refractor lottery controller.rb and write integration tests</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1658._Refractor_lottery_controller.rb_and_write_integration_tests&amp;diff=103129"/>
		<updated>2016-10-28T21:56:32Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: /* Changes performed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Expertiza Background===&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
===Description of Current Project===&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the lottery_controller.rb file. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
The lottery_controller contains all of the logic for running the lottery. Code climate is used in this project to detect various issues such as high cyclomatic complexity, bad naming, etc.&lt;br /&gt;
&lt;br /&gt;
===Changes needed===&lt;br /&gt;
Fix following issues mentioned below:&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is too high.&lt;br /&gt;
* Use snake_case for variable names.&lt;br /&gt;
* Avoid more than 3 levels of block nesting.&lt;br /&gt;
&lt;br /&gt;
===Changes performed===&lt;br /&gt;
The code was refactored and its Code Climate rating improved from F to A.&lt;br /&gt;
Before Refractoring:&lt;br /&gt;
&lt;br /&gt;
After Refractoring:&lt;br /&gt;
[[File:Ccscafter.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Cyclomatic complexity for run_intelligent_bid and other methods is greatly reduced.&lt;br /&gt;
* Perceived complexity for run_intelligent_bid is also reduced.&lt;br /&gt;
* snake_case are used for variable names.&lt;br /&gt;
* More than 3 levels of block nesting is avoided.&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Ccscafter.png&amp;diff=103127</id>
		<title>File:Ccscafter.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Ccscafter.png&amp;diff=103127"/>
		<updated>2016-10-28T21:55:59Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_after.png&amp;diff=103101</id>
		<title>File:Cc after.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_after.png&amp;diff=103101"/>
		<updated>2016-10-28T21:47:07Z</updated>

		<summary type="html">&lt;p&gt;Aanilku: uploaded a new version of &amp;amp;quot;File:Cc after.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aanilku</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_after.png&amp;diff=103099</id>
		<title>File:Cc after.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cc_after.png&amp;diff=103099"/>
		<updated>2016-10-28T21:46:25Z</updated>

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