<?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=Asagarwa</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=Asagarwa"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Asagarwa"/>
	<updated>2026-08-11T18:55:38Z</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/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106495</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106495"/>
		<updated>2016-12-04T20:59:53Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Testing Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* When an instructor will create a new assignment, he should be able to select a checkbox if he wants to enable anonymous commenting for google docs.&lt;br /&gt;
* If the instructor selects this then the authors will not be able to identify the individuals commenting on the doc.&lt;br /&gt;
* The below image shows how we aim to create a checkbox about the same for the instructor. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:newassign.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the database table 'assignments' and we will make  a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the database changes we will generate a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec will have a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view will have a 'check box' and a label added to it. &lt;br /&gt;
* A function will be added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Alert should be shown to the authors only while submitting a google doc link &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. Alert should be shown to the reviewers only if the submissions contain a google doc link and anonymous commenting is enabled&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106494</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106494"/>
		<updated>2016-12-04T20:52:05Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* When an instructor will create a new assignment, he should be able to select a checkbox if he wants to enable anonymous commenting for google docs.&lt;br /&gt;
* If the instructor selects this then the authors will not be able to identify the individuals commenting on the doc.&lt;br /&gt;
* The below image shows how we aim to create a checkbox about the same for the instructor. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:newassign.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the database table 'assignments' and we will make  a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the database changes we will generate a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec will have a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view will have a 'check box' and a label added to it. &lt;br /&gt;
* A function will be added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Newassign.png&amp;diff=106493</id>
		<title>File:Newassign.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Newassign.png&amp;diff=106493"/>
		<updated>2016-12-04T20:51:14Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106492</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106492"/>
		<updated>2016-12-04T20:03:59Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* When an instructor will create a new assignment, he should be able to select a checkbox if he wants to enable anonymous commenting for google docs.&lt;br /&gt;
* If the instructor selects this then the authors will not be able to identify the individuals commenting on the doc.&lt;br /&gt;
* The below image shows how we aim to create a checkbox about the same for the instructor. &lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the database table 'assignments' and we will make  a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the database changes we will generate a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec will have a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view will have a 'check box' and a label added to it. &lt;br /&gt;
* A function will be added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106491</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106491"/>
		<updated>2016-12-04T19:57:37Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Project File and Database additions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the database table 'assignments' and we will make  a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the database changes we will generate a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec will have a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view will have a 'check box' and a label added to it. &lt;br /&gt;
* A function will be added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106490</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106490"/>
		<updated>2016-12-04T19:53:07Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106489</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106489"/>
		<updated>2016-12-04T19:52:52Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106488</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106488"/>
		<updated>2016-12-04T19:52:30Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* We will try to create an alert message whenever the author submits a google doc link. &lt;br /&gt;
* The alert message will ask the author to change the sharing settings of the doc to 'Anyone with the link can comment'.&lt;br /&gt;
* This message should be thrown only when the author submits a google doc link and not any other link. &lt;br /&gt;
* The below image shows the desirable alert message when author tries to submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
* If the instructor has enabled anonymous commenting on google docs then the reviewer should see an alert message which will ask the reviewer to log out from all google accounts before opening the google doc link.&lt;br /&gt;
* The reviewer will need to logout because google allows anonymous commenting on a doc only if the user is currently not logged into any google account.&lt;br /&gt;
* The below image shows the desirable alert message when a reviewer tries to review a project which has google docs in its submission and anonymous commenting is enabled..&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106487</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106487"/>
		<updated>2016-12-04T19:38:37Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response View, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
* In the below image, we can see the frame where the saved Google doc is embedded. Instead of embedding the doc, we can also have a pop-up window of the doc.&lt;br /&gt;
* All the text in ''black'' in the below image, is the content added by the authors. Hence this cannot be edited by the reviewers.&lt;br /&gt;
* The text in colored font are the comments made by reviewers. The below comments have been written for illustrations sake.&lt;br /&gt;
* The comments in reality would be different and will be shown on the right side of the document page. (We can correlate this with comments made in MS Word document)&lt;br /&gt;
* The users need not login to Google in order to comment in the document. Hence, the comments made will be anonymous.&lt;br /&gt;
* If the users are already logged in to Google, constraints will be set such that their ''ID'' is hidden and their comments are still made anonymous.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:anonymous.png|center|]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Anonymous.png&amp;diff=106486</id>
		<title>File:Anonymous.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Anonymous.png&amp;diff=106486"/>
		<updated>2016-12-04T19:37:32Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106485</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106485"/>
		<updated>2016-12-04T19:29:29Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response View, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png|center|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
