<?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=Sxu11</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=Sxu11"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sxu11"/>
	<updated>2026-06-15T01:08:11Z</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=92536</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=92536"/>
		<updated>2014-12-05T02:20:26Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Encapsulation */&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 encapsulated all these three variables. Whenever we need the value of min, max and avg, we can get those directly 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 look cleaner.&lt;br /&gt;
&lt;br /&gt;
Furthermore, '''pscore''' is a complicated data structure. It consists of huge hash tables, with each hash table contains another hash table as its value. This situation makes polymorphism pretty hard to implement,if we are not allowed to modify the data structure of the score, which is the  basic structure of the system.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92534</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=92534"/>
		<updated>2014-12-05T02:17:21Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Encapsulation */&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 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92529</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=92529"/>
		<updated>2014-12-05T02:10:27Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we need to do */&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.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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92516</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=92516"/>
		<updated>2014-12-04T14:38:53Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* See Also */&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92511</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=92511"/>
		<updated>2014-12-04T05:51:20Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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 &amp;quot;Requirement for E1472&amp;quot;]&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92510</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=92510"/>
		<updated>2014-12-04T05:50:58Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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 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;
*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 &amp;quot;Requirement for E1472&amp;quot;]&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92374</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=92374"/>
		<updated>2014-12-03T22:45:28Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
*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 &amp;quot;Requirement for E1472&amp;quot;]&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92373</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=92373"/>
		<updated>2014-12-03T16:34:55Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* See Also */&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;
[https://docs.google.com/document/d/1ncwlrTEZ1taP6ZvMc_GqP4jcAchE03zXSnZwvzgfeDw/edit?usp=sharing &amp;quot;Requirement for E1472&amp;quot;]&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92347</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=92347"/>
		<updated>2014-12-03T02:05:10Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* User Guide */&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;
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;
Second, more calculation in the view will decrease the speed and performance of client terminal.&lt;br /&gt;
&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;
==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;
===Encapsulation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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 put all these three variables together. &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;
What is more, pscore is a complicated data structure, it is a huge hash table, which contains at least two more hash tables in it.&lt;br /&gt;
This situation makes polymorphism not only hard to implement, but also&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92345</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=92345"/>
		<updated>2014-12-03T02:03:55Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Introduction */&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.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;
== 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;
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;
Second, more calculation in the view will decrease the speed and performance of client terminal.&lt;br /&gt;
&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;
==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;
===Encapsulation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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 put all these three variables together. &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;
What is more, pscore is a complicated data structure, it is a huge hash table, which contains at least two more hash tables in it.&lt;br /&gt;
This situation makes polymorphism not only hard to implement, but also&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92343</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=92343"/>
		<updated>2014-12-03T02:01:34Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
*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;
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;
Second, &lt;br /&gt;
&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;
==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;
===Encapsulation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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 put all these three variables together. &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;
What is more, pscore is a complicated data structure, it is a huge hash table, which contains at least two more hash tables in it.&lt;br /&gt;
This situation makes polymorphism not only hard to implement, but also&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92326</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=92326"/>
		<updated>2014-11-29T04:44:29Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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;
*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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92325</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=92325"/>
		<updated>2014-11-29T04:44:09Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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 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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92324</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=92324"/>
		<updated>2014-11-29T04:43:00Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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;
*Modify getter methods in models&lt;br /&gt;
&lt;br /&gt;
*delete checking for topics in views&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;
===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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92323</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=92323"/>
		<updated>2014-11-29T03:39:59Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
===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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92322</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=92322"/>
		<updated>2014-11-29T03:38:40Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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;
===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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92321</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=92321"/>
		<updated>2014-11-29T03:38:24Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
&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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92320</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=92320"/>
		<updated>2014-11-29T03:38:05Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* MVC 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;
*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;
&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, delegation 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;
==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;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92319</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=92319"/>
		<updated>2014-11-29T03:37:17Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* DRY Principle */&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;
&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, delegation 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;
==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.(By setting up Rscore data structure)&lt;br /&gt;
&lt;br /&gt;
===Delegation===&lt;br /&gt;
Set up a new data structure, Rscore, and use this data structure to delegate score in all the views.&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92317</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=92317"/>
		<updated>2014-11-29T03:22:25Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Single Responsibility Principle */&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;
&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, delegation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We removed 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;
==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.(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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92316</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=92316"/>
		<updated>2014-11-29T03:21:35Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
&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, delegation will handle all the usages.&lt;br /&gt;
&lt;br /&gt;
*We removed 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;
==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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92315</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=92315"/>
		<updated>2014-11-29T03:20:20Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
&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, delegation will handle all the usages.&lt;br /&gt;
&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 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92314</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=92314"/>
		<updated>2014-11-29T03:18:36Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we have done */&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;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We have 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;
*&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92313</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=92313"/>
		<updated>2014-11-29T03:16:58Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Requirements */&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;
&lt;br /&gt;
===What we have done===&lt;br /&gt;
&lt;br /&gt;
*We have modified the camel-case variables in views/grade to Ruby convention using under_score while keeping the camel-case&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92311</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=92311"/>
		<updated>2014-11-29T02:34:02Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* 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;
&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 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92310</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=92310"/>
		<updated>2014-11-29T02:33:15Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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 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 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92253</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=92253"/>
		<updated>2014-11-22T17:40:38Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* 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;
&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_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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92252</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=92252"/>
		<updated>2014-11-22T17:35:15Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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_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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92251</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=92251"/>
		<updated>2014-11-22T17:31:50Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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_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: 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;
| 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92250</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=92250"/>
		<updated>2014-11-22T17:30:38Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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_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: 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;
| 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 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92249</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=92249"/>
		<updated>2014-11-22T17:29:13Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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_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: 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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Use_case_2.png&amp;diff=92248</id>
		<title>File:Use case 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Use_case_2.png&amp;diff=92248"/>
		<updated>2014-11-22T17:28:34Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92230</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=92230"/>
		<updated>2014-11-19T05:37:17Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Design Document */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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;
&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:uml.png |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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92229</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=92229"/>
		<updated>2014-11-19T05:35:52Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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;
&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:uml.png |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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92228</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=92228"/>
		<updated>2014-11-19T05:35:41Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* What we are going to do */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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;
&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:uml.png |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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92221</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=92221"/>
		<updated>2014-11-19T05:27:03Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Future Work */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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 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 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;
&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|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:uml.png |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:Screens3.png]]&lt;br /&gt;
&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
===View Scores===&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>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92220</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=92220"/>
		<updated>2014-11-19T05:26:42Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Future Work */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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 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 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;
