<?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=Pli5</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=Pli5"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Pli5"/>
	<updated>2026-06-05T21:28:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92535</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92535"/>
		<updated>2014-12-05T02:20:03Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case to underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using encapsulation to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to encapsulate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*After confirmation with Professor and TAs, we no longer need to check the existence of the topic.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views('''_participant.html.erb'''). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It gets the value of total_score from the instance variable('''@pscore''') and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the '''participant.scores''' method in gradesController, so we move these calculations into scores method which is declared in the model of '''assignment_participant.rb'''. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future maintenance. Since min, max and avg are the mostly used variables, we created a new data structure '''Rscore''' in model, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from '''Rscore'''.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, '''pscore''' is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/document/d/1ncwlrTEZ1taP6ZvMc_GqP4jcAchE03zXSnZwvzgfeDw/edit?usp=sharing ''Requirement for E147'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
[http://youtu.be/RPfzaGtJtQc ''Youtube Demo'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92531</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92531"/>
		<updated>2014-12-05T02:14:47Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case to underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using encapsulation to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to encapsulate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*After confirmation with Professor and TAs, we no longer need to check the existence of the topic.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views('''_participant.html.erb'''). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable('''@pscore''') and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the '''participant.scores''' method in gradesController, so we move these calculations into scores method which is declared in the model of '''assignment_participant.rb'''. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure '''Rscore''', which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, '''pscore''' is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/document/d/1ncwlrTEZ1taP6ZvMc_GqP4jcAchE03zXSnZwvzgfeDw/edit?usp=sharing ''Requirement for E147'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
[http://youtu.be/RPfzaGtJtQc ''Youtube Demo'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92530</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92530"/>
		<updated>2014-12-05T02:14:25Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case to underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using encapsulation to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to encapsulate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*After confirmation with Professor and TAs, we no longer need to check the existence of the topic.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views('''_participant.html.erb'''). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable('''@pscore''') and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the '''participant.scores''' method in gradesController, so we move these calculations into get_scores method which is declared in the model of '''assignment_participant.rb'''. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure '''Rscore''', which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, '''pscore''' is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/document/d/1ncwlrTEZ1taP6ZvMc_GqP4jcAchE03zXSnZwvzgfeDw/edit?usp=sharing ''Requirement for E147'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
[http://youtu.be/RPfzaGtJtQc ''Youtube Demo'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92527</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92527"/>
		<updated>2014-12-05T02:00:39Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using encapsulation to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to encapsulate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*After confirmation with Professor and TAs, we no longer need to check the existence of the topic.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views('''_participant.html.erb'''). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable('''@pscore''') and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the '''participant.get_scores''' method in gradesController, so we move these calculations into get_scores method which is declared in the model of '''assignment_participant.rb'''. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/document/d/1ncwlrTEZ1taP6ZvMc_GqP4jcAchE03zXSnZwvzgfeDw/edit?usp=sharing ''Requirement for E147'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
[http://youtu.be/RPfzaGtJtQc ''Youtube Demo'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92372</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92372"/>
		<updated>2014-12-03T06:41:50Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* OOP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views(_participant.html.erb). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable(@pscore) and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the participant.get_scores method in gradesController, so we move these calculations into get_scores method which is declared in the model of assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92371</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92371"/>
		<updated>2014-12-03T06:41:32Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views(_participant.html.erb). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable(@pscore) and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the participant.get_scores method in gradesController, so we move these calculations into get_scores method which is declared in the model of assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt single responsibility principle and DRY principle to simplify our code.&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92370</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92370"/>
		<updated>2014-12-03T06:39:57Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views(_participant.html.erb). The main function of these calculations in the _participant.html.erb is to curve the teams' total score. It obtains the value of total_score from the instance variable(@pscore) and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculations to the model to avoid these problems. In current system, the participant's total score is obtained by calling the participant.get_scores method in gradesController, so we move these calculations into get_scores method which is declared in the model of assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
By testing, our solution solves the above problem effectively. Meanwhile, we adopt&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92369</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92369"/>
		<updated>2014-12-03T06:27:49Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
We find that there are some calculations in the views(_participant.html.erb). The main function of these calculations in the _participant.html.erb is used to curve the teams' total score. It obtains the value of total_score from the instance variable(@pscore) and computes them in the views.&lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we can move these calculations to the model to avoid the problems. Now, we get participant's total score by calling participant.get_scores method, and get_scores method is declared in the model of assignment_participant.rb. So we can let get_scores method to calculate the total score.&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92364</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92364"/>
		<updated>2014-12-03T04:57:32Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
There are some calculations in the views(_participant.html.erb). The main function of these calculations is to curve the teams' total score. It gets the value of total_score from the instance variable(@pscore) and computes them in the views. &lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculation into the model according to the project's introduction. Because the total score is the&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92363</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92363"/>
		<updated>2014-12-03T04:55:30Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
&lt;br /&gt;
There are some calculations in the views(_participant.html.erb). The main function of these calculations is to curve the teams' total score. It gets the value of total_score from the instance variable(@pscore) and computes them in the views. &lt;br /&gt;
&lt;br /&gt;
The whole project utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, the above calculations violate the MVC design pattern and ruin the program's structure. Meanwhile, it will increase the workload of the views and decrease performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculation into the model according to the project's introduction.&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92362</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92362"/>
		<updated>2014-12-03T04:02:31Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
====Why move calculation from view to model====&lt;br /&gt;
&lt;br /&gt;
There are some calculations in the view of _participant.html.erb. The main function of these code is to curve the team's total score, which gets total_score from the instance variable of @pscore and curve it here. &lt;br /&gt;
&lt;br /&gt;
The whole website utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, in practice, these calculations in the views violates this pattern and ruins the program's structure. Meanwhile, it will increase the workload of the views, and decrease the speed of viewing the current page. performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculation into the model according to the project's introduction. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, MVC-Model-View-Controller - is a design pattern for the architecture of web applications. It is a widely adopted pattern, across many languages and implementation frameworks, whose purpose is to achieve a clean separation between three components of most any web application. &lt;br /&gt;
&lt;br /&gt;
Second, more calculation in the view will decrease the speed and performance of the website.&lt;br /&gt;
&lt;br /&gt;
====The function of the calculation====&lt;br /&gt;
In the file of _participant.html.erb show all team's score. Before that, the view gets the total score from @pscore, and curves the total score in the view. &lt;br /&gt;
The calculation is in the /views/grades/_participant.html.erb. The main function is to curve the total score. We move these calculation into the method of  /model/assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
why use mvc&lt;br /&gt;
calculation's function &lt;br /&gt;
why put them in the model&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92361</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92361"/>
		<updated>2014-12-03T03:57:18Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Details of Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
====Why move calculation from view to model====&lt;br /&gt;
&lt;br /&gt;
There are some calculations in the view of _participant.html.erb. The main function of these code is to curve the team's total score, which gets total_score from the instance variable of @pscore and curve it here. &lt;br /&gt;
&lt;br /&gt;
The whole website utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, in practice, these calculations in the views violates this pattern and ruins the program's structure. Meanwhile, it will increase the workload of the views, and decrease the speed of viewing the current page. performance of the website.&lt;br /&gt;
&lt;br /&gt;
In order to implement the MVC design pattern much better and improve the performance of the website, we move these calculation into the model according to the project's introduction. &lt;br /&gt;
&lt;br /&gt;
    According to MVC design pattern,&lt;br /&gt;
&lt;br /&gt;
First, MVC-Model-View-Controller - is a design pattern for the architecture of web applications. It is a widely adopted pattern, across many languages and implementation frameworks, whose purpose is to achieve a clean separation between three components of most any web application. &lt;br /&gt;
&lt;br /&gt;
Second, more calculation in the view will decrease the speed and performance of the website.&lt;br /&gt;
&lt;br /&gt;
====The function of the calculation====&lt;br /&gt;
In the file of _participant.html.erb show all team's score. Before that, the view gets the total score from @pscore, and curves the total score in the view. &lt;br /&gt;
The calculation is in the /views/grades/_participant.html.erb. The main function is to curve the total score. We move these calculation into the method of  /model/assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
why use mvc&lt;br /&gt;
calculation's function &lt;br /&gt;
why put them in the model&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92360</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92360"/>
		<updated>2014-12-03T03:39:26Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Details of Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.189:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
*models/course.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/course_team.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/scores_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignments_controller.rb&lt;br /&gt;
&lt;br /&gt;
*controllers/assignment_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_tabbing.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/edit.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_review.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/_submitted_files.html.erb&lt;br /&gt;
&lt;br /&gt;
*response/view.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*Modify the setters and getters in the models/participant.rb by refactoring&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&lt;br /&gt;
&lt;br /&gt;
*Move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:'''assignment_participant.rb''')&lt;br /&gt;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We modified the camel-case variables in views/grade to Ruby convention by replacing them with under_score format while keeping the camel-case in JavaScript, as in JavaScript the camel-case should be its convention.&lt;br /&gt;
&lt;br /&gt;
*We set up new data structure Rscore to delegate the score and reduce the local variables.&lt;br /&gt;
&lt;br /&gt;
*We analysed the system and found out that polymorphism for Rscore is not necessary, encapsulation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We moved the calculations in the views into model file,'''assignment_participants.rb''', which follows the single responsibility principle and DRY principle.&lt;br /&gt;
&lt;br /&gt;
*We modified the response_map to expedite the rendering speed of showing scores.&lt;br /&gt;
&lt;br /&gt;
==Details of Implementation==&lt;br /&gt;
There are some calculations in the view of _participant.html.erb. The main function of these code is to curve the team's total score, which gets total_score from the instance variable of @pscore. The website utilizes the MVC design pattern to achieve a clean separation among three components(Model-View-Controller). However, these calculation in the code    According to MVC design pattern, &lt;br /&gt;
===Moving calculation from view to model===&lt;br /&gt;
====Why move calculation from view to model====&lt;br /&gt;
First, MVC-Model-View-Controller - is a design pattern for the architecture of web applications. It is a widely adopted pattern, across many languages and implementation frameworks, whose purpose is to achieve a clean separation between three components of most any web application. &lt;br /&gt;
&lt;br /&gt;
Second, more calculation in the view will decrease the speed and performance of the website.&lt;br /&gt;
&lt;br /&gt;
====The function of the calculation====&lt;br /&gt;
In the file of _participant.html.erb show all team's score. Before that, the view gets the total score from @pscore, and curves the total score in the view. &lt;br /&gt;
The calculation is in the /views/grades/_participant.html.erb. The main function is to curve the total score. We move these calculation into the method of  /model/assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
why use mvc&lt;br /&gt;
calculation's function &lt;br /&gt;
why put them in the model&lt;br /&gt;
&lt;br /&gt;
===OOP===&lt;br /&gt;
&lt;br /&gt;
===Encapsulation===&lt;br /&gt;
&lt;br /&gt;
In the original code, there are plenty of local variables such as min, max and avg. This not only ruins the readability of the code, but also tends to cause problem for future development. Since min, max and avg are the mostly used variables, we created a new data structure Rscore, which encapsulate all these three variables. Whenever we need the value of min, max and avg, we can get those from Rscore.&lt;br /&gt;
&lt;br /&gt;
In the project specification, it suggested that we use polymorphism to reduce the redundant local variables. However, we found that this simple data structure will suffice without bothering to use polymorphism, and it makes the code looks cleaner.&lt;br /&gt;
&lt;br /&gt;
What is more, pscore is a complicated data structure. It is a huge hash table, which contains at least two more level of hash tables in it. This situation makes polymorphism pretty hard to implement, since we can't do it without changing some basic structure of the design.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.(By removing all the calculations in the views to models)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1466_gjf&amp;diff=92327</id>
		<title>CSC/ECE 517 Fall 2014/OSS E1466 gjf</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/OSS_E1466_gjf&amp;diff=92327"/>
		<updated>2014-12-01T15:46:36Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Project Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1466: Refactoring GradesController==&lt;br /&gt;
&lt;br /&gt;
This wiki deals with our implementation of a controller in expertiza: &lt;br /&gt;
[https://github.com/expertiza/expertiza/blob/rails4/app/controllers/grades_controller.rb grade_controller]  for the Expertiza Project using Ruby on Rails.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.&lt;br /&gt;
&lt;br /&gt;
==Project Description==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Classes involved:''' grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''What it does:'''&lt;br /&gt;
&lt;br /&gt;
This class lists the grades of all the participants for an assignments and also their reviews. Instructor can edit scores, calculate penalties and send emails for conflicts.&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:'''&lt;br /&gt;
&lt;br /&gt;
*Modify '''calculate_all_penalties''' method which is too complex and long.&lt;br /&gt;
*Put the '''get_body_text''' method in a mailer rather than in the grades_controller.&lt;br /&gt;
*Refactor '''conflict_nofication''' method to '''conflict_email''' and make it delegated to the mailer. &lt;br /&gt;
*Refactor '''view_my_scores''' method to '''grades_show''' and delete the unnecessary variables.&lt;br /&gt;
*Try not to query for reviews and meta reviews in '''grades_show''' method.&lt;br /&gt;
&lt;br /&gt;
'''What we have done:'''&lt;br /&gt;
*Modify '''calculate_all_penalties''' method.&lt;br /&gt;
*Refactor the '''conflict_notification''' method to '''conflict_email''' method. &lt;br /&gt;
*Simplify sending email function and make it delegated to the mailer.&lt;br /&gt;
*Send a conflict email to the reviewer automatically when instructor click the button &amp;quot;email reviewer&amp;quot;.&lt;br /&gt;
*Remove '''get_body_text''' and '''send_grading_email''' method from grades_controller.&lt;br /&gt;
*Refactor '''conflict_nofication''' method to '''conflict_email''' and make it delegated to the mailer. &lt;br /&gt;
*Use Design Pattern Delegation in ConflictMailer.&lt;br /&gt;
*Refactor '''view_my_scores''' method to '''grades_show''' method.&lt;br /&gt;
*Search for the key reasons which lead to huge waiting time for getting score.&lt;br /&gt;
*Refactor '''get_assessments_for''' method in response_map.rb and lead to more than 90% off the current waiting time.&lt;br /&gt;
*Eliminate the search for reviews and meta reviews during the '''grades_show''' method.&lt;br /&gt;
*Delete unnecessary instance Variables.&lt;br /&gt;
&lt;br /&gt;
==Set Up Environment==&lt;br /&gt;
&lt;br /&gt;
===User Guide===&lt;br /&gt;
Current System (After Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.46.18.10:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
Original System (Before Refactoring Grades_controller):&lt;br /&gt;
&lt;br /&gt;
http://152.1.13.97:3000/&lt;br /&gt;
&lt;br /&gt;
 Instructor: user6 Password: test&lt;br /&gt;
&lt;br /&gt;
Student: user1600 and user1601 Password: test&lt;br /&gt;
&lt;br /&gt;
All our test result based on the following test cases on expertiza, please follow these step to get it.&lt;br /&gt;
&lt;br /&gt;
Instructor: (Searching &amp;quot;Program 2&amp;quot; using &amp;quot;Ctrl + F&amp;quot; will be convinient for you.)&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;view scores.&lt;br /&gt;
&lt;br /&gt;
Student:&lt;br /&gt;
&lt;br /&gt;
 Steps: Login -&amp;gt; Assignments-&amp;gt;Program 2 style -&amp;gt;Your scores.&lt;br /&gt;
&lt;br /&gt;
===Set Up Environment Locally===&lt;br /&gt;
====Get Expertiza from Github====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;git clone https://github.com/maxlpy/expertiza.git&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Use rvm to install ruby-2.1.0====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;curl -L https://get.rvm.io | bash -s stable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;source ~/.rvm/scripts/rvm&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;echo &amp;quot;source ~/.rvm/scripts/rvm&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm install 2.1.0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rvm use 2.1.0 --default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ruby -v&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Install Bundled Gems====&lt;br /&gt;
Set JAVA_HOME for the rjb gem:&lt;br /&gt;
Your path may be different. You can generally find out the path by looking at the symbolic link at /etc/alternatives/java&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;ls -la /etc/alternatives/java&amp;lt;/pre&amp;gt;&lt;br /&gt;
This outputs something like '/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java'. Only part of this path may need to be set to JAVA_HOME. In this instance, it is '/usr/lib/jvm/java-6-openjdk-amd64'.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;bundle install&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Set Up the Database====&lt;br /&gt;
=====Enable and Start the MySql Daemon=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld enable&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;sudo service mysqld start&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Set the MySql Root Password=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysqladmin -u root password&amp;lt;/pre&amp;gt;&lt;br /&gt;
=====Log in to MySql=====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;mysql -uroot -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Create the Databases====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:create:all&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Build the Expertiza Database====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rake db:migrate&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Start Expertiza service====&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space:normal;&amp;quot;&amp;gt;rails server&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code Modification==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== calculate_all_penalties Method===&lt;br /&gt;
====Summary====&lt;br /&gt;
&lt;br /&gt;
We have modified the calculate_penalties method and implemented all the functions it originally has. After our modification the method shrinks from 45 lines to 32 lines of Ruby code. Originally, the method includes a lot of unnecessary if and unless statements which makes the method uneasy to read and seems to have a difficult logic to calculate the penalties. &lt;br /&gt;
&lt;br /&gt;
According to the [https://codeclimate.com codeclimate] which calculate the complexity of the method, originally, it has a complexity of '''85''', however, after we modified it, the complexity goes down to '''65'''. Please check at [https://codeclimate.com/github/expertiza/expertiza/GradesController original version],[https://codeclimate.com/github/maxlpy/expertiza/GradesController modified version]&lt;br /&gt;
&lt;br /&gt;
We have done the following to the original methods:&lt;br /&gt;
&lt;br /&gt;
*Used for loop with selective choice to create penalty attributes and put it into the '''CalculatedPenalty''' Table, instead of duplicating the almost same code.&lt;br /&gt;
&lt;br /&gt;
*Used Object-Oriented Design patterns of Ruby: let the array respond to the method '''min''' which returns the minimum number in the array and get the logical penalty other than using if statement.(max_penalty if total_penalty is larger than max_penalty,  total_penalty if total_penalty is smaller than max_penalty)&lt;br /&gt;
&lt;br /&gt;
*Eliminated the unnecessary if statements to make the code clear to read.&lt;br /&gt;
&lt;br /&gt;
====Implementation====&lt;br /&gt;
&lt;br /&gt;
*Modify if statements:&lt;br /&gt;
&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 if(penalties[:submission].nil?)&lt;br /&gt;
      penalties[:submission]=0&lt;br /&gt;
 end&lt;br /&gt;
 if(penalties[:review].nil?)&lt;br /&gt;
      penalties[:review]=0&lt;br /&gt;
 end&lt;br /&gt;
 if(penalties[:meta_review].nil?)&lt;br /&gt;
      penalties[:meta_review]=0&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
penalties[:submission] = 0 if penalties[:submission].nil?&lt;br /&gt;
penalties[:review] = 0 if penalties[:review].nil?&lt;br /&gt;
penalties[:meta_review] = 0 if penalties[:meta_review].nil?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Using Objected-oriented Pattern&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 if(@total_penalty &amp;gt; l_policy.max_penalty)&lt;br /&gt;
      @total_penalty = l_policy.max_penalty&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @total_penality=[l_policy.max_penalty,@total_penality].min&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Using loops rather than duplicate same code&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 penalty_attr1 = {:deadline_type_id =&amp;gt; 1,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:submission]}&lt;br /&gt;
       CalculatedPenalty.create(penalty_attr1)&lt;br /&gt;
 penalty_attr2 = {:deadline_type_id =&amp;gt; 2,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:review]}&lt;br /&gt;
       CalculatedPenalty.create(penalty_attr2)&lt;br /&gt;
 penalty_attr3 = {:deadline_type_id =&amp;gt; 5,:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[:meta_review]}&lt;br /&gt;
       CalculatedPenalty.create(penalty_attr3)&amp;quot;&lt;br /&gt;
 @all_penalties[participant.id] = Hash.new&lt;br /&gt;
       @all_penalties[participant.id][:submission] = penalties[:submission]&lt;br /&gt;
       @all_penalties[participant.id][:review] = penalties[:review]&lt;br /&gt;
       @all_penalties[participant.id][:meta_review] = penalties[:meta_review]&lt;br /&gt;
       @all_penalties[participant.id][:total_penalty] = @total_penalty&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 deadline_type=[1,2,5]&lt;br /&gt;
 penalty_type=[:submission,:review,:meta_review]&lt;br /&gt;
 if calculate_for_participants&lt;br /&gt;
      for i in 0..2&lt;br /&gt;
           penalty_attr={:deadline_type_id=&amp;gt;deadline_type[i],:participant_id =&amp;gt; @participant.id, :penalty_points =&amp;gt; penalties[penalty_type[i]]}&lt;br /&gt;
           CalculatedPenalty.create(penalty_attr)&lt;br /&gt;
      end&lt;br /&gt;
 end&lt;br /&gt;
 @all_penalties[participant.id] = {}&lt;br /&gt;
      for i in 0..2&lt;br /&gt;
          @all_penalties[participant.id][:penalty_type[i]] = penalties[:penalty_type[i]]&lt;br /&gt;
      end&lt;br /&gt;
 @all_penalties[participant.id][:total_penalty] = @total_penalty&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== conflict_notification Method===&lt;br /&gt;
&lt;br /&gt;
====Summary====&lt;br /&gt;
We refactored the '''conflict_notification''' method to '''conflict_email''' method. When instructor click the button &amp;quot;email reviewer&amp;quot; whom he thought give a unfair review, the system should be able to send an email to the reviewer automatically.The '''get_body_text''' and '''send_grading_email''' were removed from the controller. The sending email function is well simplified and delegated to a conflict_mailer.&lt;br /&gt;
&lt;br /&gt;
====Design Pattern====&lt;br /&gt;
Delegation: The conflict_email should be able to send email. The class ConflictMailer works as its delegate .The conflict_email calls the send_conflict_email function to take the job of sending an email.&lt;br /&gt;
&lt;br /&gt;
UML: Draw UML graph for Grades_controller&lt;br /&gt;
&lt;br /&gt;
====Implementation====&lt;br /&gt;
The old '''conflict_notification''' action queries an email address list of a certain kind of reviews. In its view conflict_notifiction.html.erb, A email form contains email list for instructor to choose from and email content. &lt;br /&gt;
[[File:old_email.png]]&lt;br /&gt;
&lt;br /&gt;
'''Before Refactorring''', in conflict_notification:&lt;br /&gt;
First,Get the instructor email address as sender&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
      if session[:user].role_id !=6             &lt;br /&gt;
        @instructor = session[:user]&lt;br /&gt;
      else&lt;br /&gt;
        @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
      end&lt;br /&gt;
      @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
      @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then,Based on submission of review, the action query all the reviewers' email address  &lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
      @questions = Hash.new&lt;br /&gt;
      questionnaires = @assignment.questionnaires&lt;br /&gt;
      questionnaires.each {&lt;br /&gt;
        |questionnaire|&lt;br /&gt;
        @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
      }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The email list is for instructor to choose from. The process_response method queries the email address.    &lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
      @reviewers_email_hash = Hash.new            &lt;br /&gt;
      @caction = &amp;quot;view&amp;quot;&lt;br /&gt;
      @submission = params[:submission]&lt;br /&gt;
      if @submission == &amp;quot;review&amp;quot;&lt;br /&gt;
        @caction = &amp;quot;view_review&amp;quot;&lt;br /&gt;
        @symbol = &amp;quot;review&amp;quot;&lt;br /&gt;
        process_response(&amp;quot;Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.reviews, &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
      elsif @submission == &amp;quot;review_of_review&amp;quot;&lt;br /&gt;
        @symbol = &amp;quot;metareview&amp;quot;&lt;br /&gt;
        process_response(&amp;quot;Metareview&amp;quot;, &amp;quot;Metareviewer&amp;quot;, @participant.metareviews, &amp;quot;MetareviewQuestionnaire&amp;quot;)&lt;br /&gt;
      elsif @submission == &amp;quot;review_feedback&amp;quot;&lt;br /&gt;
        @symbol = &amp;quot;feedback&amp;quot;&lt;br /&gt;
        process_response(&amp;quot;Feedback&amp;quot;, &amp;quot;Author&amp;quot;, @participant.feedback, &amp;quot;AuthorFeedbackQuestionnaire&amp;quot;)&lt;br /&gt;
      elsif @submission == &amp;quot;teammate_review&amp;quot;&lt;br /&gt;
        @symbol = &amp;quot;teammate&amp;quot;&lt;br /&gt;
        process_response(&amp;quot;Teammate Review&amp;quot;, &amp;quot;Reviewer&amp;quot;, @participant.teammate_reviews, &amp;quot;TeammateReviewQuestionnaire&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The get_body_text method construct email content which should be removed from controller.&lt;br /&gt;
&amp;lt;pre&amp;gt;                                               &lt;br /&gt;
      @body = get_body_text(params[:submission])      &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The conflict_notification action requiring another two method &amp;quot;process_response&amp;quot; and &amp;quot;get_body_text&amp;quot; method to get the recipient email list and email content which contributes to extra complexity. The instructor only have to click the button &amp;quot;send email&amp;quot; in conflict_notifiction.html.erb and turn to send_conflict_email action, then he/she can send the email. If the instructor want to send another email, the process will repeat again,which will be terrible when reloading the &amp;quot;view&amp;quot; scores page.&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring''':The querying reviews actually have done in our show_reviews action, and we can get the individual reviewers' email address.In the reviewer table,we add extra button &amp;quot;email reviewer&amp;quot;.Now the instructor could send to reviewer email directly.&lt;br /&gt;
[[File:conflict_email.png]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In _review_table.html.erb,we add the link to send email. The review_id is passed to the conflict_email action taken as the recipient.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%= link_to 'email reviewer', :action =&amp;gt; 'conflict_email',:remote=&amp;gt; true,:reviewer_id=&amp;gt; &lt;br /&gt;
&lt;br /&gt;
review.map.reviewer.user,:participant_id=&amp;gt;participant,:score=&amp;gt;sprintf(&amp;quot;%.2f&amp;quot;,score) %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In our new '''conflict_email''' action:&lt;br /&gt;
&lt;br /&gt;
We still need the instructor as the sender &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      if session[:user].role_id !=6&lt;br /&gt;
        @instructor = session[:user]&lt;br /&gt;
      else&lt;br /&gt;
        @instructor = Ta.get_my_instructor(session[:user].id)&lt;br /&gt;
      end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The reviewer_id is passed from the link,we can query his/her email address to send the email &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      recipient=User.find(params[:reviewer_id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The responsibility of sending email has been delegated to a new mailer conflict_mailer. And the email content was constructed in the mailer.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      participant = AssignmentParticipant.find(params[:participant_id])&lt;br /&gt;
      assignment=Assignment.find(participant.parent_id)      &lt;br /&gt;
      score=params[:score]&lt;br /&gt;
      ConflictMailer.send_conflict_email(instructor,recipient,assignment,score).deliver&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Take a look at new conflict_mailer, it define a '''send_conflict_email''' method. the email was sent from sender's email and to reviewer's email.Some instance variables were used in view.&lt;br /&gt;
In conflict_mailer.erb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def send_conflict_email(sender,recipient,assignment,score)&lt;br /&gt;
      @assignment=assignment&lt;br /&gt;
      @recipient=recipient&lt;br /&gt;
      @score=score&lt;br /&gt;
      if recipient.role_id==1&lt;br /&gt;
        @role = &amp;quot;reviewer&amp;quot;&lt;br /&gt;
        @item = &amp;quot;submission&amp;quot;&lt;br /&gt;
      else&lt;br /&gt;
        @role = &amp;quot;metareviewer&amp;quot;&lt;br /&gt;
        @item = &amp;quot;review&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    mail subject: &amp;quot;Confliction Email&amp;quot;,from: sender.email,to: reviewer.email&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In its view send_conflict_email.txt.haml, we edit the email content.By this way, we deleted the '''get_body_text''' and well followed the rule of MVC design&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%h1=&amp;quot;Hi ,&amp;quot; +@recipient.name&lt;br /&gt;
&lt;br /&gt;
%p=&amp;quot;You submitted a score of &amp;quot;+@score+&amp;quot; for assignment &amp;quot;+@assignment.name+&amp;quot; that varied greatly from another &amp;quot;+@role+&amp;quot;'s score for the same &amp;quot;+@item+&amp;quot;.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
%p=&amp;quot;The Expertiza system has brought this to my attention.&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The link &amp;quot;email reviewer&amp;quot; request a ajax,so the current view page will not refresh when the action done&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      respond_to do |format|&lt;br /&gt;
        format.js&lt;br /&gt;
      end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If an email was successfully sent,The instructor should get the alert window by ajax.&lt;br /&gt;
[[File:email_sent.png]]&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores method===&lt;br /&gt;
&lt;br /&gt;
====Summary====&lt;br /&gt;
We refactored '''view_my_scores''' method to grades_show, deleted many unnecessary instance variables along with several review and meta reviews methods inside it. Therefore, the system will only search for scores in the database rather than search for scores and reviews, which wastes a lot of time during the grade show process. After refactoring, the complexity on this decreased from '''53''' to '''35'''.&lt;br /&gt;
We also optimize '''get_scores''' method to improve the efficiency of showing scores by students and instructors, which cost us most of the time during the project. After refactoring this method, the time cost of views in grade controller decreased by more than '''90%'''.&lt;br /&gt;
&lt;br /&gt;
We have done the following to the original methods:&lt;br /&gt;
&lt;br /&gt;
*Refactored '''view_my_scores''' method to '''grades_show''' method.&lt;br /&gt;
&lt;br /&gt;
*Searched for the key reasons which lead to huge waiting time for getting score.&lt;br /&gt;
&lt;br /&gt;
*Refactored '''get_assessments_for''' method in response_map.rb and lead to more than 90% off the current waiting time.&lt;br /&gt;
&lt;br /&gt;
*Eliminated the search for reviews during the '''grades_show''' method.&lt;br /&gt;
&lt;br /&gt;
*Deleted unnecessary instance Variables.&lt;br /&gt;
&lt;br /&gt;
====Implementation====&lt;br /&gt;
*Deleted the unnecessary instance variables&lt;br /&gt;
&lt;br /&gt;
Deleted Code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @average_score_results = Array.new&lt;br /&gt;
 @average_score_results = ScoreCache.get_class_scores(@participant.id)&lt;br /&gt;
 @statistics = Array.new&lt;br /&gt;
 @average_score_results.each { |x|&lt;br /&gt;
 @statistics &amp;lt;&amp;lt; x&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Deleted query for reviews and meta_reviews&lt;br /&gt;
&lt;br /&gt;
Deleted Code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @average_reviews = ScoreCache.get_reviews_average(@participant.id)&lt;br /&gt;
 @average_metareviews = ScoreCache.get_metareviews_average(@participant.id)&lt;br /&gt;
 @my_reviews = ScoreCache.my_reviews(@participant.id)&lt;br /&gt;
 @my_metareviews = ScoreCache.my_metareviews(@participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Add a new method into grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
Add Method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #show_reviews method gets reviews, meta reviews and author feedback information from server.&lt;br /&gt;
  def show_reviews&lt;br /&gt;
    @partial='grades/'+params[:path]&lt;br /&gt;
    @prefix=params[:prefix]&lt;br /&gt;
    @score=Hash.new&lt;br /&gt;
    @score[:assessments]=Array.new&lt;br /&gt;
    params[:score][:assessments].each do |assessment|&lt;br /&gt;
        @score[:assessments]&amp;lt;&amp;lt;Response.find(assessment)&lt;br /&gt;
    end&lt;br /&gt;
    @score[:scores]=params[:score][:scores]&lt;br /&gt;
    @participant=AssignmentParticipant.find(params[:participant])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = {}&lt;br /&gt;
    questionnaires = @assignment.questionnaires&lt;br /&gt;
    questionnaires.each do |questionnaire|&lt;br /&gt;
      @questions[questionnaire.symbol] = questionnaire.questions&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Change view_my_score.html.erb into show_reviews.html.erb in views.&lt;br /&gt;
&lt;br /&gt;
*Add in views(show_reviews.html.erb)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;%= render :partial=&amp;gt;@partial, :locals =&amp;gt; {:prefix =&amp;gt; @prefix, :participant =&amp;gt; @participant, :rscore =&amp;gt; @score} %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Test Result====&lt;br /&gt;
*The following test results based on the test case on Expertiza(Assignments: Program 2 style) &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[https://github.com/expertiza/expertiza Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
*[https://github.com/maxlpy/expertiza/blob/rails4/README.rdoc GradesController Readme File]&lt;br /&gt;
&lt;br /&gt;
*[https://www.youtube.com/watch?v=Md4NO6VjCn8&amp;amp;feature=youtu.be GradesController Video Instructions]&lt;br /&gt;
&lt;br /&gt;
*[http://152.46.18.10:3000/ Original Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
*[http://152.1.13.97:3000/ Expertiza Website After Refactoring]&lt;br /&gt;
&lt;br /&gt;
*[https://codeclimate.com/github/expertiza/expertiza/GradesController Original GradesController on CodeClimate]&lt;br /&gt;
&lt;br /&gt;
*[https://codeclimate.com/github/maxlpy/expertiza/GradesController  Modified GradesController on CodeClimate]&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92312</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92312"/>
		<updated>2014-11-29T02:36:10Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Speeding up viewing score function */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
*models/assignment_participant.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the model so that there won't be many calculations in the views of MVC framework.(Model file:assignment_participant.rb)&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up view score's function==&lt;br /&gt;
At the beginning of the final project, the function of viewing scores is very slow by students and instructor. Our team found the real factor which lead to the slow problem and solved it in an easy approach. &lt;br /&gt;
===Optimize response searching method in the model===&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92309</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92309"/>
		<updated>2014-11-29T02:22:20Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Test Result */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up viewing score function==&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Name&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Before Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| After Refactoring&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Reduced By&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92308</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92308"/>
		<updated>2014-11-29T02:21:34Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Speeding up viewing score function */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up viewing score function==&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Result===&lt;br /&gt;
|-&lt;br /&gt;
| View all team's score(instructor)&lt;br /&gt;
| 484988ms&lt;br /&gt;
| 8642ms&lt;br /&gt;
| 98.21%&lt;br /&gt;
|-&lt;br /&gt;
| View own score(student)&lt;br /&gt;
| 8941ms&lt;br /&gt;
| 651ms&lt;br /&gt;
| 92.71%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Original Time for Instructor to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_old.png‎|frame|center|Original Time for Instructor to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Instructor to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Instructor_new.png‎|frame|center|Time for Instructor to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
*Original Time for Student to View all scores&lt;br /&gt;
&lt;br /&gt;
[[File:Student_old.png‎|frame|center|Original Time for Student to View all scores]]&lt;br /&gt;
&lt;br /&gt;
*Time for Student to View all scores after Refactoring&lt;br /&gt;
&lt;br /&gt;
[[File:Student_new.png‎|frame|center|Time for Student to View all scores after Refactoring]]&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92307</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92307"/>
		<updated>2014-11-29T02:18:37Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Snapshots */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Speeding up viewing score function==&lt;br /&gt;
*Modify '''get_assessments_for''' method in response_map.rb&lt;br /&gt;
After doing this, the time cost of view function decreased by more than 90%&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # the original method to find all response &lt;br /&gt;
 @all_resp=Response.all&lt;br /&gt;
 for element in @all_resp&lt;br /&gt;
     if (element.map_id == map.map_id)&lt;br /&gt;
         @array_sort &amp;lt;&amp;lt; element&lt;br /&gt;
         @test &amp;lt;&amp;lt; map&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @all_resp=Response.find_by_map_id(map.map_id)&lt;br /&gt;
 @array_sort &amp;lt;&amp;lt; @all_resp&lt;br /&gt;
 @test &amp;lt;&amp;lt; map&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92306</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92306"/>
		<updated>2014-11-29T02:06:27Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Delegation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92305</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92305"/>
		<updated>2014-11-29T02:06:12Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Observer design pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Delegation===&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92304</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92304"/>
		<updated>2014-11-29T02:05:51Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Delegation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
This ensures that information is not repeated in the application. We use DRY Principle to design our object and modify all other work.&lt;br /&gt;
===Single Responsibility Principle===&lt;br /&gt;
This ensures that every controller and model method will be responsible in performing exactly one functionality.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92303</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92303"/>
		<updated>2014-11-29T01:52:03Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Use instance variables in views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92302</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92302"/>
		<updated>2014-11-29T01:51:16Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving Calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(views/grades/_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(model/assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92301</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92301"/>
		<updated>2014-11-29T01:50:25Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving Calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views to model.&lt;br /&gt;
&lt;br /&gt;
'''Before''':(_participant.html.erb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After''':(assignment_participant.rb)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92300</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92300"/>
		<updated>2014-11-29T01:48:58Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Moving Calculation from view to model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views(_participant.html.erb) to model(assignment_participant.rb).&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                 total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
        total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
        total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92299</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92299"/>
		<updated>2014-11-29T01:47:48Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Replacing Calculation in view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Moving Calculation from view to model==&lt;br /&gt;
We move lots of calculations from views(_participant.html.erb) to model(assignment_participant.rb).&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                  total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
             total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
             total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92298</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92298"/>
		<updated>2014-11-29T01:46:50Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Replacing Calculation in view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Replacing Calculation in view==&lt;br /&gt;
We move lots of calculations from views(_participant.html.erb) to model(assignment_participant.rb).&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                  total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
            &amp;lt;%end%&amp;gt;&lt;br /&gt;
 &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
             total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
             total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92297</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92297"/>
		<updated>2014-11-29T01:45:26Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Replacing Calculation in view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Replacing Calculation in view==&lt;br /&gt;
We move lots of calculations from views(_participant.html.erb) to model(assignment_participant.rb).&lt;br /&gt;
&lt;br /&gt;
Before:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                  total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
             &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
              &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
             total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
             total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92296</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92296"/>
		<updated>2014-11-29T01:45:09Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Replacing Calculation in view */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Replacing Calculation in view==&lt;br /&gt;
We move lots of calculations from views(_participant.html.erb) to model(assignment_participant.rb).&lt;br /&gt;
Before:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;% if controller.action_name == 'view' or controller.action_name == &amp;quot;view_my_scores&amp;quot; %&amp;gt;&lt;br /&gt;
    	&amp;lt;TD ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
    	&amp;lt;% if stage == &amp;quot;Finished&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;% if participant.grade&lt;br /&gt;
          total_score = participant.grade&lt;br /&gt;
          title = &amp;quot;A score in blue indicates that the value was overwritten by the instructor or teaching assistant.&amp;quot;&lt;br /&gt;
        else&lt;br /&gt;
          total_score = pscore[:total_score] &lt;br /&gt;
          title = nil&lt;br /&gt;
        end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;% hardline = 85&lt;br /&gt;
               if tr_avg &amp;gt; hardline&lt;br /&gt;
                 total_score = total_score + 0.05*total_score&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 40&lt;br /&gt;
                  total_score = total_score - 10&lt;br /&gt;
               elsif tr_avg &amp;lt; hardline and (hardline -tr_avg) &amp;gt; 20&lt;br /&gt;
                 total_score = total_score - (hardline -tr_avg)*0.5&lt;br /&gt;
            %&amp;gt;&lt;br /&gt;
             &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% if total_score&amp;gt;100&lt;br /&gt;
              total_score = 100&lt;br /&gt;
              %&amp;gt;&lt;br /&gt;
              &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &amp;lt;div &amp;lt;% if title %&amp;gt;title=&amp;quot;&amp;lt;%=title%&amp;gt;&amp;quot; style=&amp;quot;color:#0033FF&amp;quot;&amp;lt;% end %&amp;gt;&amp;gt;&amp;lt;%= sprintf(&amp;quot;%.2f&amp;quot;,total_score) %&amp;gt;&amp;lt;%= score_postfix %&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # move lots of calculation from view(_participant.html.erb) to model&lt;br /&gt;
    if self.grade&lt;br /&gt;
      scores[:total_score] = self.grade&lt;br /&gt;
    end&lt;br /&gt;
    else&lt;br /&gt;
      total_score = scores[:total_score]&lt;br /&gt;
      hardline = 85&lt;br /&gt;
      if scores[:teammate][:scores][:avg].to_f &amp;gt; hardline&lt;br /&gt;
        total_score = total_score + 0.05*total_score&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 40&lt;br /&gt;
             total_score = total_score - 10&lt;br /&gt;
      elsif scores[:teammate][:scores][:avg].to_f &amp;lt; hardline and (hardline - scores[:teammate][:scores][:avg].to_f) &amp;gt; 20&lt;br /&gt;
             total_score = total_score - (hardline - scores[:teammate][:scores][:avg].to_f)*0.5&lt;br /&gt;
      end&lt;br /&gt;
      if total_score &amp;gt; 100&lt;br /&gt;
        total_score = 100&lt;br /&gt;
      end&lt;br /&gt;
      scores[:total_score] = total_score&lt;br /&gt;
    scores&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92295</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92295"/>
		<updated>2014-11-29T01:40:02Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Objected Oriented Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Replacing Calculation in view==&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92294</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92294"/>
		<updated>2014-11-29T01:36:21Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Create object to avoid local variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create rscore class in models (rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92293</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92293"/>
		<updated>2014-11-29T01:35:59Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Create object to avoid local variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create Rscore class in models (Rscore.rb):  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92292</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92292"/>
		<updated>2014-11-29T01:34:20Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Create object to avoid local variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
Create Rscore class in models:  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92291</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92291"/>
		<updated>2014-11-29T01:29:55Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Use instance variables in views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92290</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92290"/>
		<updated>2014-11-29T01:24:54Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Use instance variables in views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
In grades/_participant.html.erb, we create an object that has max, min, and avg fields for each kind of reviews, and pass the kind of review when referring to a max, min, or avg field.&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92289</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92289"/>
		<updated>2014-11-29T01:22:15Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Use instance variables in views */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
'''Before:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
  	s_max = pscore[:review][:scores][:max]&lt;br /&gt;
  	s_min = pscore[:review][:scores][:min] &lt;br /&gt;
  	s_avg = pscore[:review][:scores][:avg] &lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    r_max = pscore[:metareview][:scores][:max]&lt;br /&gt;
  	r_min = pscore[:metareview][:scores][:min] &lt;br /&gt;
  	r_avg = pscore[:metareview][:scores][:avg]&lt;br /&gt;
  end &lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
  	f_max = pscore[:feedback][:scores][:max]&lt;br /&gt;
  	f_min = pscore[:feedback][:scores][:min] &lt;br /&gt;
  	f_avg = pscore[:feedback][:scores][:avg]&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
  	tr_max = pscore[:teammate][:scores][:max]&lt;br /&gt;
  	tr_min = pscore[:teammate][:scores][:min] &lt;br /&gt;
  	tr_avg = pscore[:teammate][:scores][:avg]   &lt;br /&gt;
  end &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''After:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92288</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92288"/>
		<updated>2014-11-29T01:19:35Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Create object to avoid local variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92287</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92287"/>
		<updated>2014-11-29T01:19:22Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Create object to avoid local variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use instance variables in views&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  if pscore[:review]&lt;br /&gt;
    @rscore_review=Rscore.new(pscore,:review)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:metareview]&lt;br /&gt;
    @rscore_metareview=Rscore.new(pscore,:metareview)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:feedback]&lt;br /&gt;
    @rscore_feedback=Rscore.new(pscore,:feedback)&lt;br /&gt;
  end&lt;br /&gt;
  if pscore[:teammate]&lt;br /&gt;
    @rscore_teammate=Rscore.new(pscore,:teammate)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92286</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92286"/>
		<updated>2014-11-29T01:15:38Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Objected Oriented Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
===Create object to avoid local variables===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92285</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92285"/>
		<updated>2014-11-29T01:12:02Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Objected Oriented Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Rscore&lt;br /&gt;
  attr_accessor :my_max,:my_min,:my_avg,:my_type&lt;br /&gt;
&lt;br /&gt;
  def initialize(my_score,type)&lt;br /&gt;
    @my_max=my_score[type][:scores][:max]&lt;br /&gt;
    @my_min=my_score[type][:scores][:min]&lt;br /&gt;
    @my_avg=my_score[type][:scores][:avg]&lt;br /&gt;
    @my_type=type&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92284</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92284"/>
		<updated>2014-11-29T01:11:13Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Objected Oriented Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern and System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===MVC design pattern===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
===Observer design pattern===&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
asdfasfd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92265</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92265"/>
		<updated>2014-11-22T18:37:17Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* System Architecture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
**There are percentage calculation and question scores in the _scores_author_feedback.html.erb file&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern and Principles ==&lt;br /&gt;
&lt;br /&gt;
For this project, we will use the MVC design pattern. Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application (such as web application) into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Components===&lt;br /&gt;
&lt;br /&gt;
The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.&lt;br /&gt;
&lt;br /&gt;
===Interactions===&lt;br /&gt;
&lt;br /&gt;
In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.&lt;br /&gt;
&lt;br /&gt;
*A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).&lt;br /&gt;
*A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be &amp;quot;passive,&amp;quot; so that other components must poll the model for updates rather than being notified.&lt;br /&gt;
*A view requests information from the model that it uses to generate an output representation to the user.&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza003.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===Views===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza003.png&amp;diff=92264</id>
		<title>File:Expertiza003.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza003.png&amp;diff=92264"/>
		<updated>2014-11-22T18:35:54Z</updated>

		<summary type="html">&lt;p&gt;Pli5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92259</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92259"/>
		<updated>2014-11-22T18:01:22Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Files Involved */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern and Principles ==&lt;br /&gt;
&lt;br /&gt;
For this project, we will use the MVC design pattern. Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application (such as web application) into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above diagram is an architecture of the MVC model with 3 components, and the interaction among them.&lt;br /&gt;
&lt;br /&gt;
===Components===&lt;br /&gt;
&lt;br /&gt;
The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.&lt;br /&gt;
&lt;br /&gt;
===Interactions===&lt;br /&gt;
&lt;br /&gt;
In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.&lt;br /&gt;
&lt;br /&gt;
*A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).&lt;br /&gt;
*A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be &amp;quot;passive,&amp;quot; so that other components must poll the model for updates rather than being notified.&lt;br /&gt;
*A view requests information from the model that it uses to generate an output representation to the user.&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza002.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===Views===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92258</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92258"/>
		<updated>2014-11-22T17:56:55Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* System Architecture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern and Principles ==&lt;br /&gt;
&lt;br /&gt;
For this project, we will use the MVC design pattern. Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application (such as web application) into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above diagram is an architecture of the MVC model with 3 components, and the interaction among them.&lt;br /&gt;
&lt;br /&gt;
===Components===&lt;br /&gt;
&lt;br /&gt;
The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.&lt;br /&gt;
&lt;br /&gt;
===Interactions===&lt;br /&gt;
&lt;br /&gt;
In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.&lt;br /&gt;
&lt;br /&gt;
*A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).&lt;br /&gt;
*A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be &amp;quot;passive,&amp;quot; so that other components must poll the model for updates rather than being notified.&lt;br /&gt;
*A view requests information from the model that it uses to generate an output representation to the user.&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza002.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===Views===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza002.png&amp;diff=92257</id>
		<title>File:Expertiza002.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza002.png&amp;diff=92257"/>
		<updated>2014-11-22T17:56:31Z</updated>

		<summary type="html">&lt;p&gt;Pli5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92256</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92256"/>
		<updated>2014-11-22T17:54:55Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* System Architecture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
'''Calculations Found in Views''':&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern and Principles ==&lt;br /&gt;
&lt;br /&gt;
For this project, we will use the MVC design pattern. Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application (such as web application) into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above diagram is an architecture of the MVC model with 3 components, and the interaction among them.&lt;br /&gt;
&lt;br /&gt;
===Components===&lt;br /&gt;
&lt;br /&gt;
The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.&lt;br /&gt;
&lt;br /&gt;
===Interactions===&lt;br /&gt;
&lt;br /&gt;
In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.&lt;br /&gt;
&lt;br /&gt;
*A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).&lt;br /&gt;
*A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be &amp;quot;passive,&amp;quot; so that other components must poll the model for updates rather than being notified.&lt;br /&gt;
*A view requests information from the model that it uses to generate an output representation to the user.&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza001.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===Views===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_2.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 100%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
|-&lt;br /&gt;
| Admin&lt;br /&gt;
| This actor has the same responsibility as Instructor along with the ability to create instructor(however, this is not our concern here).&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor/ Teaching Assistant/ Admin views the list of teams scores || Instructor/ Teaching Assistant/ Admin || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza001.png&amp;diff=92255</id>
		<title>File:Expertiza001.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza001.png&amp;diff=92255"/>
		<updated>2014-11-22T17:54:26Z</updated>

		<summary type="html">&lt;p&gt;Pli5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza_Architecture.png&amp;diff=92254</id>
		<title>File:Expertiza Architecture.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Expertiza_Architecture.png&amp;diff=92254"/>
		<updated>2014-11-22T17:52:45Z</updated>

		<summary type="html">&lt;p&gt;Pli5: uploaded a new version of &amp;amp;quot;File:Expertiza Architecture.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92244</id>
		<title>CSC/ECE 517 Fall 2014/final E1472 gjfz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92244"/>
		<updated>2014-11-21T21:33:02Z</updated>

		<summary type="html">&lt;p&gt;Pli5: /* Files Involved */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Design Document==&lt;br /&gt;
'''E1472: Connect changes to score model with changes to score views'''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities. One of the Expertiza features is to report scores to both students and the instructor. The student can see the feedback from other students, such as the max score, the min score and the average score.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===A way to query db models to return scores, without UI changes===&lt;br /&gt;
&lt;br /&gt;
These methods report grades to students and instructors.  The view method reports everyone’s grades to an instructor, and the view_my_scores method reports peer-review scores to a student. This code is very slow, due to many factors.  Two of the most prominent are the fact that separate db queries are used for each rubric that has been filled out by anyone associated with the assignment; these queries are made sequentially while the HTML page is being written; and the fact that HTML for the whole page is generated, largely by controller methods, before anything is displayed. &lt;br /&gt;
&lt;br /&gt;
===UI changes for reporting scores===&lt;br /&gt;
&lt;br /&gt;
The grades_controller class is responsible for displaying grades to students (via view_my_scores) and instructors or Teaching Assistant (via the view method).&lt;br /&gt;
We will modify the Score class, and reduce the number of variables in order to remove code duplication and improve the loading speed.&lt;br /&gt;
&lt;br /&gt;
===What we need to do===&lt;br /&gt;
*Remove the get_ and set_ accessor names; just use Ruby accessors.&lt;br /&gt;
*Change camel-case vs. underscores to match the Ruby convention.&lt;br /&gt;
*In grades/_participant.html.erb, don’t create local variables in the view; rather, create an object that has max, min, and avg fields for each kind of reviews.  Try to avoid the need to check review type; instead, just pass the kind of review when referring to a max, min, or avg field and use polymorphism.&lt;br /&gt;
*Also, you shouldn't have to check for the existence topic in the view; if it is null, a null string should just be returned.&lt;br /&gt;
*There are lots of calculations in the views, which should be moved to the model.&lt;br /&gt;
&lt;br /&gt;
===Files Involved===&lt;br /&gt;
'''Model''':&lt;br /&gt;
*models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*models/rscore.rb&lt;br /&gt;
&lt;br /&gt;
'''Controller''':&lt;br /&gt;
*grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
'''View''':&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_author_feedback.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_metareview.html.erb&lt;br /&gt;
&lt;br /&gt;
*grades/_scores_submitted_work.html.erb&lt;br /&gt;
&lt;br /&gt;
===What we are going to do===&lt;br /&gt;
&lt;br /&gt;
*We will modify the setters and getters in the models/participant.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the camel-case variables to underscores to match the Ruby convention in views/grades/... , models/participant.rb and controllers/grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
*Modify the data structure of the score, instead of using pScore which contains lots of hash tables in it, we set up a new object, '''Rscore''', which only consists of max, min and average fields of each reviews. Also, using inheritance to implement this data structure to avoid check review type. &lt;br /&gt;
&lt;br /&gt;
*We will also move the calculations in the views to the controller so that there won't be many calculations in the views of MVC framework.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern and Principles ==&lt;br /&gt;
&lt;br /&gt;
For this project, we will use the MVC design pattern. Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application (such as web application) into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above diagram is an architecture of the MVC model with 3 components, and the interaction among them.&lt;br /&gt;
&lt;br /&gt;
===Components===&lt;br /&gt;
&lt;br /&gt;
The central component of MVC, the model, captures the behavior of the application in terms of its problem domain, independent of the user interface. The model directly manages the data, logic and rules of the application. A view can be any output representation of information, such as a chart or a diagram; multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants. The third part, the controller, accepts input and converts it to commands for the model or view.&lt;br /&gt;
&lt;br /&gt;
===Interactions===&lt;br /&gt;
&lt;br /&gt;
In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.&lt;br /&gt;
&lt;br /&gt;
*A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).&lt;br /&gt;
*A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be &amp;quot;passive,&amp;quot; so that other components must poll the model for updates rather than being notified.&lt;br /&gt;
*A view requests information from the model that it uses to generate an output representation to the user.&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Expertiza Architecture.png‎|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
===Views===&lt;br /&gt;
Responsibility of view_my_scores html.erb is to display all the scores with respect to a participant and an assignment. For achieving optimal functionality, a good amount of refactoring had to be done in the views that were responsible for displaying the results to a user.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in other controller class, the grades_controller specifically has two more important methods: view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
*'''view method''': handle the functionality of viewing the assignments of the whole class. Understandably, this is done through an admin/instructor's profile as only they have the privilege of viewing all participants' scores.&lt;br /&gt;
&lt;br /&gt;
*'''view_my_scores''': take care of displaying the scores pertaining to an assignment to a single user.&lt;br /&gt;
&lt;br /&gt;
===Models===&lt;br /&gt;
Scores.rb has two methods which are responsible to compute scores for the participants based on assignments and courses.&lt;br /&gt;
&lt;br /&gt;
*'''get_total_scores()''' method: make multiple sequential queries to the database to calculate scores. &lt;br /&gt;
&lt;br /&gt;
*Model class PartcipantScores.rb and AssignmentScores.rb have been created to retrieve the scores for participant and assignment respectively.&lt;br /&gt;
&lt;br /&gt;
== Use Case==&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
The figure above mainly illustrates the process of viewing scores for different actors. The instructor and teaching assistant are able to view scores of all the team and could see the reviews of a selected team. Student actor can see his own scores and reviews.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;font-size: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.25em;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Actor&lt;br /&gt;
!style=&amp;quot;background:#eFeFeF;&amp;quot;| Description&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Instructor&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of all the students(teams).&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for viewing scores and reviews of his own or of his team. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table is showing the use case of different users of the expertiza and how they interact with it. For example, when a student want to view his/her grades, there must be something in the database (precondition). He will need to login, and choose one of the assignments which he want to view grade on. He can also see the review of his work.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! Other Participants || Precondition || Primary Sequence&lt;br /&gt;
|-&lt;br /&gt;
| Student views his team score || Student || None || At least team's score exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| TA views teams' review || TA || None||At least team's review exists. || &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select Your Scores button from an Assignment menu&lt;br /&gt;
*Select show_review in score page&lt;br /&gt;
|-&lt;br /&gt;
| Instructor or Teaching Assistant views the list of teams scores || Instructor or Teaching Assistant || None || At least one team's score exists.|| &lt;br /&gt;
*Log in to Expertiza&lt;br /&gt;
*Choose Assignment from multiple Assignments&lt;br /&gt;
*Select View Scores button from an Assignment menu&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;br /&gt;
&lt;br /&gt;
The following class diagram shows a combination of new and existing classes along with the attributes and operations that are relevant to the implementation of this solution. &lt;br /&gt;
[[File:Objected Oriented Design.png|frame|center|]]&lt;br /&gt;
The RScore class stores the variables maximum,minimum, average review scores. Different type of reviews score is declared as subclass of RScore using ploymorphism. The type field is specified in their initialize method.&lt;br /&gt;
&lt;br /&gt;
==Snapshots==&lt;br /&gt;
===Instructor Login===&lt;br /&gt;
[[File:Screens1.png|frame|center|]]&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
[[File:Screens3.png|frame|center|]]&lt;br /&gt;
===View Scores===&lt;br /&gt;
[[File:Screens4.png|frame|center|]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E804_spb ''Wiki page for E804'']&lt;br /&gt;
&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2013/oss_E805_kkn ''Wiki page for E805'']&lt;br /&gt;
&lt;br /&gt;
[https://github.com/ajain2709/expertiza ''Github link for E912'']&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
&lt;br /&gt;
We will stick to the UI design of the grades view and see what else we can do to further improve the performance of the system. We are trying to figure out other reasons that may lead to the bad performance in addition to the two main reasons mentioned and solved in E804 and E805 projects.&lt;/div&gt;</summary>
		<author><name>Pli5</name></author>
	</entry>
</feed>