* In the below image, we can see the frame where the saved Google doc is embedded. Instead of embedding the doc, we can also have a pop-up window of the doc.&lt;br /&gt;
* All the text in ''black'' in the below image, is the content added by the authors. Hence this cannot be edited by the reviewers.&lt;br /&gt;
* The text in colored font are the comments made by reviewers. The below comments have been written for illustrations sake.&lt;br /&gt;
* The comments in reality would be different and will be shown on the right side of the document page. (We can correlate this with comments made in MS Word document)&lt;br /&gt;
* The users need not login to Google in order to comment in the document. Hence, the comments made will be anonymous.&lt;br /&gt;
* If the users are already logged in to Google, constraints will be set such that their ''ID'' is hidden and their comments are still made anonymous.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106484</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106484"/>
		<updated>2016-12-04T19:26:18Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Embedding the document editor in expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response View, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:google doc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
* In the below image, we can see the frame where the saved Google doc is embedded. Instead of embedding the doc, we can also have a pop-up window of the doc.&lt;br /&gt;
* All the text in ''black'' in the below image, is the content added by the authors. Hence this cannot be edited by the reviewers.&lt;br /&gt;
* The text in colored font are the comments made by reviewers. The below comments have been written for illustrations sake.&lt;br /&gt;
* The comments in reality would be different and will be shown on the right side of the document page. (We can correlate this with comments made in MS Word document)&lt;br /&gt;
* The users need not login to Google in order to comment in the document. Hence, the comments made will be anonymous.&lt;br /&gt;
* If the users are already logged in to Google, constraints will be set such that their ''ID'' is hidden and their comments are still made anonymous.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Google_doc.png&amp;diff=106483</id>
		<title>File:Google doc.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Google_doc.png&amp;diff=106483"/>
		<updated>2016-12-04T19:24:54Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106482</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=106482"/>
		<updated>2016-12-04T19:09:05Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Security Risks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by displaying alert messages to the authors and the reviewers who will use the newly created Google document links embedded into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza or any google account for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
