<?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=Ahasket</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=Ahasket"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ahasket"/>
	<updated>2026-09-30T08:11:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E1735._UI_changes_for_review_and_score_reports&amp;diff=108559</id>
		<title>E1735. UI changes for review and score reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E1735._UI_changes_for_review_and_score_reports&amp;diff=108559"/>
		<updated>2017-04-13T04:13:36Z</updated>

		<summary type="html">&lt;p&gt;Ahasket: /* Low Level Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
This wiki provides details on the tasks that were undertaken as part of the continuous improvement to the Expertiza project.&lt;br /&gt;
===Background===&lt;br /&gt;
[[Expertiza_documentation|Expertiza]] is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). The application provides a complete system through which students and instructors collaborate on the learning objects as well as submit, review and grade assignments for the courses. It is used in select courses at NC State and by professors at several other colleges and universities. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview of Review Functionality===&lt;br /&gt;
&lt;br /&gt;
The Expertiza review system encompasses many types of reviews. Assignments can have multiple submission rounds defined with their own due dates and criteria. Each round can have an associated questionnaire whereby peers are encouraged, or required, to review each others' submissions and rate those submissions using the scores 1 through 5 for each question. The scores for each question are averaged to find the rating for the submission for each  questionnaire response. The average of all questionnaire responses determine the score for the submission.After the reviews are submitted, the recipient of those reviews can rate the reviewers using a similar questionnaire. On this questionnaire, the author of the submission will rate the reviews based on the reviewers understanding, helpfulness, and respectfulness. This is a review of the reviews, thus it is termed a &amp;quot;metareview.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Both students and instructors using Expertiza have the ability to view the reviews and the scores associated with the reviews for each assignment. These screens will display review summary and detail information in various formats such as lists, graphs, and heatgrids. The instructor will be able to see all review and score information for all teams on the assignment whereas a student will only be able to see the review and score information pertaining to them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reviews and associated scores are available on the scores report. To access the score reports in Expertiza follow these instructions:&lt;br /&gt;
&lt;br /&gt;
'''As a student'''&lt;br /&gt;
&lt;br /&gt;
# Log into Expertiza.&lt;br /&gt;
# Click on the 'Assignments' link on the top navigation bar.&lt;br /&gt;
# Find the assignment in the list and click the title of the assignment.&lt;br /&gt;
# Click on the 'Your scores' link to see the standard view or click on the 'Alternate View' link to see the heatgrid view.&lt;br /&gt;
&lt;br /&gt;
'''As an instructor'''&lt;br /&gt;
&lt;br /&gt;
# Log into Expertiza.&lt;br /&gt;
# Hover over the 'Manage' item on the top navigation bar, then select click the 'Assignments' link.&lt;br /&gt;
# Find the assignment in the list and click the 'View scores' icon (a star with a magnifying glass) in the 'Actions' column.&lt;br /&gt;
# This will bring up the standard view. To see the heatgrid view, click the 'Alternate View' link on the team headings or click the 'view heatgrid' beneath the 'Final Score' when the team is expanded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
By participating in the overall refactoring effort as part of the continuous improvement of Expertiza, students get an opportunity to work on a open source software project. This helps them gain exposure on the technologies used in the project as well as much needed experience in collaborating with peers as part of the software development process. This effort was undertaken as a final project for the CSC 517 - Object Oriented Design and Development course at North Carolina State University in the spring of 2017.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Purpose==&lt;br /&gt;
&lt;br /&gt;
===Requirements Statement===&lt;br /&gt;
Expertiza displays reviews (i) to the team who was reviewed, and (ii) to the reviewer.  A student user can see all the reviews of his/her team’s project.  The instructor can see all the reviews of everyone’s project.  The instructor also has access to a review report, which shows, for each reviewer, all the reviews that (s)he wrote. Currently, the score report and review report use completely different code.  This makes the UI non-orthogonal and also causes DRY problems.  So, we would like to have a single way of displaying reviews that would be visible to students (reviews that they did, and reviews that their team received), and instructors (reviews that each time received, sorted by team; and reviews that each student did, sorted by student).&lt;br /&gt;
&lt;br /&gt;
===Required Tasks===&lt;br /&gt;
The tasks involved as part of this requirements change are as follows:&lt;br /&gt;
# Compact the review display&lt;br /&gt;
#* Eliminate the blank lines between items within a single review. Instead vary the background color from line to line to improve readability&lt;br /&gt;
#* With a single click, there should be a way to hide all the reviews, reveal just the headings (as at present), or expand all the reviews&lt;br /&gt;
# At the top of each review, it should say&lt;br /&gt;
#* Who submitted the review. The instructor should see the user’s name and user-ID.&lt;br /&gt;
#* A student should see&lt;br /&gt;
#** “Reviewer #k”, where k is an integer between 1 and n, the number of reviews that have been submitted for this project&lt;br /&gt;
#** The version number of the review&lt;br /&gt;
#** The time the review was submitted&lt;br /&gt;
# There should be a tabbed view to switch between various review views&lt;br /&gt;
#* One tab has overall statistics (averages, min, max, as the present “normal” view)&lt;br /&gt;
#* One tab has the heat map (current “alternate” view)&lt;br /&gt;
#* One tab has a grid view, with no scores, but text comments in the grid squares, and then a “More” link to display the whole comment (which will require expanding the row of the grid)&lt;br /&gt;
#* Switching between reviews from Reviewer k and Reviewer j might also be done by clicking on different tabs.  Or, it might be more convenient to keep the current score view, which lists the n reviews across the page.  Then the student should be able to click on the reviewer number (the instructor would instead click on the reviewer name) and see the review done by that reviewer&lt;br /&gt;
# To make it easy to focus on the reviewer’s feedback, there should be a way to hide and/or gray the criteria (“questions”), so the responses stand out more clearly&lt;br /&gt;
# There needs to be a way to search all reviews (of a particular project, or by a particular individual) for a given text string.  The user should be able to go from one instance of the text string to another by clicking down and up buttons&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In the current state, the score report for instructors and students are built differently though they display the same information using similar UI elements. The application has multiple views into the same information but the way in which those views are accessed, the code which populates them, and the layout of the screens differs unnecessarily between instructors and students and across the views themselves. This leads to redundant code in both the backend and frontend of the application. Furthermore, since the UI is not uniform between instructors and students, instructors may have difficulty assisting students in accessing their score information due to the differences which are present in the UI that leads to confusion.&lt;br /&gt;
&lt;br /&gt;
Following are some of the issues with the current state UI which we seek to rectify.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scores Report====&lt;br /&gt;
[[File:Problem_Statement_Diagram_1A_-_Instructor_View_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
The scores report for students and instructors have very similar layouts despite being created by different controller methods and views. They both display graphs, reviews on team submissions, author feedback, and score metrics. The primary different between them is that the instructor view (shown above) displays information for all teams in a collapsible accordion widget format while the student view (shown below) display the information only for a single team. There are some further discontinuities between the two UIs. For example, the student cannot access the heatgrid view from within the scores report page. This view is only accessible from the assignment page for students. For instructors there are two ways to access the heatgrid view from a single page. The 'Alternate View' link is adjacent to the team name on the heading bar and there is also a link inexplicably placed beneath the 'Final Score' field.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_1B_-_Student_View_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Author Feedback====&lt;br /&gt;
Author feedback takes two different forms when being shown to instructors but only one form for students. Both students and instructors have access to the author feedback format shown on the left in the student view. This format is identical to the format of the review scores and is displayed on the scores report for both instructor and student. The format on the right is shown on the heatgrid view yet it is only available to instructors. The information conveyed by these two formats is nearly identical and not uniformly available to all consumers of this information.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_2_-_Author_Feedback_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Graphs and Charts====&lt;br /&gt;
The scores report view has a bar of graphs and charts at the top of the page for both students and instructors. Both views shown below use a donut chart and bar graphs though their method of display is not uniform. The instructor view has titles beneath each item but the student view does not. The 'Submitted work' and 'Author Feedback' titles shown, despite being beneath the bar graphs, are actually headings for the metrics which are displayed beneath the graphs. Also, the graphs contain two labels on the y-axis: the maximum score and the average score. The graphs are so compact that the values on the axis overlap and make them illegible.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_3_-_Squashed_Graphs_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Design==&lt;br /&gt;
&lt;br /&gt;
===High Level Design===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Design Overview====&lt;br /&gt;
The project requirements state that we need to create a standard UI for accessing and consuming review and score information. The emphasis will be on smart and purposeful code reuse as well as ease of navigation to access information. To achieve these results we will redesign the scores report to work for both instructors and students alike. There will be a single route, a single controller method, and a single view that is common t users of both role types. In some instances, such as with the graphs and charts, the data will be different enough to warrant separate methods to retrieve the values needed. In most instances, the data is identical and will be accessed identically.&lt;br /&gt;
&lt;br /&gt;
We will create a standard hierarchy which works for both students (who only need to see a single team's scores) and instructors (who need to see all teams' scores). This hierarchy will be rendered within a page in the form of a set of tabbed panes which contain the contents. We will separate the information among four tabs.&lt;br /&gt;
&lt;br /&gt;
# Reviews&lt;br /&gt;
# Author Feedback&lt;br /&gt;
# Statistics&lt;br /&gt;
# Heat Grid&lt;br /&gt;
&lt;br /&gt;
Putting these components on different tabs will allow us to de-clutter the UI. The instructor scores report UI has multiple ways to expand and collapse sections of information, links are placed in some unusual places, and the page can get so cluttered that it is difficult to distinguish one thing from another. This will be cleaned up by removing some links, removing the author feedback and the charts, and placing the reviews and scores into more discernible sections. The graphs and charts will be on their own tab so they can be larger and easier to read. Since they are not confined to a single bar of a fixed height new graphs and charts can be added. The heat grid will no longer be coupled with the author feedback and there will be a standard author feedback view which encompasses all information needs. Each of these tabs will be rendered using their own partial. &lt;br /&gt;
&lt;br /&gt;
To prevent the application from pulling data for tabs which the user will not view, AJAX calls will be used to access the data on demand without reloading the page. These calls can also be expanded to request data for individual sections. Routes will be created to controller methods specifically to pull the data for each tab so that calls can be made to them to generate the necessary data structures. These will be accessed when a user expands a group or switches tabs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Technologies Used====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Technology&lt;br /&gt;
! Technology Type&lt;br /&gt;
! Use(s)&lt;br /&gt;
|-&lt;br /&gt;
| Ruby&lt;br /&gt;
| Language&lt;br /&gt;
| Core development of the application's backend system&lt;br /&gt;
|-&lt;br /&gt;
| Rails&lt;br /&gt;
| Framework&lt;br /&gt;
| Implements MVC; CRUD support; Web application support&lt;br /&gt;
|-&lt;br /&gt;
| RSpec (rspec)&lt;br /&gt;
| Gem&lt;br /&gt;
| Enables TDD; supports testing DSL&lt;br /&gt;
|-&lt;br /&gt;
| JQuery (jquery.ui.tabs)&lt;br /&gt;
| Library&lt;br /&gt;
| Enables creation of tabbed Web interfaces&lt;br /&gt;
|-&lt;br /&gt;
| JQuery (jquery.ui.accordion)&lt;br /&gt;
| Library&lt;br /&gt;
| Enables creation of accordion widgets for Web interfaces&lt;br /&gt;
|-&lt;br /&gt;
| Sass (sass-rails)&lt;br /&gt;
| Gem&lt;br /&gt;
| Sass style sheet pre-processor engine&lt;br /&gt;
|-&lt;br /&gt;
| Cascading Style Sheets (CSS)&lt;br /&gt;
| Language&lt;br /&gt;
| Web page presentation description language&lt;br /&gt;
|-&lt;br /&gt;
| Sassy CSS (SCSS)&lt;br /&gt;
| Language&lt;br /&gt;
| Superset of CSS style sheet language&lt;br /&gt;
|-&lt;br /&gt;
| rails-ajax&lt;br /&gt;
| Gem&lt;br /&gt;
| Enable AJAX to refresh containers within views without reloading the page&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Software Patterns====&lt;br /&gt;
&lt;br /&gt;
'''Model-View-Controller (MVC)''' - MVC is a software architectural pattern which divides an application into three parts which separate the data representation from the interface through which users will access and operate on the data. We will use this pattern to logically segregate our interface from the business logic implementation. The main components of this pattern are the:&lt;br /&gt;
* Model - The underlying logical structure of the application's data along with the accesses and operators on the data in the persistent storage medium.&lt;br /&gt;
* View - The user facing representation of the data along with the means for the user to request, operate on, or view the data.&lt;br /&gt;
* Controller - The intermediary layer between the Model and the View which accepts requests from the View, translates that to the Model, receives the Model's response and formats the response to the View.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' - A software architectural pattern which wraps data from persistent storage, along with the method to operate on the data, in a class or object of a class to be used within an application. It uses the object-relation mapping (ORM) technique to create virtual database objects. We will use this pattern to access the persistent storage in a standard way and to generate object representations of the records.&lt;br /&gt;
&lt;br /&gt;
'''Factory Method''' - A creational software design pattern which allows a class to instantiate objects but defer the creation to subclasses of the parent class. We will use this pattern in various places to generate objects for either students or instructors based on the user's role at the time of instantiation. This will allow us to have a single class to interact with from the controller and views but remain flexible enough to accommodate the needs of the different user types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Low Level Design===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Screen Mockups====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''New Scores Report With Multiple Teams and Collapsed Reviews'''&lt;br /&gt;
&lt;br /&gt;
[[File:Expanded_Teams_With_Collapsed_Tabs_-_35.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''New Scores Report With Multiple Teams and Expanded Reviews'''&lt;br /&gt;
&lt;br /&gt;
[[File:Expanded_Teams_With_Expanded_Tabs_-_35.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Class Diagram====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Files Changed====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Changes&lt;br /&gt;
|-&lt;br /&gt;
| grades_controller.rb&lt;br /&gt;
| Add extra methods for filters of student names, team names, or assignment titles.  Edit the index and show methods to support new tabs and expansion areas in the display.&lt;br /&gt;
|-&lt;br /&gt;
| view_my_scores.html.erb&lt;br /&gt;
| Edit arguments passed and linkage to the new display tabs.&lt;br /&gt;
|-&lt;br /&gt;
| _summary_reviews.html.erb&lt;br /&gt;
| Add more expansion areas to the display to organize the reviews.&lt;br /&gt;
|-&lt;br /&gt;
| _reviewTabs.html.erb&lt;br /&gt;
| Add new display tabs by building on the current test suite in this file.&lt;br /&gt;
|-&lt;br /&gt;
| _searchbox.html.erb&lt;br /&gt;
| Edit linkage to point to the new search method in grades_controller.rb&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing, we built off the existing test framework which implemented RSPEC.  The goal of our testing is to verify that the existing functionality is still present in the new views and is accessible to both the student and the instructor.  Below are the tests that have been modified or created to verify the changed functionality.  Any other tests not listed below are assumed to be unmodified and are intended to still work with the new updates. Note that some requirements of this project cannot be verified with the script such as formatting changes, but any functional modifications to the layout will be verified.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 1&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to hide the “feedback review” button is correct for a student&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#Has one course assigned&lt;br /&gt;
#Has one assigned as part of that course&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as a student&lt;br /&gt;
#Click on &amp;quot;Assignments&amp;quot; on the top menu&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#On the &amp;quot;Submit or Review work for Expertiza&amp;quot; screen, click on &amp;quot;Your scores”&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is not present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 2&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to show the “feedback review” button is correct for a student&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#Has one course assigned&lt;br /&gt;
#Has one assigned as part of that course&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as a student&lt;br /&gt;
#Click on &amp;quot;Assignments&amp;quot; on the top menu&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#On the &amp;quot;Submit or Review work for Expertiza&amp;quot; screen, click on &amp;quot;Your scores”&lt;br /&gt;
#On the “Summary Report for assignment” screen, select the “Show Review” button&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 3&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to hide the “feedback review” button is correct for an instructor&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#At least one assignment exists&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as an instructor&lt;br /&gt;
#Click on &amp;quot;Manage&amp;quot; on the top menu&lt;br /&gt;
#Click on “Assignments”&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#Click on &amp;quot;View Scores”&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is not present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 4&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to show the “feedback review” button is correct for an instructor&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#At least one assignment exists&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as an instructor&lt;br /&gt;
#Click on &amp;quot;Manage&amp;quot; on the top menu&lt;br /&gt;
#Click on “Assignments”&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#Click on &amp;quot;View Scores”&lt;br /&gt;
#On the “Summary Report for assignment” screen, select the “Show Review” button&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Ahasket</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E1735._UI_changes_for_review_and_score_reports&amp;diff=108558</id>
		<title>E1735. UI changes for review and score reports</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E1735._UI_changes_for_review_and_score_reports&amp;diff=108558"/>
		<updated>2017-04-13T04:12:49Z</updated>

		<summary type="html">&lt;p&gt;Ahasket: /* Low Level Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
This wiki provides details on the tasks that were undertaken as part of the continuous improvement to the Expertiza project.&lt;br /&gt;
===Background===&lt;br /&gt;
[[Expertiza_documentation|Expertiza]] is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). The application provides a complete system through which students and instructors collaborate on the learning objects as well as submit, review and grade assignments for the courses. It is used in select courses at NC State and by professors at several other colleges and universities. The Expertiza project is supported by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview of Review Functionality===&lt;br /&gt;
&lt;br /&gt;
The Expertiza review system encompasses many types of reviews. Assignments can have multiple submission rounds defined with their own due dates and criteria. Each round can have an associated questionnaire whereby peers are encouraged, or required, to review each others' submissions and rate those submissions using the scores 1 through 5 for each question. The scores for each question are averaged to find the rating for the submission for each  questionnaire response. The average of all questionnaire responses determine the score for the submission.After the reviews are submitted, the recipient of those reviews can rate the reviewers using a similar questionnaire. On this questionnaire, the author of the submission will rate the reviews based on the reviewers understanding, helpfulness, and respectfulness. This is a review of the reviews, thus it is termed a &amp;quot;metareview.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Both students and instructors using Expertiza have the ability to view the reviews and the scores associated with the reviews for each assignment. These screens will display review summary and detail information in various formats such as lists, graphs, and heatgrids. The instructor will be able to see all review and score information for all teams on the assignment whereas a student will only be able to see the review and score information pertaining to them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The reviews and associated scores are available on the scores report. To access the score reports in Expertiza follow these instructions:&lt;br /&gt;
&lt;br /&gt;
'''As a student'''&lt;br /&gt;
&lt;br /&gt;
# Log into Expertiza.&lt;br /&gt;
# Click on the 'Assignments' link on the top navigation bar.&lt;br /&gt;
# Find the assignment in the list and click the title of the assignment.&lt;br /&gt;
# Click on the 'Your scores' link to see the standard view or click on the 'Alternate View' link to see the heatgrid view.&lt;br /&gt;
&lt;br /&gt;
'''As an instructor'''&lt;br /&gt;
&lt;br /&gt;
# Log into Expertiza.&lt;br /&gt;
# Hover over the 'Manage' item on the top navigation bar, then select click the 'Assignments' link.&lt;br /&gt;
# Find the assignment in the list and click the 'View scores' icon (a star with a magnifying glass) in the 'Actions' column.&lt;br /&gt;
# This will bring up the standard view. To see the heatgrid view, click the 'Alternate View' link on the team headings or click the 'view heatgrid' beneath the 'Final Score' when the team is expanded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Motivation===&lt;br /&gt;
By participating in the overall refactoring effort as part of the continuous improvement of Expertiza, students get an opportunity to work on a open source software project. This helps them gain exposure on the technologies used in the project as well as much needed experience in collaborating with peers as part of the software development process. This effort was undertaken as a final project for the CSC 517 - Object Oriented Design and Development course at North Carolina State University in the spring of 2017.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Purpose==&lt;br /&gt;
&lt;br /&gt;
===Requirements Statement===&lt;br /&gt;
Expertiza displays reviews (i) to the team who was reviewed, and (ii) to the reviewer.  A student user can see all the reviews of his/her team’s project.  The instructor can see all the reviews of everyone’s project.  The instructor also has access to a review report, which shows, for each reviewer, all the reviews that (s)he wrote. Currently, the score report and review report use completely different code.  This makes the UI non-orthogonal and also causes DRY problems.  So, we would like to have a single way of displaying reviews that would be visible to students (reviews that they did, and reviews that their team received), and instructors (reviews that each time received, sorted by team; and reviews that each student did, sorted by student).&lt;br /&gt;
&lt;br /&gt;
===Required Tasks===&lt;br /&gt;
The tasks involved as part of this requirements change are as follows:&lt;br /&gt;
# Compact the review display&lt;br /&gt;
#* Eliminate the blank lines between items within a single review. Instead vary the background color from line to line to improve readability&lt;br /&gt;
#* With a single click, there should be a way to hide all the reviews, reveal just the headings (as at present), or expand all the reviews&lt;br /&gt;
# At the top of each review, it should say&lt;br /&gt;
#* Who submitted the review. The instructor should see the user’s name and user-ID.&lt;br /&gt;
#* A student should see&lt;br /&gt;
#** “Reviewer #k”, where k is an integer between 1 and n, the number of reviews that have been submitted for this project&lt;br /&gt;
#** The version number of the review&lt;br /&gt;
#** The time the review was submitted&lt;br /&gt;
# There should be a tabbed view to switch between various review views&lt;br /&gt;
#* One tab has overall statistics (averages, min, max, as the present “normal” view)&lt;br /&gt;
#* One tab has the heat map (current “alternate” view)&lt;br /&gt;
#* One tab has a grid view, with no scores, but text comments in the grid squares, and then a “More” link to display the whole comment (which will require expanding the row of the grid)&lt;br /&gt;
#* Switching between reviews from Reviewer k and Reviewer j might also be done by clicking on different tabs.  Or, it might be more convenient to keep the current score view, which lists the n reviews across the page.  Then the student should be able to click on the reviewer number (the instructor would instead click on the reviewer name) and see the review done by that reviewer&lt;br /&gt;
# To make it easy to focus on the reviewer’s feedback, there should be a way to hide and/or gray the criteria (“questions”), so the responses stand out more clearly&lt;br /&gt;
# There needs to be a way to search all reviews (of a particular project, or by a particular individual) for a given text string.  The user should be able to go from one instance of the text string to another by clicking down and up buttons&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In the current state, the score report for instructors and students are built differently though they display the same information using similar UI elements. The application has multiple views into the same information but the way in which those views are accessed, the code which populates them, and the layout of the screens differs unnecessarily between instructors and students and across the views themselves. This leads to redundant code in both the backend and frontend of the application. Furthermore, since the UI is not uniform between instructors and students, instructors may have difficulty assisting students in accessing their score information due to the differences which are present in the UI that leads to confusion.&lt;br /&gt;
&lt;br /&gt;
Following are some of the issues with the current state UI which we seek to rectify.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scores Report====&lt;br /&gt;
[[File:Problem_Statement_Diagram_1A_-_Instructor_View_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
The scores report for students and instructors have very similar layouts despite being created by different controller methods and views. They both display graphs, reviews on team submissions, author feedback, and score metrics. The primary different between them is that the instructor view (shown above) displays information for all teams in a collapsible accordion widget format while the student view (shown below) display the information only for a single team. There are some further discontinuities between the two UIs. For example, the student cannot access the heatgrid view from within the scores report page. This view is only accessible from the assignment page for students. For instructors there are two ways to access the heatgrid view from a single page. The 'Alternate View' link is adjacent to the team name on the heading bar and there is also a link inexplicably placed beneath the 'Final Score' field.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_1B_-_Student_View_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Author Feedback====&lt;br /&gt;
Author feedback takes two different forms when being shown to instructors but only one form for students. Both students and instructors have access to the author feedback format shown on the left in the student view. This format is identical to the format of the review scores and is displayed on the scores report for both instructor and student. The format on the right is shown on the heatgrid view yet it is only available to instructors. The information conveyed by these two formats is nearly identical and not uniformly available to all consumers of this information.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_2_-_Author_Feedback_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Graphs and Charts====&lt;br /&gt;
The scores report view has a bar of graphs and charts at the top of the page for both students and instructors. Both views shown below use a donut chart and bar graphs though their method of display is not uniform. The instructor view has titles beneath each item but the student view does not. The 'Submitted work' and 'Author Feedback' titles shown, despite being beneath the bar graphs, are actually headings for the metrics which are displayed beneath the graphs. Also, the graphs contain two labels on the y-axis: the maximum score and the average score. The graphs are so compact that the values on the axis overlap and make them illegible.&lt;br /&gt;
&lt;br /&gt;
[[File:Problem_Statement_Diagram_3_-_Squashed_Graphs_-_65.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Design==&lt;br /&gt;
&lt;br /&gt;
===High Level Design===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Design Overview====&lt;br /&gt;
The project requirements state that we need to create a standard UI for accessing and consuming review and score information. The emphasis will be on smart and purposeful code reuse as well as ease of navigation to access information. To achieve these results we will redesign the scores report to work for both instructors and students alike. There will be a single route, a single controller method, and a single view that is common t users of both role types. In some instances, such as with the graphs and charts, the data will be different enough to warrant separate methods to retrieve the values needed. In most instances, the data is identical and will be accessed identically.&lt;br /&gt;
&lt;br /&gt;
We will create a standard hierarchy which works for both students (who only need to see a single team's scores) and instructors (who need to see all teams' scores). This hierarchy will be rendered within a page in the form of a set of tabbed panes which contain the contents. We will separate the information among four tabs.&lt;br /&gt;
&lt;br /&gt;
# Reviews&lt;br /&gt;
# Author Feedback&lt;br /&gt;
# Statistics&lt;br /&gt;
# Heat Grid&lt;br /&gt;
&lt;br /&gt;
Putting these components on different tabs will allow us to de-clutter the UI. The instructor scores report UI has multiple ways to expand and collapse sections of information, links are placed in some unusual places, and the page can get so cluttered that it is difficult to distinguish one thing from another. This will be cleaned up by removing some links, removing the author feedback and the charts, and placing the reviews and scores into more discernible sections. The graphs and charts will be on their own tab so they can be larger and easier to read. Since they are not confined to a single bar of a fixed height new graphs and charts can be added. The heat grid will no longer be coupled with the author feedback and there will be a standard author feedback view which encompasses all information needs. Each of these tabs will be rendered using their own partial. &lt;br /&gt;
&lt;br /&gt;
To prevent the application from pulling data for tabs which the user will not view, AJAX calls will be used to access the data on demand without reloading the page. These calls can also be expanded to request data for individual sections. Routes will be created to controller methods specifically to pull the data for each tab so that calls can be made to them to generate the necessary data structures. These will be accessed when a user expands a group or switches tabs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Technologies Used====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Technology&lt;br /&gt;
! Technology Type&lt;br /&gt;
! Use(s)&lt;br /&gt;
|-&lt;br /&gt;
| Ruby&lt;br /&gt;
| Language&lt;br /&gt;
| Core development of the application's backend system&lt;br /&gt;
|-&lt;br /&gt;
| Rails&lt;br /&gt;
| Framework&lt;br /&gt;
| Implements MVC; CRUD support; Web application support&lt;br /&gt;
|-&lt;br /&gt;
| RSpec (rspec)&lt;br /&gt;
| Gem&lt;br /&gt;
| Enables TDD; supports testing DSL&lt;br /&gt;
|-&lt;br /&gt;
| JQuery (jquery.ui.tabs)&lt;br /&gt;
| Library&lt;br /&gt;
| Enables creation of tabbed Web interfaces&lt;br /&gt;
|-&lt;br /&gt;
| JQuery (jquery.ui.accordion)&lt;br /&gt;
| Library&lt;br /&gt;
| Enables creation of accordion widgets for Web interfaces&lt;br /&gt;
|-&lt;br /&gt;
| Sass (sass-rails)&lt;br /&gt;
| Gem&lt;br /&gt;
| Sass style sheet pre-processor engine&lt;br /&gt;
|-&lt;br /&gt;
| Cascading Style Sheets (CSS)&lt;br /&gt;
| Language&lt;br /&gt;
| Web page presentation description language&lt;br /&gt;
|-&lt;br /&gt;
| Sassy CSS (SCSS)&lt;br /&gt;
| Language&lt;br /&gt;
| Superset of CSS style sheet language&lt;br /&gt;
|-&lt;br /&gt;
| rails-ajax&lt;br /&gt;
| Gem&lt;br /&gt;
| Enable AJAX to refresh containers within views without reloading the page&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Software Patterns====&lt;br /&gt;
&lt;br /&gt;
'''Model-View-Controller (MVC)''' - MVC is a software architectural pattern which divides an application into three parts which separate the data representation from the interface through which users will access and operate on the data. We will use this pattern to logically segregate our interface from the business logic implementation. The main components of this pattern are the:&lt;br /&gt;
* Model - The underlying logical structure of the application's data along with the accesses and operators on the data in the persistent storage medium.&lt;br /&gt;
* View - The user facing representation of the data along with the means for the user to request, operate on, or view the data.&lt;br /&gt;
* Controller - The intermediary layer between the Model and the View which accepts requests from the View, translates that to the Model, receives the Model's response and formats the response to the View.&lt;br /&gt;
&lt;br /&gt;
'''Active Record''' - A software architectural pattern which wraps data from persistent storage, along with the method to operate on the data, in a class or object of a class to be used within an application. It uses the object-relation mapping (ORM) technique to create virtual database objects. We will use this pattern to access the persistent storage in a standard way and to generate object representations of the records.&lt;br /&gt;
&lt;br /&gt;
'''Factory Method''' - A creational software design pattern which allows a class to instantiate objects but defer the creation to subclasses of the parent class. We will use this pattern in various places to generate objects for either students or instructors based on the user's role at the time of instantiation. This will allow us to have a single class to interact with from the controller and views but remain flexible enough to accommodate the needs of the different user types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Low Level Design===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Screen Mockups====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''New Scores Report With Multiple Teams and Collapsed Reviews'''&lt;br /&gt;
&lt;br /&gt;
[[File:Expanded_Teams_With_Collapsed_Tabs_-_35.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''New Scores Report With Multiple Teams and Expanded Reviews'''&lt;br /&gt;
&lt;br /&gt;
[[File:Expanded_Teams_With_Expanded_Tabs_-_35.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Code Change Specifics====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Class Diagram====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Files Changed====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! Changes&lt;br /&gt;
|-&lt;br /&gt;
| grades_controller.rb&lt;br /&gt;
| Add extra methods for filters of student names, team names, or assignment titles.  Edit the index and show methods to support new tabs and expansion areas in the display.&lt;br /&gt;
|-&lt;br /&gt;
| view_my_scores.html.erb&lt;br /&gt;
| Edit arguments passed and linkage to the new display tabs.&lt;br /&gt;
|-&lt;br /&gt;
| _summary_reviews.html.erb&lt;br /&gt;
| Add more expansion areas to the display to organize the reviews.&lt;br /&gt;
|-&lt;br /&gt;
| _reviewTabs.html.erb&lt;br /&gt;
| Add new display tabs by building on the current test suite in this file.&lt;br /&gt;
|-&lt;br /&gt;
| _searchbox.html.erb&lt;br /&gt;
| Edit linkage to point to the new search method in grades_controller.rb&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing, we built off the existing test framework which implemented RSPEC.  The goal of our testing is to verify that the existing functionality is still present in the new views and is accessible to both the student and the instructor.  Below are the tests that have been modified or created to verify the changed functionality.  Any other tests not listed below are assumed to be unmodified and are intended to still work with the new updates. Note that some requirements of this project cannot be verified with the script such as formatting changes, but any functional modifications to the layout will be verified.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 1&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to hide the “feedback review” button is correct for a student&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#Has one course assigned&lt;br /&gt;
#Has one assigned as part of that course&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as a student&lt;br /&gt;
#Click on &amp;quot;Assignments&amp;quot; on the top menu&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#On the &amp;quot;Submit or Review work for Expertiza&amp;quot; screen, click on &amp;quot;Your scores”&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is not present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 2&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to show the “feedback review” button is correct for a student&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#Has one course assigned&lt;br /&gt;
#Has one assigned as part of that course&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as a student&lt;br /&gt;
#Click on &amp;quot;Assignments&amp;quot; on the top menu&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#On the &amp;quot;Submit or Review work for Expertiza&amp;quot; screen, click on &amp;quot;Your scores”&lt;br /&gt;
#On the “Summary Report for assignment” screen, select the “Show Review” button&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 3&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to hide the “feedback review” button is correct for an instructor&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#At least one assignment exists&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as an instructor&lt;br /&gt;
#Click on &amp;quot;Manage&amp;quot; on the top menu&lt;br /&gt;
#Click on “Assignments”&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#Click on &amp;quot;View Scores”&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is not present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; | Test Case 4&lt;br /&gt;
|-&lt;br /&gt;
! Test Type&lt;br /&gt;
| Functional&lt;br /&gt;
|-&lt;br /&gt;
! Scenario&lt;br /&gt;
| Test to see if modifications to the display_as_html function in response.rb order to show the “feedback review” button is correct for an instructor&lt;br /&gt;
|-&lt;br /&gt;
! Pre-Conditions&lt;br /&gt;
| &lt;br /&gt;
Make sure student to test with has the following:&lt;br /&gt;
#At least one assignment exists&lt;br /&gt;
#Has more than one review for that assignment&lt;br /&gt;
|-&lt;br /&gt;
! Description&lt;br /&gt;
| &lt;br /&gt;
#Login to the site as an instructor&lt;br /&gt;
#Click on &amp;quot;Manage&amp;quot; on the top menu&lt;br /&gt;
#Click on “Assignments”&lt;br /&gt;
#Select an assignment from the list&lt;br /&gt;
#Click on &amp;quot;View Scores”&lt;br /&gt;
#On the “Summary Report for assignment” screen, select the “Show Review” button&lt;br /&gt;
#On the &amp;quot;Summary Report for assignment&amp;quot; screen, verify that the &amp;quot;Give feedback for Review 1&amp;quot; button is present&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Ahasket</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1711&amp;diff=107464</id>
		<title>CSC/ECE 517 Spring 2017 E1711</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2017_E1711&amp;diff=107464"/>
		<updated>2017-03-25T07:50:31Z</updated>

		<summary type="html">&lt;p&gt;Ahasket: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;&amp;lt;b&amp;gt; E1711. Refactor delayed_mailer.rb and scheduled_task.rb&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a web based tool that allows instructors to create collaborative assignments where students can provide peer feedback on each others work.  It provides instructors a system to manage assignments and different courses.&lt;br /&gt;
&lt;br /&gt;
==Scope of project E1711==&lt;br /&gt;
&lt;br /&gt;
The goal of E1711 was to refactor code found in the files &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;scheduled_task.rb&amp;lt;/i&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
The following issues were identified as the scope of this project:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:::* &amp;lt;i&amp;gt;scheduled_task.rb&amp;lt;/i&amp;gt; duplicated most of its code from &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt;.  Our objective is to reduce/remove the duplication in keeping with the DRY principle.&lt;br /&gt;
:::* The &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; method uses a giant case statement, instead we were to incorporate the use of polymorphism&lt;br /&gt;
:::* The &amp;lt;code&amp;gt;mail_signed_up_users&amp;lt;/code&amp;gt; is long and should be broken into smaller and better named methods&lt;br /&gt;
:::* Add/modify test cases as we added/removed/modified areas of the code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Information about the assignment can be found on [https://docs.google.com/document/d/17f8WVW7i-S5i0HEc__33lDQYRu9RxD7HQndSumQ_-JA/edit#heading=h.kq28lsw1uwf4 this document]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
As this was a purely refactoring effort, our testing consisted of confirming existing tests did not break, modifying existing tests to match our changes, or adding tests as needed.  The below sections will cover each objective in detail and will include information on how testing was done for each of those changes.  See each of the &amp;lt;b&amp;gt;Our Testing&amp;lt;/b&amp;gt; sections.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Remove duplicated code between ''delayed_mailer.rb'' and ''scheduled_task.rb''=&lt;br /&gt;
&lt;br /&gt;
===Background of Objective===&lt;br /&gt;
&lt;br /&gt;
The main objective of this task was to reduce duplicated code as recommended by DRY principle.&lt;br /&gt;
&lt;br /&gt;
After a deep investigation into understanding why the same code would appear in two separate files, we concluded that the authors of &amp;lt;i&amp;gt;scheduled_task.rb&amp;lt;/i&amp;gt; found that &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt; already integrated with a Ruby gem called [https://rubygems.org/gems/delayed_job/versions/4.1.2 delayed_job].   &amp;lt;i&amp;gt;delayed_job&amp;lt;/i&amp;gt; is used to run tasks asynchronously in the background.  It was used in &amp;lt;i&amp;gt;delayed_mailer&amp;lt;/i&amp;gt; to add an outgoing email to a queue to send out in the future.  Instead of recreating similar infrastructure, the authors copied over the file to a different location, added on the new desired functionality, and renamed it.  The authors also pointed all existing code to use &amp;lt;i&amp;gt;scheduled_task.rb&amp;lt;/i&amp;gt; instead of &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Our Changes===&lt;br /&gt;
&lt;br /&gt;
We found that the vast majority of the code in both the files applied to sending emails so we decided to merge the &amp;lt;i&amp;gt;scheduled_task.rb&amp;lt;/i&amp;gt; into &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt; by porting the enhancements made for the scheduled tasks into &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt;.  Doing so allowed us to meet the objective of DRYing out the code.  However, we still have a situation where scheduled tasks feature has code in a section devoted to mailer code.  We recommend that a future project take up the needed changes to pull out the scheduled task code out of the mailer file and make it a standalone feature as it should have been originally.  See details in the &amp;lt;b&amp;gt;Future Refactoring Opportunities&amp;lt;/b&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
===Existing Tests===&lt;br /&gt;
&lt;br /&gt;
We did not find any existing automated testing targeting this area of the code.  All existing tests in the &amp;lt;code&amp;gt;spec&amp;lt;/code&amp;gt; file associated with this feature were copies of the tests in the delayed mailer feature and did not exercise any of the new code that was introduced with adding the new types of scheduled tasks.&lt;br /&gt;
&lt;br /&gt;
===Our Testing===&lt;br /&gt;
&lt;br /&gt;
We went back to the demonstration of this feature and manually tested all the same scenarios.  We verified that no functionality presented in the scheduled tasks demonstration was broken.  Tests were added for the delayed mailer feature (covered in more details in the following sections).  We recommend tests focused towards scheduled tasks are added once the scheduled tasks code is removed from the delayed mailer file back into an independent file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Refactor the &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; mehtod=&lt;br /&gt;
&lt;br /&gt;
===Background of Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of this task was to clean up this method.  It was identified as being badly named, long, and not taking advantage of good design.  It is essentially a giant case statement where  one of the variables passed into the &amp;lt;code&amp;gt;DelayedMailer&amp;lt;/code&amp;gt; constructor determines the people who receives the email..  Some suggested ways to refactor this function was first rename the &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; to better describe what it does and to use polymorphism in place of the case statement.  The original thought was that polymorphism could be used to determine what was sent out in each email based on the type of the email.&lt;br /&gt;
&lt;br /&gt;
===Our Changes===&lt;br /&gt;
&lt;br /&gt;
The first item we looked at was to rename the method.  A generic name such as &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; usually means that the method is doing too much or does not have a clear objective.  Unfortunately, we found we could not rename the method because the delayed_job gem requires a method named &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; in order to work on a custom job.  See documentation [http://www.rubydoc.info/gems/delayed_job/4.1.2 here]&lt;br /&gt;
&lt;br /&gt;
The second part of the planned refactoring was to use polymorphism to determine the content of the email.  After simplifying much of the code in the file, we discovered that the content of the email was independent of the variables used to initialize the object.  At that point, we weighed the complexity of new code to use polymorphism versus a significantly more simplified case statement, and because of the lack of existing tests, decided that the simplified case statement was not only short, it is also very simple to follow the flow through the code.  We instead focused on DRYing out this code as a better return on immediate investment as opposed to adding polymorphism.&lt;br /&gt;
&lt;br /&gt;
===Existing Tests===&lt;br /&gt;
&lt;br /&gt;
There were six existing Rspec tests for &amp;lt;i&amp;gt;delayed_mailer.rb&amp;lt;/i&amp;gt;, but the existing tests only verify that a new delayed job was added to the queue based on the type of deadline specified when creating a new &amp;lt;code&amp;gt;DelayedMalier&amp;lt;/code&amp;gt;.  We deemed the existing testing as adequate for this section of the file as the &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; method calls other methods to find the email addresses and send the email.&lt;br /&gt;
&lt;br /&gt;
===Our Testing===&lt;br /&gt;
&lt;br /&gt;
We did not change existing testing for the &amp;lt;code&amp;gt;perform&amp;lt;/code&amp;gt; method as the existing testing verified that a job to send out emails was added to the queue.  We did, however, verify that our code changes did not break this portion of the code by continuously running the existing test cases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Refactor &amp;lt;code&amp;gt;mail_signed_up_users&amp;lt;/code&amp;gt; method=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Background of Objective===&lt;br /&gt;
&lt;br /&gt;
The primary objective of this task was that the method is long and could be broken into smaller appropriately named methods.&lt;br /&gt;
&lt;br /&gt;
===Our Changes===&lt;br /&gt;
&lt;br /&gt;
We replaced the existing single method &amp;lt;code&amp;gt;mail_signed_up_users&amp;lt;/code&amp;gt; with a shorter version and a new method &amp;lt;code&amp;gt;find_team_members_email_for_all_topics&amp;lt;/code&amp;gt;.  We also heavily modified (including renaming) the existing method &amp;lt;code&amp;gt;getTeamMembersMail&amp;lt;/code&amp;gt;, and it is now called &amp;lt;code&amp;gt;find_team_members_email&amp;lt;/code&amp;gt;.  As the naming of the methods suggest, there are still opportunities for DRYing the two functions to get team member emails, but exiting code makes it extremely difficult to combine the two functions exactly though they are extremely similar at first glance.  Merging the two would require refactoring areas outside the scope of this assignment and a whole new set of test cases to verify a lot of basic functionality is not broken in the process.  We recommend this is taken up as a part of a future assignment.  See &amp;lt;/b&amp;gt;Future Refactoring Opportunities&amp;lt;/b&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
===Existing Tests===&lt;br /&gt;
&lt;br /&gt;
We did not find any existing automated testing targeting this area of the code.  None of the six existing tests verified if the emails are being retrieved from the database so changes in the database schema would break the feature.&lt;br /&gt;
&lt;br /&gt;
=== Our Testing===&lt;br /&gt;
&lt;br /&gt;
We added test cases for each of the methods we changed.  There are now 10 test cases that are covering this file.  The four new test cases focus on verifying that the functions can access the database to protect against schema changes and making sure the right methods are called.  Tests were not added for code that was not within the scope of this assignment but we recommend the remainder of the functions also get similar test cases.  See details in  &amp;lt;b&amp;gt;Future Refactoring Opportunities&amp;lt;/b&amp;gt; below.&lt;br /&gt;
&lt;br /&gt;
=Future Refactoring Opportunities=&lt;br /&gt;
&lt;br /&gt;
Once we started to refactor the code, we found many additional opportunities to refactor the files that was beyond the planned scope.  We note down some of the opportunities here and leave it to future projects to address.&lt;br /&gt;
&lt;br /&gt;
1. Scheduled Task feature does not belong in the mailers.  It needs to be a standalone file with new tests added.&lt;br /&gt;
&lt;br /&gt;
2. There are still methods that look like they should be collapsed into one function and opportunities for DRYing out code once other tightly coupled methods are also refactored.&lt;br /&gt;
&lt;br /&gt;
3. There were practically no tests for this area of the code.  We added tests for what we modified but much code still remains that is not being tested.&lt;br /&gt;
&lt;br /&gt;
4. There are many calls to the database for the same information in different methods.  These repeated calls could probably be reduced to one call and save the result from the database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Extra Credit=&lt;br /&gt;
&lt;br /&gt;
During our testing, we found that the &amp;quot;create new late policy&amp;quot; function was broken.  It was throwing a ActiveModel::ForbiddenAttributesError on LatePoliciesController#create, as seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:Late_Policy_Ruby_Error.jpg|frame|center]]  &lt;br /&gt;
&lt;br /&gt;
To find this, we had to add the following code to the private section of late_policies_controller.rb:&lt;br /&gt;
&lt;br /&gt;
    def late_policy&lt;br /&gt;
    params.require(:late_policy).permit(:policy_name, :penalty_per_unit, :penalty_unit, :max_penalty)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
and change the argument in the LatePolicy.new() to just &lt;br /&gt;
&lt;br /&gt;
    @late_policy = LatePolicy.new(late_policy)&lt;br /&gt;
&lt;br /&gt;
After these two small changes, we were able to create new late policies from the UI.&lt;/div&gt;</summary>
		<author><name>Ahasket</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Late_Policy_Ruby_Error.jpg&amp;diff=107463</id>
		<title>File:Late Policy Ruby Error.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Late_Policy_Ruby_Error.jpg&amp;diff=107463"/>
		<updated>2017-03-25T07:42:35Z</updated>

		<summary type="html">&lt;p&gt;Ahasket: uploaded a new version of &amp;amp;quot;File:Late Policy Ruby Error.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ahasket</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Late_Policy_Ruby_Error.jpg&amp;diff=107462</id>
		<title>File:Late Policy Ruby Error.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Late_Policy_Ruby_Error.jpg&amp;diff=107462"/>
		<updated>2017-03-25T07:33:41Z</updated>

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