&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|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:uml.png |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:Screens3.png]]&lt;br /&gt;
&lt;br /&gt;
===Select Assignment===&lt;br /&gt;
===View Scores===&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 E814 and E815 projects.&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92200</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=92200"/>
		<updated>2014-11-19T05:16:06Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* See Also */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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 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;
==System Architecture==&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;
[[File:usecase_score.png|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;
== Design Pattern and Principle ==&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;
[[File:MVC-Process.png|center|]]&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;
==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:uml.png |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;
== 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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92199</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=92199"/>
		<updated>2014-11-19T05:13:42Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Requirements */&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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
*models/participant.rb&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 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;
==System Architecture==&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;
[[File:usecase_score.png|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;
== Design Pattern and Principle ==&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;
[[File:MVC-Process.png|center|]]&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;
==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:uml.png |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;
== 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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92192</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=92192"/>
		<updated>2014-11-19T04:49:54Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* 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 GradesController 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;
*grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
*grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&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. A couple of problems were that:&lt;br /&gt;
&lt;br /&gt;
*In the original expertiza application, all the reviews given to a user were listed one after another and this made finding a particular review very difficult.&lt;br /&gt;
&lt;br /&gt;
*Also, when an admin clicked on view scores for an assignment, the time overhead to display the assignments was too high and this had to be taken care of.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in every controller class, the grades_controller specifically has two more methods:view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
====view====&lt;br /&gt;
&lt;br /&gt;
The 'view' method is responsible for handling 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====&lt;br /&gt;
&lt;br /&gt;
The 'view_my_scores' method takes care of displaying the scores pertaining to an assignment to a single user. &lt;br /&gt;
&lt;br /&gt;
In the controller methods, some amount of code pertaining to views too was initially coded. This code was refactored and made central to the views only so as to avoid duplication.&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;
Method get_total_scores() was making multiple sequential queries to the database to calculate scores. This method has been modified to retrieve data from a view. This view has been created in the database by migration “CreateMyViews”. Also, a new method ubmission_valid?' has been created to check whether the review is valid or not. This functionality was previously included in get_total_scores().&lt;br /&gt;
&lt;br /&gt;
New model classes 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;
[[File:usecase_score.png|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;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! other paticipants || 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;
== Design Pattern and Principle ==&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;
[[File:MVC-Process.png|center|]]&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;
==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:uml.png |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;
== 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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=92190</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=92190"/>
		<updated>2014-11-19T04:49:37Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Requirements */&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 GradesController 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;
1.grades_controller.rb.&lt;br /&gt;
2.grades/_participant.html.erb&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&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. A couple of problems were that:&lt;br /&gt;
&lt;br /&gt;
*In the original expertiza application, all the reviews given to a user were listed one after another and this made finding a particular review very difficult.&lt;br /&gt;
&lt;br /&gt;
*Also, when an admin clicked on view scores for an assignment, the time overhead to display the assignments was too high and this had to be taken care of.&lt;br /&gt;
&lt;br /&gt;
===Controllers===&lt;br /&gt;
Apart from the template methods that are present in every controller class, the grades_controller specifically has two more methods:view and view_my_scores.&lt;br /&gt;
&lt;br /&gt;
====view====&lt;br /&gt;
&lt;br /&gt;
The 'view' method is responsible for handling 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====&lt;br /&gt;
&lt;br /&gt;
The 'view_my_scores' method takes care of displaying the scores pertaining to an assignment to a single user. &lt;br /&gt;
&lt;br /&gt;
In the controller methods, some amount of code pertaining to views too was initially coded. This code was refactored and made central to the views only so as to avoid duplication.&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;
Method get_total_scores() was making multiple sequential queries to the database to calculate scores. This method has been modified to retrieve data from a view. This view has been created in the database by migration “CreateMyViews”. Also, a new method ubmission_valid?' has been created to check whether the review is valid or not. This functionality was previously included in get_total_scores().&lt;br /&gt;
&lt;br /&gt;
New model classes 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;
[[File:usecase_score.png|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;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Student views his team's review by other students&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
'''Name:''' TA views teams' review&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' TA&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's review exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant views the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Actor !! other paticipants || 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;
== Design Pattern and Principle ==&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;
[[File:MVC-Process.png|center|]]&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;
==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:uml.png |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;
== 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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91631</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=91631"/>
		<updated>2014-11-10T23:39:50Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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;
==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 GradesController 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;
== Use Case==&lt;br /&gt;
[[File:usecase_score.png|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;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Student views his team's review by other students&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant views the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==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:uml.png |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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91630</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=91630"/>
		<updated>2014-11-10T23:39:09Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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;
==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 GradesController 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;
== Use Case==&lt;br /&gt;
[[File:usecase_score.png|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;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Student views his team's review by other students&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==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:uml.png |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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91629</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=91629"/>
		<updated>2014-11-10T23:37:40Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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;
==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 GradesController 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;
== Use Case==&lt;br /&gt;
[[File:usecase_score.png|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;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==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:uml.png |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;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91628</id>
		<title>CSC/ECE 517 Fall 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91628"/>
		<updated>2014-11-10T23:07:25Z</updated>

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

		<summary type="html">&lt;p&gt;Sxu11: /* a */&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;
==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;
This class is responsible for displaying grades to students (via view_my_scores) and instructors (via the view method). &lt;br /&gt;
===What we should 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;
== Use Case==&lt;br /&gt;
[[File:UseCase.png |center|]]&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
===a===&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;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
===b===&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91588</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=91588"/>
		<updated>2014-11-10T00:16:22Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* a */&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;
==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;
This class is responsible for displaying grades to students (via view_my_scores) and instructors (via the view method). &lt;br /&gt;
===What we should 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;
== Use Case==&lt;br /&gt;
[[File:UseCase.png |center|]]&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
===a===&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 commenting and voting on the suggested topic and making decision to approve or reject thesuggestion.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Teaching Assistant&lt;br /&gt;
| This actor is responsible for commenting and voting ones preferences on the suggested topic.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Student&lt;br /&gt;
| This actor is responsible for making suggestions for a topic or question for class exercise. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
===b===&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91587</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=91587"/>
		<updated>2014-11-10T00:08:40Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* a */&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;
==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;
This class is responsible for displaying grades to students (via view_my_scores) and instructors (via the view method). &lt;br /&gt;
===What we should 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;
== Use Case==&lt;br /&gt;
[[File:UseCase.png |center|]]&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
===a===&lt;br /&gt;
'''Name:''' Student views his team score&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Student&lt;br /&gt;
&lt;br /&gt;
'''Other Participants:''' None&lt;br /&gt;
&lt;br /&gt;
'''Precondition:''' At least team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence:'''&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;
&lt;br /&gt;
===b===&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91586</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=91586"/>
		<updated>2014-11-10T00:07:28Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* a */&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;
==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;
This class is responsible for displaying grades to students (via view_my_scores) and instructors (via the view method). &lt;br /&gt;
===What we should 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;
== Use Case==&lt;br /&gt;
[[File:UseCase.png |center|]]&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
===a===&lt;br /&gt;
Name: Student views his team score&lt;br /&gt;
Actor: Student&lt;br /&gt;
Other Participants: None&lt;br /&gt;
Precondition: At least team's score exists.&lt;br /&gt;
Primary Sequence:&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;
[edit]&lt;br /&gt;
&lt;br /&gt;
===b===&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_E1472_gjfz&amp;diff=91585</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=91585"/>
		<updated>2014-11-10T00:04:51Z</updated>

		<summary type="html">&lt;p&gt;Sxu11: /* Use Case */&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;
==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;
This class is responsible for displaying grades to students (via view_my_scores) and instructors (via the view method). &lt;br /&gt;
===What we should 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;
== Use Case==&lt;br /&gt;
[[File:UseCase.png |center|]]&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
===a===&lt;br /&gt;
&lt;br /&gt;
===b===&lt;br /&gt;
'''Name''': Instructor or Teaching Assistant viewing the list of teams scores&lt;br /&gt;
&lt;br /&gt;
'''Actor''': Instructor or Teaching Assistant&lt;br /&gt;
&lt;br /&gt;
'''Other Participants''': None&lt;br /&gt;
&lt;br /&gt;
'''Precondition''': At least one team's score exists.&lt;br /&gt;
&lt;br /&gt;
'''Primary Sequence''':&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;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Objected Oriented Design==&lt;/div&gt;</summary>
		<author><name>Sxu11</name></author>
	</entry>
</feed>