* The alert message should only pop up when the faculty as indicated to do so &lt;br /&gt;
* The Google doc link needs to be added on the submissions page by the author of the project&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot; by the author&lt;br /&gt;
* A peer reviewer needs be directed not login to any Google account to comment on the doc, and all peer reviewer comments shall be anonymous&lt;br /&gt;
* Multiple commenting at a specific instance is taken care of by the google document settings and it will be placed one below the other.&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
&lt;br /&gt;
The first phase of our project aimed at embedding a google a document which enables the project author to automatically generate a google document with specified permissions for the reviews such that when a reviewer makes a comment it appears without his identity. &lt;br /&gt;
We succeeded in authorizing the user to the google documents by using the google-client-API (aouth + signet) credentials and the API console also showed positive results for the &amp;quot;request&amp;quot; sent over to the client and created a google document but to access that particular binary file we had to set the permission rights of the service account for which the google document is created which is different from the credentials account.  We also tried hard coding and giving all access rights to anyone who wanted to open the file but it seems practically impossible to get those rights. &lt;br /&gt;
&lt;br /&gt;
The second half of the project aimed at creating a flash box which directs the author to set the comment rights on the review google document as decided by the professor subject to the condition and complexity of the project. This will happen on the go and the author is notified to &amp;quot;enable commenting rights only&amp;quot; only if the faculty checks the option for that particular project. &lt;br /&gt;
On the other side whenever the reviewers click on the google document link attached to the project for reviewing or commenting on a project they will get a notification alert to log out of all google accounts in order to assure the anonymity of the reviewer. This is done because google documents does not support complete anonymity.    &lt;br /&gt;
In this the assumption is that the google doc is created in the same manner as the other hyperlinks are added. Additionally whenever the  the which will be already created by the author        &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a provision (button) for creating a Google document is added to the ''Your Work'' page of ''Assignments''.&lt;br /&gt;
* When the authors would select this button before submitting their assignment, a new Google doc is created.&lt;br /&gt;
* The document's Sharing criteria is set using google docs API such that the authors of the team can edit the document.&lt;br /&gt;
* Sharing criteria is also set such that anyone else having the link to this document can only comment.&lt;br /&gt;
* The authors would then copy paste their content, to be reviewed, on to the document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png|thumb=Doceditor.png|center|alt=none|The expected display on the google documents]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Now the file sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|thumb=Googledoc.png|center|alt=none|The list of hyperlinks a project author would ideally have]]&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situation where the peer reviewer forgets to logout would result in his/ her name being added to the history of document edits which will reveal the identity. &lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*When a reviewer goes on the page of submitted contents, he'll be shown an alert message to logout from google accounts if there exists a google docs link in the submitted content and instructor has enabled anonymous commenting.&lt;br /&gt;
*The authors of the project will be shown an alert to modify the settings of their google doc to 'Anyone with the link can comment' when they submit a google doc link.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png|thumb=can_comment.png|center|alt = ScreenShot of google document settings|ScreenShot of google document settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
* Also the anonymity is handled if the user directly comments on the document without loging in into other google accounts.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response View, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Iframecode.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
* In the below image, we can see the frame where the saved Google doc is embedded. Instead of embedding the doc, we can also have a pop-up window of the doc.&lt;br /&gt;
* All the text in ''black'' in the below image, is the content added by the authors. Hence this cannot be edited by the reviewers.&lt;br /&gt;
* The text in colored font are the comments made by reviewers. The below comments have been written for illustrations sake.&lt;br /&gt;
* The comments in reality would be different and will be shown on the right side of the document page. (We can correlate this with comments made in MS Word document)&lt;br /&gt;
* The users need not login to Google in order to comment in the document. Hence, the comments made will be anonymous.&lt;br /&gt;
* If the users are already logged in to Google, constraints will be set such that their ''ID'' is hidden and their comments are still made anonymous.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
== '''Project File and Database additions''' ==&lt;br /&gt;
&lt;br /&gt;
* The new outcome will involve accessing the data base table 'assignments' and we have made a change to the schema of the table by adding a column 'allow_anonymous_commenting' of the type 'Boolean' to indicate whether the professor has asked the project developers to have a review document created with the rights of anonymous comments.  &lt;br /&gt;
* To incorporate the data base changes we generated a migration file in the &amp;quot;db&amp;quot; migrate named: '_add_allow_anonymous_commenting_to_assignemnnts.rb'&lt;br /&gt;
* The 'factories' file in the spec has a variable added with the default value set as 'FALSE'&lt;br /&gt;
* '_genral.html.erb' page in the edit assignments view has a 'check box' and a label added to it. &lt;br /&gt;
* A function is added in the 'assignments_form' model which sets the visibility to false/ true depending on the input &lt;br /&gt;
* The submitted_content view file '_main.html.erb' has the button to upload the google doc link.&lt;br /&gt;
* The 'submitted_content_controller.erb' has the code which directs the author to enable the anonymous commenting.      &lt;br /&gt;
* Newly added Google doc hyperlinks will be saved with other assignment hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
* The iFrame tag will be added to the 'view.html.erb' file in 'response' View in order to embed the Google doc.&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should only be able to comment on the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105823</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105823"/>
		<updated>2016-11-15T02:21:37Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Security Risks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by embedding Google docs into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
The Google doc editor needs to be embedded in expertiza or it should be made as a pop up window&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can comment&amp;quot;&lt;br /&gt;
* A peer reviewer need not login to Google to comment on the doc, and all peer reviewer comments must be anonymous&lt;br /&gt;
* If more than one user comment on the Google doc at the same time, any conflicts that may arise should be handled well&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you make changes to the Google document (like comments), it will be automatically updated in the application's content editor.&lt;br /&gt;
 &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a Google document must be created, the content in which has to be submitted for collaborative peer reviewing, as shown in the below figure.&lt;br /&gt;
* The document Sharing criteria should be set such that - Anyone with the link can comment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* This sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
* The new Google doc link will be saved with other hyperlinks in the 'submitted_hyperlinks' column of 'teams' table.&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situtation where more than one people comment on the doc and mess up the content.&lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*To address these two issues we'll be modifying the access rights of the google doc associated with that project.&lt;br /&gt;
*We'll by default assign all new users who access the page only the 'can comment' access right and only the author team will have 'can edit' rights.&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png]]&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response controller, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Iframecode.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should be able to edit the original Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105819</id>
		<title>File:Googledoc.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105819"/>
		<updated>2016-11-15T01:59:57Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: uploaded a new version of &amp;amp;quot;File:Googledoc.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Can_comment.png&amp;diff=105791</id>
		<title>File:Can comment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Can_comment.png&amp;diff=105791"/>
		<updated>2016-11-15T01:17:12Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: uploaded a new version of &amp;amp;quot;File:Can comment.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105788</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105788"/>
		<updated>2016-11-15T01:15:17Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Security Risks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by embedding Google docs into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
The Google doc editor needs to be embedded in expertiza or it should be made as a pop up window&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can edit&amp;quot;&lt;br /&gt;
* A peer reviewer need not login to Google to comment on the doc, and all peer reviewer comments must be anonymous&lt;br /&gt;
* If more than one user comment on the Google doc at the same time, any conflicts that may arise should be handled well&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you edit the Google document, it will be automatically updated in the application's content editor.&lt;br /&gt;
 &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a Google document must be created, the content in which has to be submitted for collaborative peer reviewing, as shown in the below figure.&lt;br /&gt;
* The document Sharing criteria should be set such that - Anyone with the link can edit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* This sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situtation where more than one people comment on the doc and mess up the content.&lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*To address these two issues we'll be modifying the access rights of the google doc associated with that project.&lt;br /&gt;
*We'll by default assign all new users who access the page only the 'can comment' access right.&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png]]&lt;br /&gt;
&lt;br /&gt;
*As it can be seen, Google doc has 3 access levels and the 'can comment' option will allow the users only to add more comments on the Google doc. They won't be able to edit or delete previously entered comments.&lt;br /&gt;
*Doing this will ensure that no user even unintentionally will be able to delete or edit previous comments which might be of great value to the authors of that project.&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response controller, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Iframecode.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should be able to edit the original Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105775</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105775"/>
		<updated>2016-11-15T01:08:19Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by embedding Google docs into Expertiza. Every project will have a Google doc link for itself which the reviewers can access and make further comments about the project. Once on the Google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the Google doc link to post comments and it wouldn't be required to login into Expertiza for using this feature.&lt;br /&gt;
&lt;br /&gt;
== '''Key Points To Consider''' ==&lt;br /&gt;
&lt;br /&gt;
The Google doc editor needs to be embedded in expertiza or it should be made as a pop up window&lt;br /&gt;
* The settings for the Google doc should be set to &amp;quot;anyone with link can edit&amp;quot;&lt;br /&gt;
* A peer reviewer need not login to Google to comment on the doc, and all peer reviewer comments must be anonymous&lt;br /&gt;
* If more than one user comment on the Google doc at the same time, any conflicts that may arise should be handled well&lt;br /&gt;
&lt;br /&gt;
== '''Approach''' ==&lt;br /&gt;
&lt;br /&gt;
Generally, we can always create a Google document, slide presentation, or spreadsheet using Google Drive and then embed that document anywhere in our application using iFrame as a dynamic rich content editor. The rich content editor is used in features that support the editor (Announcements, Quizzes or Collaborative Reviewing in our case). Any time you edit the Google document, it will be automatically updated in the application's content editor.&lt;br /&gt;
 &lt;br /&gt;
===Creating Google document, Setting Up its Link===&lt;br /&gt;
&lt;br /&gt;
* First and foremost a Google document must be created, the content in which has to be submitted for collaborative peer reviewing, as shown in the below figure.&lt;br /&gt;
* The document Sharing criteria should be set such that - Anyone with the link can edit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Doceditor.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* This sharable link must be pasted while submitting an Assignment in expertiza as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Publishing the document to Web===&lt;br /&gt;
&lt;br /&gt;
* Open the File menu in Google doc and select Publish to the web....&lt;br /&gt;
* Make sure that the Automatically republish when changes are made checkbox is selected. Click the Start publishing button.&lt;br /&gt;
* When a confirmation prompt pops up, click the OK button.&lt;br /&gt;
* Click on the Embed tab to get the below screen, now copy the text in order to use it in our expertiza code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Publish.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Security Risks===&lt;br /&gt;
&lt;br /&gt;
As mentioned in the requirement document, there are 2 security risks associated with this project, they are:&lt;br /&gt;
*A situtation where more than one people comment on the doc and mess up the content.&lt;br /&gt;
*Possible security violations like an user with access to the link deletes all the content on that doc.&lt;br /&gt;
&lt;br /&gt;
Proposed solution to mitigate the risk:&lt;br /&gt;
*To address these two issues we'll be modifying the access rights of the google doc associated with that project.&lt;br /&gt;
*We'll assign all new users who access the page only the 'can comment' access right.&lt;br /&gt;
&lt;br /&gt;
[[File:can_comment.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Embedding the document editor in expertiza===&lt;br /&gt;
&lt;br /&gt;
* Our aim is to incorporate the dynamic content editor in the Review Assignments page, so that all the users can make collaborative suggestions in the document at the time of Review.&lt;br /&gt;
* In order to embed this editor, the code needs to be added in the View page for student responses. &lt;br /&gt;
* For example, to embed the editor for Assignment Responses the above code must be incorporated in the view.html.erb file in the response controller, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Iframecode.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* On building the code and running expertiza, we must be able to see the Google doc editor successfully embedded in the Assignment Reviews page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Embeddoc.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Testing Plan''' ==&lt;br /&gt;
&lt;br /&gt;
This UI enhancement will be tested to check whether the following required functionalities are implemented successfully:&lt;br /&gt;
&lt;br /&gt;
i. Any user having the doc link should be able to edit the original Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
ii. Changes made in the original Google doc should be reflected in the embedded doc editor in expertiza &amp;lt;br&amp;gt;&lt;br /&gt;
iii. Users need not login to comment in the Google doc&amp;lt;br&amp;gt;&lt;br /&gt;
iv. All comments made must be anonymous&amp;lt;br&amp;gt;&lt;br /&gt;
v. Multiple comments made at the same time should not lead to any conflicts &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
*[https://community.canvaslms.com/docs/DOC-1885  Guide to Embedding Google doc editor]&lt;br /&gt;
*[https://expertiza.ncsu.edu/ Expertiza application]&lt;br /&gt;
*[https://en.wikipedia.org/wiki/Ruby_on_Rails  Ruby on Rails]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Can_comment.png&amp;diff=105768</id>
		<title>File:Can comment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Can_comment.png&amp;diff=105768"/>
		<updated>2016-11-15T01:00:34Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105262</id>
		<title>File:Googledoc.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105262"/>
		<updated>2016-11-10T03:18:34Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: uploaded a new version of &amp;amp;quot;File:Googledoc.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105248</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105248"/>
		<updated>2016-11-10T03:10:43Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by embedding google docs into Expertiza. Every project will have a google doc link for itself which the reviewers can access and make further comments about the project. Once on the google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the google doc link to post comments and it wouldn't be required to login into Expertiza for using this feature.&lt;br /&gt;
&lt;br /&gt;
=='''Additions in UI'''==&lt;br /&gt;
&lt;br /&gt;
[[File:Googledoc.png|frame|upright|center]]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105246</id>
		<title>File:Googledoc.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Googledoc.png&amp;diff=105246"/>
		<updated>2016-11-10T03:08:22Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105221</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105221"/>
		<updated>2016-11-10T02:44:52Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
=='''Project Description'''==&lt;br /&gt;
&lt;br /&gt;
Currently the instructor creates rubrics for an assignment through questionnaires which students use to review other students' submissions. The only way reviewers can suggest some more changes to the author is by using the 'additional comments' section in the review form which is not very helpful. In this project we will be looking towards improving this functionality by adding an extra medium through which multiple reviewers can collectively comment on the author's work and collaborate their answers in a constructive way. This will be achieved by embedding google docs into Expertiza. Every project will have a google doc link for itself which the reviewers can access and make further comments about the project. Once on the google doc, the reviewer's comments will be posted anonymously, the reviewer's comment will be anonymous to both, other fellow reviewers as well as the author. This feature will help the author to better understand where is his work exactly lacking and how exactly should the changes be worked upon based on the comments received. The reviewers will just need the google doc link to post comments and it wouldn't be required to login into Expertiza for using this feature.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105169</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105169"/>
		<updated>2016-11-10T01:59:32Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Expertiza Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Expertiza Background'''==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105168</id>
		<title>CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/_E1700_Integrate_Google_doc_editor/viewer&amp;diff=105168"/>
		<updated>2016-11-10T01:58:40Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: Created page with &amp;quot;==Expertiza Background==  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 p...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=105164</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=105164"/>
		<updated>2016-11-10T01:56:04Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* 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 E1689: Anonymous Chat Between Author and Reviewer]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1703: Logging for Expertiza]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1708: Improvements to staggered-deadline assignments]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016 E1685: UI changes for review and score reports]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/ M1653 Implement HTML form validation]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/ E1700 Integrate Google doc editor/viewer]]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104570</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104570"/>
		<updated>2016-11-05T00:45:44Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Unit Testing===&lt;br /&gt;
&lt;br /&gt;
We created unit tests as well to check that the module performs as it did earlier before we refactored it. There were no pre-existing test cases for this module.&amp;lt;br/&amp;gt;&lt;br /&gt;
We first had to create a dummy class to test the module. The new test file can be viewed at the mentioned GitHub link.&lt;br /&gt;
&lt;br /&gt;
[[File:testtt.png]]&lt;br /&gt;
  All the test cases pass.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104569</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104569"/>
		<updated>2016-11-05T00:44:33Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Unit Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Unit Testing===&lt;br /&gt;
&lt;br /&gt;
We created unit tests as well to check that the module performs as it did earlier before we refactored it. There were no pre-existing test cases for this module.&amp;lt;br/&amp;gt;&lt;br /&gt;
We first had to create a dummy class to test the module. The new test file can be viewed at the mentioned GitHub link.&lt;br /&gt;
&lt;br /&gt;
[[File:testtt.png]]&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104563</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104563"/>
		<updated>2016-11-04T23:49:27Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Unit Testing===&lt;br /&gt;
&lt;br /&gt;
[[File:testtt.png]]&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Testtt.png&amp;diff=104562</id>
		<title>File:Testtt.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Testtt.png&amp;diff=104562"/>
		<updated>2016-11-04T23:48:26Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104561</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104561"/>
		<updated>2016-11-04T23:43:42Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Testing Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Unit Testing===&lt;br /&gt;
&lt;br /&gt;
[[File:Screen Shot 2016-11-04 at 7.31.32 PM.png]]&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104560</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104560"/>
		<updated>2016-11-04T23:42:25Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* UI Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104559</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104559"/>
		<updated>2016-11-04T23:42:05Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* UI Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
=======UI Testing=======&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104558</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104558"/>
		<updated>2016-11-04T23:41:46Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Testing Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
=====UI Testing=====&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104557</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104557"/>
		<updated>2016-11-04T23:41:15Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* UI Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.(You can use the student ids in the peer review section above)&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2016-11-04_at_7.31.32_PM.png&amp;diff=104555</id>
		<title>File:Screen Shot 2016-11-04 at 7.31.32 PM.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screen_Shot_2016-11-04_at_7.31.32_PM.png&amp;diff=104555"/>
		<updated>2016-11-04T23:33:33Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104550</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104550"/>
		<updated>2016-11-04T23:20:08Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Testing Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
===UI Testing===&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104548</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104548"/>
		<updated>2016-11-04T23:19:26Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor.&amp;lt;br/&amp;gt; &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores.&amp;lt;br/&amp;gt;  &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module.&amp;lt;br/&amp;gt;  &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page.&amp;lt;br/&amp;gt;  &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&amp;lt;br/&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104546</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104546"/>
		<updated>2016-11-04T23:18:20Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* UI Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
&lt;br /&gt;
1. Login into Expertiza as a student or an instructor. &lt;br /&gt;
2. Go to an assignment which has some prior reviews for a previous project and click on view scores. &lt;br /&gt;
3. The total score for a review is calculated on the fly using this module. &lt;br /&gt;
4. You will be able to see the average score that each reviewer gave you on the top right of your page. &lt;br /&gt;
5. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104543</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=104543"/>
		<updated>2016-11-04T23:16:41Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
=== On_the_fly_calc ===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee. It directly calculates the total review score for each review, using the score values in the answer table during run-time.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
The main aim was to reduce the complexity grade of ‘on_the_fly_calc.rb’ module from “F” to “C” in CodeClimate, which was achieved. We worked on the following work items(WIs) in order to refactor the module:&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor ‘Similar Code’ in lines 34-42 and 62-70 in on_the_fly_calc.rb&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Prefer ‘each’ over every instance of ‘for loop’ &amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor ‘scores’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Refactor ‘compute_reviews_hash’ method to reduce ABC (assignment, branch and condition) size&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Refactor ‘compute_avg_and_ranges_hash’ method to reduce ABC (assignment, branch and condition) size&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
==== Refactored similar code ====&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 and 62-70 were similar in compute_reviews_hash method. Hence, a dedicated method ‘calc_review_score’ was defined and this method was called in the both instances inside compute_reviews_hash.&lt;br /&gt;
&lt;br /&gt;
Lines 34-42 in compute_reviews_hash:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similar code in Lines 62-70:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Similar code 2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored method 'calc_review_score' for the two similar codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same code method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Each loop prefered over For loop ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In every instance where ‘for’ loops were used in on_the_fly_calc module, ‘each…do’ was replaced instead. This significantly reduced the Cyclomatic complexity of the code. &lt;br /&gt;
&lt;br /&gt;
The following screen shows the instances where for loops where replaced:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Eachloop.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Refactored methods - 'scores', 'compute_reviews_hash', 'compute_avg_and_ranges_hash'  ====&lt;br /&gt;
&lt;br /&gt;
1. a) Method ‘scores’ was very complex, performing too many functions within a single method. Hence, every specific function was broken down into 4 separate smaller methods. This significantly reduced the Assignment, Branch, Condition size for ‘scores’ method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def scores(questions)&lt;br /&gt;
    scores = {}&lt;br /&gt;
    score_team = scores[:teams][index.to_s.to_sym]&lt;br /&gt;
    score = score_team[:scores]&lt;br /&gt;
    scores[:participants] = {}&lt;br /&gt;
    participant_score          #New method defined - participant_score&lt;br /&gt;
    scores[:teams] = {}&lt;br /&gt;
    index = 0&lt;br /&gt;
    self.teams.each do |team|&lt;br /&gt;
      score_team = {}&lt;br /&gt;
      score_team[:team] = team&lt;br /&gt;
      if self.varying_rubrics_by_round?&lt;br /&gt;
        assess                #New method defined - assess&lt;br /&gt;
        calculate_score       #New method defined - calculate_score&lt;br /&gt;
        calculate_assessment  #New method defined - calculate_assessment&lt;br /&gt;
      else&lt;br /&gt;
        assessments = ReviewResponseMap.get_assessments_for(team)&lt;br /&gt;
        score = Answer.compute_scores(assessments, questions[:review])&lt;br /&gt;
      end&lt;br /&gt;
      index += 1&lt;br /&gt;
    end&lt;br /&gt;
    scores&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b) The following 4 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
i.  participant_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def participant_score&lt;br /&gt;
  self.participants.each do |participant|&lt;br /&gt;
    scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ii. assess&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def assess&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    total_score = 0&lt;br /&gt;
    total_num_of_assessments = 0 # calculate grades for each rounds&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    assessments = ReviewResponseMap.get_assessments_round_for(team, i)&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    round = Answer.compute_scores(assessments, questions[round_sym])&lt;br /&gt;
    total_num_of_assessments += assessments.size&lt;br /&gt;
    total_score += round[:avg] * assessments.size.to_f unless round[:avg].nil?&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iii. calculate_score&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_score&lt;br /&gt;
  score = {}&lt;br /&gt;
  score[:max] = -999_999_999&lt;br /&gt;
  score[:min] = 999_999_999&lt;br /&gt;
  score[:avg] = 0&lt;br /&gt;
  grades_by_rounds = {}&lt;br /&gt;
  round = grades_by_rounds[round_sym]&lt;br /&gt;
  self.num_review_rounds.each do |i|&lt;br /&gt;
    round_sym = (&amp;quot;review&amp;quot; + i.to_s).to_sym&lt;br /&gt;
    grades_by_rounds = {}&lt;br /&gt;
    round = grades_by_rounds[round_sym]&lt;br /&gt;
    score[:max] = round[:max] if max_condition&lt;br /&gt;
    score[:min] = round[:min] if min_condition&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iv. calculate_assessment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def calculate_assessment&lt;br /&gt;
  if total_num_of_assessments.nonzero?&lt;br /&gt;
    score[:avg] = total_score / total_num_of_assessments&lt;br /&gt;
  else&lt;br /&gt;
    score[:avg] = nil&lt;br /&gt;
    score[:max] = 0&lt;br /&gt;
    score[:min] = 0&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
c) Complex and long statements or loops were broken into simpler multiple statements.&lt;br /&gt;
&lt;br /&gt;
For example, the unless condition in Lines 132-134 was refactored to Line 127. This reduced the Perceived Complexity of 'scores' method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Conditionsimpler.png]]&lt;br /&gt;
&lt;br /&gt;
2. a) We also refactored method ‘compute_reviews_hash’ which was very complex and modularized individual functionalities into 2 separate methods.&lt;br /&gt;
b) The following 2 methods were created and called after refactoring:&amp;lt;br&amp;gt;&lt;br /&gt;
i.  scores_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
ii. scores_non_varying_rubrics&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Similarly, method ‘compute_avg_and_ranges_hash’ was also refactored and a seperate method calc_contri_score was defined to calculate contributor’s score. This method was then called from ‘compute_avg_and_ranges_hash’.&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_unnamed.png]]&lt;br /&gt;
  The Code Climate Grade Before Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:rsz_1after.png]] &lt;br /&gt;
  The Code Climate Grade After Refactoring&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
====UI Testing====&lt;br /&gt;
&lt;br /&gt;
Login into Expertiza as a student or an instructor. Go to an assignment which has some reviews for a previous project and click on view scores. The total score for a review is calculated on the fly using this module. You will be able to see the average score that each reviewer gave you on the top right of your page. This ensured that the refactoring done by us didn't break the code and it delivered it's expected functionality.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
Every code has future improvements possible. We have evolved the Code Climate Grade 'F' to a Grade 'C' currently by removing the Cyclomatic complexity, the Perceived Complexity and replaced with the &amp;quot;for&amp;quot; with the 'each' to reduce the size .&lt;br /&gt;
There are modifications that can still reduce the &amp;quot;ABC&amp;quot; Assignment Branches and Conditions Score as we can include the variables and functions in the &amp;quot;before action clauses&amp;quot;, and rename long names with shorter yet appropriate names thus moving towards the score of &amp;quot;A&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=102705</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=102705"/>
		<updated>2016-10-28T06:08:07Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
===On_the_fly_calc===&lt;br /&gt;
&lt;br /&gt;
On_the_fly_calc is a module that is included in assignment.rb. What this module does is that it calculates the score for both students and instructors. E.g., when a student clicks “view my score”, Expertiza calculates the review scores for each review. This is called “on the fly” because expertiza stores the review scores based on each question (in answers table), but does not store the total score that a reviewer gives to a reviewee.&lt;br /&gt;
Eg: For a set of 4 questions a reviewer gives 5 on 5 points for 2 questions and 4 on 5 points for other 2 questions. So only these points are stored in the database and when a reviewee clicks to see the score given by this particular reviewer, on_the_fly_calc module helps calculate the total score i.e. 90% in this case.&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=102704</id>
		<title>CSC/ECE 517 Fall 2016/E1659. Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659._Refactor_on_the_fly_calc.rb&amp;diff=102704"/>
		<updated>2016-10-28T05:56:31Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: Created page with &amp;quot;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.  == Peer Review Information ==  For users intending to view the deplo...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1659 OSS assignment for Fall 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5431,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student5427,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&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. Using Expertiza students can bid for a particular project topic and the faculty assigns the same to different groups. Students can track their grades for previous projects and make new submissions for current projects. It also allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
We worked on a module named on_the_fly_calc in this Expertiza based OSS project. We focussed on refactoring some methods which were very complex and also modified the language of the module to make it more ruby-istic. We also worked on refactoring the code to reduce redundancy. Our goal in this project was to make this model easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A model was modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. On_the_fly_calc&lt;br /&gt;
&lt;br /&gt;
===On_the_fly_calc===&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=102675</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=102675"/>
		<updated>2016-10-28T04:48:37Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: /* Writing Assignments 2 */&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/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/E1659. Refactor on_the_fly_calc.rb]]&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659.Refactor_on_the_fly_calc.rb&amp;diff=102674</id>
		<title>CSC/ECE 517 Fall 2016/E1659.Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659.Refactor_on_the_fly_calc.rb&amp;diff=102674"/>
		<updated>2016-10-28T04:44:17Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;a&lt;br /&gt;
n&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659.Refactor_on_the_fly_calc.rb&amp;diff=102673</id>
		<title>CSC/ECE 517 Fall 2016/E1659.Refactor on the fly calc.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1659.Refactor_on_the_fly_calc.rb&amp;diff=102673"/>
		<updated>2016-10-28T04:43:18Z</updated>

		<summary type="html">&lt;p&gt;Asagarwa: Created page with &amp;quot;a&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;a&lt;/div&gt;</summary>
		<author><name>Asagarwa</name></author>
	</entry>
</feed>