<?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=Nsingh9</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=Nsingh9"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Nsingh9"/>
	<updated>2026-05-09T20:34:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106371</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106371"/>
		<updated>2016-12-03T03:51:00Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* How reviewing times get recorded in the database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 5 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
* In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub student user and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
require 'rails_helper' &lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106282</id>
		<title>File:Rspec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106282"/>
		<updated>2016-12-03T01:55:37Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: uploaded a new version of &amp;amp;quot;File:Rspec.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;testing rspec file&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106281</id>
		<title>File:Rspec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106281"/>
		<updated>2016-12-03T01:55:14Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: uploaded a new version of &amp;amp;quot;File:Rspec.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;testing rspec file&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106280</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106280"/>
		<updated>2016-12-03T01:54:27Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
* In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub student user and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
require 'rails_helper' &lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106279</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106279"/>
		<updated>2016-12-03T01:53:41Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
* In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
require 'rails_helper' &lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106278</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106278"/>
		<updated>2016-12-03T01:52:49Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
# In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
require 'rails_helper' &lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
## The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106277</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106277"/>
		<updated>2016-12-03T01:52:33Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
# In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
require 'rails_helper' &lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106276</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106276"/>
		<updated>2016-12-03T01:52:00Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
# In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &amp;lt;pre&amp;gt;&lt;br /&gt;
require 'rails_helper'&lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end end end end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106275</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106275"/>
		<updated>2016-12-03T01:51:34Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
# In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &amp;lt;pre&amp;gt;&lt;br /&gt;
require 'rails_helper'&lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106274</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106274"/>
		<updated>2016-12-03T01:51:03Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&lt;br /&gt;
# In the following code, we are checking that there is a successful POST request to both the methods. To record the starting and ending time of a person looking at the submission, we call 'record_start_time' and 'record_end_time' respectively. We create a stub user for a student and a record in response_times database to imitate the real data entry. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
require 'rails_helper'&lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# The image below shows the RSpec test running successfully&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106264</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106264"/>
		<updated>2016-12-03T01:41:15Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
require 'rails_helper'&lt;br /&gt;
include LogInHelper&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSpec.describe ResponseTimeController, type: :controller do&lt;br /&gt;
&lt;br /&gt;
context 'checking that the user creates valid post request' do&lt;br /&gt;
&lt;br /&gt;
  date1 = DateTime.parse(&amp;quot;2011-05-19 10:30:14&amp;quot;)&lt;br /&gt;
  date2 = DateTime.parse(&amp;quot;2011-05-19 11:30:14&amp;quot;)&lt;br /&gt;
  date3 = DateTime.parse(&amp;quot;2011-05-19 13:30:14&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
  let!(:responsetime) {ResponseTime.create(map_id: 1, link: 'hello', round: 1, start: date1)}&lt;br /&gt;
  let!(:first_review) { Response.create(map_id: 1, additional_comment: 'hello', round: 1) }&lt;br /&gt;
  let(:response_time) {ResponseTime.create(map_id: 2, link: 'hello2', round: 2, start: date2, end: nil)}&lt;br /&gt;
&lt;br /&gt;
  before(:each) do&lt;br /&gt;
    student.save&lt;br /&gt;
    @user = User.find_by_name('student14')&lt;br /&gt;
    @role = double('role', super_admin?: false)&lt;br /&gt;
    stub_current_user(@user, 'student14', @role)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_start_time' do&lt;br /&gt;
    it 'returns with an HTTP status of 200' do&lt;br /&gt;
&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(responsetime)&lt;br /&gt;
      allow(responsetime).to receive(:each).and_return(1)&lt;br /&gt;
      allow_any_instance_of(ResponseTime).to receive_message_chain(:new).and_return(1)&lt;br /&gt;
      allow(responsetime).to receive(:save).and_return(true)&lt;br /&gt;
      post &amp;quot;record_start_time&amp;quot;, :response_time =&amp;gt; {map_id: 1, round: 1, link: 'hello' , start: date3}&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  describe 'POST #record_end_time', js: true do&lt;br /&gt;
    it 'respond with an HTTP status of 200'  do&lt;br /&gt;
      allow(ResponseTime).to receive(:where).and_return(response_time)&lt;br /&gt;
      allow(response_time).to receive(:each).and_return(1)&lt;br /&gt;
      post &amp;quot;record_end_time&amp;quot;, :response_time =&amp;gt; {map_id: 2, round: 2, end: date3}, format: :json&lt;br /&gt;
      expect(response).to have_http_status(200)&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106261</id>
		<title>File:Rspec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106261"/>
		<updated>2016-12-03T01:39:42Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: uploaded a new version of &amp;amp;quot;File:Rspec.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;testing rspec file&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106255</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106255"/>
		<updated>2016-12-03T01:34:36Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* RSpec Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;br /&gt;
[[File:Rspec.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106254</id>
		<title>File:Rspec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106254"/>
		<updated>2016-12-03T01:33:53Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: uploaded a new version of &amp;amp;quot;File:Rspec.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;testing rspec file&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106253</id>
		<title>File:Rspec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspec.png&amp;diff=106253"/>
		<updated>2016-12-03T01:32:26Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: testing rspec file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;testing rspec file&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106246</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=106246"/>
		<updated>2016-12-03T01:18:07Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each others' work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to understand the correlation between the time spent in reviewing and the knowledge gained through reviewing submissions, we need to track the time that each student spends on peer reviewing the work. The knowledge gained can be measured by assignment score and reviewing score of the reviewer. This data can be further be utilized for research studies related to learning through peer reviews.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Design a database schema for logging the time a reviewer spends on each submission link&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to display the response time summary report for each reviewer.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The task is to know how much time a reviewer spent reviewing other teams.&lt;br /&gt;
#We earlier thought of having '''response_id''' as one of the fields which could help us identify for which response we are recording reviewing time. But, entry in the''' responses table''' is created only once the response is either saved or submitted. Since we want our response_times entry to be created before that, we did not have any '''response_id''' corresponding to the response.  &amp;lt;br/&amp;gt;&lt;br /&gt;
#We primarily needed reviewer and reviewee specific data. So, another parameter to help us identify this primary information was '''response_map_id''' in the '''response_maps''' table. Once the review is started , we have the '''response_map_id''' from which we can later derive both '''reviewer_id''' and '''reviewee_id'''.There can be separate links uploaded per round, hence '''round''' is also an important parameter to be recorded. We need to record '''start''' and '''end''' time per '''link'''.&amp;lt;br/&amp;gt; &lt;br /&gt;
The following table '''response_times''' was created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Response_times.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''How reviewing times get recorded in the database'''===&lt;br /&gt;
Start and end time of each link viewed in one session needs to be recorded. &lt;br /&gt;
&lt;br /&gt;
The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Log the '''start time''' when a user clicks on a submitted link (a new entry in the '''response_times table''' gets created) during new review or while editing his saved review. An AJAX call is made from the view to '''ResponseTime''' controller action '''record_start_time''' to save start time details to database.&lt;br /&gt;
#End time of all open links (where end time has not been recorded yet) for that session get recorded in the cases mentioned below. In this, an AJAX call is made from the view to '''ResponseTime''' controller action '''record_end_time''' to save '''end time''' details to database.  All these cases are handled with the help of javascript '''onbeforeunload''' property&lt;br /&gt;
##User logged out&lt;br /&gt;
##User closed the window&lt;br /&gt;
##User clicked on 'save' or 'submit' button&lt;br /&gt;
##User switched to some other view other than the page where he is currently writing the review in the same tab. Note - the user is free to switch between tabs. The end time will not get affected in this case&lt;br /&gt;
#Next time the reviewer opens the links again to review:&lt;br /&gt;
##New entry gets created in the response_times table and start time gets recorded for this new session&lt;br /&gt;
##The above procedure for end time remains the same&lt;br /&gt;
#In case there is no user activity on the expertiza reviewing page for more than 20 minutes, there will be a pop up asking the user if he is still reviewing the submission. &lt;br /&gt;
#As soon as the pop up is shown, the end times of all open links get updated to this time. The user has two options to cancel or to okay. If the user clicks on 'okay', then the above links for which we just updated the end time, need to be added as new entries again in this new session with start time as the current time.&lt;br /&gt;
#This way we have individual entries for each link corresponding to each session with both start and end times recorded in the database.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Popup screenshot.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow_diagram_final.jpg|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Viewing the recorded times spent'''===&lt;br /&gt;
Instructor can now view the total times taken by reviewers in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each team reviewed for this particular assignment. For example - 15.32, 12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Review_report_view.png|center]]&lt;br /&gt;
&lt;br /&gt;
Now, we can see that this report is simply an overview. If the instructor wishes to view fine-grained details, he can click on the reviewer link in the report. A popup is then rendered by '''popup/reviewer_details_popup.html.erb'''. This view shows reviewer details and details of time spent per link per round by that particular reviewer. Note - total time represents total time spent by the reviewer over all rounds over all links. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
If the user clicks on &amp;quot;alternate view&amp;quot; for a particular round, a pie-chart representation of the same data for that round appears above the details table. The user can toggle this view off by clicking &amp;quot;hide details&amp;quot; and &amp;quot;show details&amp;quot;.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Pie-chart.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Other Edge cases handled :'''===&lt;br /&gt;
&lt;br /&gt;
#What happens when the user clicks on the same link twice in the same session: &lt;br /&gt;
##It may so happen that once the user clicked on a link, by mistake he/she closed it or lost the link and wishes to view it again. If the link is again clicked, a second entry gets created with the current time as start time. &lt;br /&gt;
##We account for the previous entry by updating its end time as current time. &lt;br /&gt;
#What happens when the user downloads the submission: &lt;br /&gt;
##If the user downloads any submission, the start time will be recorded on click link and end time will get recorded as above or when he submits the review&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files modified'''===&lt;br /&gt;
#response_controller.rb&lt;br /&gt;
#response/response.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#response/view.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#popup/reviewer_details_popup.html.erb&lt;br /&gt;
#helpers/review_mapping_helper.rb &lt;br /&gt;
#config/routes.rb&lt;br /&gt;
#application.js&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Files added'''===&lt;br /&gt;
#response_time_controller.rb&lt;br /&gt;
#response_time.rb&lt;br /&gt;
#review_mapping/_review_submissions_time_spent.html.erb &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Testing'''==&lt;br /&gt;
==='''Manual Testing'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the total time spent by the reviewers for each to be visible&lt;br /&gt;
#Click on the reviewer in order to see detailed information of time spent by each reviewer&lt;br /&gt;
#Click on alternate view for each entry in order to see link wise time spent in form of a pie chart.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
==='''RSpec Testing'''===&lt;br /&gt;
To test the two new controller methods, we wrote and ran RSpec tests for it. We have two methods in the new controller - record_start_time and record_end_time.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105738</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105738"/>
		<updated>2016-11-14T23:55:48Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow.JPG|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#student_review/list.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
'''Functional Testing using RSpec:'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Manual Testing for Verification:''' &lt;br /&gt;
#When user clicks on a submitted link, it opens up in a new window&lt;br /&gt;
#To verify if the time displayed in the response_report view matches with the actual time spent by the reviewer for all reviews&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105737</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105737"/>
		<updated>2016-11-14T23:54:17Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps to follow for all external links (Github, YouTube etc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow.JPG|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review as shown below.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#student_review/list.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
'''Functional Testing using RSpec:'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Manual Testing for Verification:''' &lt;br /&gt;
#When user clicks on a submitted link, it opens up in a new window.&lt;br /&gt;
#To verify if the time displayed in the response_report view matches with the actual time spent by the reviewer for all reviews.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105731</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105731"/>
		<updated>2016-11-14T23:41:48Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps to follow for all external links (Github, YouTube etc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
review_mapping/_review_report.html.erb will be modified to show the time spent in reviewing a submission. For example, the view below shows a sample modification of the view to depict the time taken in different rounds (separated by '/').[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#student_review/list.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
'''Functional Testing using RSpec:'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Manual Testing for Verification:''' &lt;br /&gt;
#When user clicks on a submitted link, it opens up in a new window.&lt;br /&gt;
#To verify if the time displayed in the response_report view matches with the actual time spent by the reviewer for all reviews.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105729</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105729"/>
		<updated>2016-11-14T23:29:09Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Files to be modified/added */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Flow.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#student_review/list.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
'''Functional Testing using RSpec:'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Manual Testing for Verification:''' &lt;br /&gt;
#When user clicks on a submitted link, it opens up in a new window.&lt;br /&gt;
#To verify if the time displayed in the response_report view matches with the actual time spent by the reviewer for all reviews.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105710</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105710"/>
		<updated>2016-11-14T23:01:37Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#submitted_content/submitted_files.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;Steps:&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105709</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105709"/>
		<updated>2016-11-14T23:01:05Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps to follow for all external links (Github, YouTube etc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#submitted_content/submitted_files.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;Steps:&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database.&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105707</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105707"/>
		<updated>2016-11-14T23:00:40Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps to follow for all external links (Github, YouTube etc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#submitted_content/submitted_files.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;Steps:&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database.&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105706</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105706"/>
		<updated>2016-11-14T23:00:16Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps to follow for all external links (Github, YouTube etc) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#submitted_content/submitted_files.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;Steps:&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database.&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105705</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105705"/>
		<updated>2016-11-14T23:00:00Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* What needs to be done */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows students to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to assess and analyze quality of reviews, we want to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. To assess and improve review qualities, the purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach and Implementation'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps to follow for all external links (Github, YouTube etc)'''===&lt;br /&gt;
On clicking a submitted link available in '''submitted_content/submitted_files.html.erb''', a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. &amp;lt;br/&amp;gt;&lt;br /&gt;
Our solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., '''IFrame''' or '''Embed''' tag. &lt;br /&gt;
We shall include two new javascript files - '''TimeMe.js''' and '''IfVisible.js''' to keep track of open submission links and time spent viewing them. &amp;lt;br/&amp;gt; The following are the steps that will be followed to keep track of the time: &lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
Instructor can now view the times taken for reviewers by reviewer in the Review report summary. This report is rendered by partial '''review_mapping/_review_report.html.erb'''. We shall modify this view to record the times spent by the reviewer per review round for each assignment. For example - 15.32/12.67 indicates that reviewer spent 15.32 minutes on round 1 review and 12.67 minutes on round 2 review.&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Modified View''' :&amp;lt;br/&amp;gt;[[File:ReviewReport1.png|center]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Files to be modified/added'''===&lt;br /&gt;
#submitted_content/submitted_files.html.erb&lt;br /&gt;
#review_mapping/_review_report.html.erb&lt;br /&gt;
#review_mapping_helper.rb (method- get_data_for_review_report)&lt;br /&gt;
#Additionally, we will create a new model class corresponding to new database table&lt;br /&gt;
#TimeMe.js and IfVisible.js for handling timing counter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Test Plan'''===&lt;br /&gt;
To test if the time spent by the reviewer on the submitted links shows up in the response_report in Instructor View. &amp;lt;br/&amp;gt;Steps:&lt;br /&gt;
# Login as a reviewer, for example (student5930). Click on the submitted links to start reviewing. Once review is done, the time spent is recorded in the background and saved in our database.&lt;br /&gt;
# Login as an instructor. Click on assignments tab. Click on 'View Review Report' under actions for the particular assignment. In the view rendered we expect the new content of time spent by the reviewers to be visible.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105393</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105393"/>
		<updated>2016-11-11T04:59:49Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for a third person to read and understand&lt;br /&gt;
In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. A possible solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., IFrame or Embed tag. &lt;br /&gt;
&amp;lt;br/&amp;gt;The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset. &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked.&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105392</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105392"/>
		<updated>2016-11-11T04:59:24Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced to a different set of eyes on the code&lt;br /&gt;
#It might expose edge cases not previously thought of&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for the third person to read and understand&lt;br /&gt;
In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. A possible solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., IFrame or Embed tag. &lt;br /&gt;
&amp;lt;br/&amp;gt;The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset. &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked.&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105391</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=105391"/>
		<updated>2016-11-11T04:55:33Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. &lt;br /&gt;
#It provides a dual benefit for both the reviewer and the writer as they are introduced a different set of eyes on the code&lt;br /&gt;
#This can expose edge cases that you hadn't thought of or invalid logic&lt;br /&gt;
#It helps instructors review a project faster&lt;br /&gt;
#It emphasizes the importance of writing in such a way that it's easy for the third person to read and understand&lt;br /&gt;
In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g. GitHub and Youtube use cases&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. A possible solution is to embed the submissions (done on an external website) within the peer assessment system itself using e.g., IFrame or Embed tag. &lt;br /&gt;
&amp;lt;br/&amp;gt;The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits review or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created.&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Behaviour Diagram''' :&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Behaviour_diagram.png|center]]&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset. &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked.&lt;br /&gt;
&lt;br /&gt;
==='''Database Design'''===&lt;br /&gt;
The following table review_submission_timing will be created to implement a solution for this project: &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Database table review submission timing.png]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104813</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104813"/>
		<updated>2016-11-09T01:36:48Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Steps */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handles GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. Another approach of using an iframe, as mentioned in the design documents, was thought of but the non-user-friendly appearance of having to scroll through it in all directions to view the page properly was the primary reason for dropping it. The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Time is saved into the database when the user saves, submits or closes the popped-up window&lt;br /&gt;
##If the corresponding entry already exists, the value of the time column is updated otherwise it is created&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;br /&gt;
&lt;br /&gt;
Edge cases that need to be handled :&lt;br /&gt;
&lt;br /&gt;
#What happens when the user refreshes the window : It will set the timer back to 0 and the time spent on that page will be reset. &lt;br /&gt;
#What happens when the user downloads the submission: If the user downloads any solution and then opens it in his/her local machine, then the time spent on that can't be tracked.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104805</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104805"/>
		<updated>2016-11-09T00:50:33Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that opens submitted files in views/response/_submitted_files.html.erb so that when the user clicks on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handles GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above-mentioned submissions. Another approach of using an iframe, as mentioned in the design documents, was thought of but the non-user-friendly appearance of having to scroll through it in all directions to view the page properly was the primary reason for dropping it. The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
#Resume time when:&lt;br /&gt;
##User switches back to this window&lt;br /&gt;
##User performs some activity after being idle&lt;br /&gt;
#Stop the time when the user closes the window or submits&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104804</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104804"/>
		<updated>2016-11-09T00:45:13Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that open submitted files in views/response/_submitted_files.html.erb so that when the user click on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handle GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
&lt;br /&gt;
Based on each submission type, we need to handle the tracking functionalities differently. Generally, the submission links can be one of the following:&lt;br /&gt;
#GitHub project/repository link , GitHub Pull requests link or Deployment link&lt;br /&gt;
#Youtube videos &lt;br /&gt;
#Wikipages&lt;br /&gt;
#Text document/doc/pdf/ppt&lt;br /&gt;
#Images - png/jpg&lt;br /&gt;
#Downloadable contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
On clicking a submitted link, a new window will pop-up that will keep track of the time spent on that new window. This can be a link to any of the above mentioned submissions. Another approach of using an iframe, as mentioned in the design documents, was thought of but the non-user-friendly appearance of having to scroll through it in all directions to view the page properly was primary reason of dropping it. The following are the steps that will be followed to keep track of the time:&lt;br /&gt;
#Start the time when a user clicks on the submitted link (a new window pops-up)&lt;br /&gt;
#We'll pause the time in the following cases:&lt;br /&gt;
##User idle for more than 30sec&lt;br /&gt;
##User switched tabs&lt;br /&gt;
##User minimized the window&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==='''Edge cases'''===&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104801</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104801"/>
		<updated>2016-11-09T00:29:24Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that open submitted files in views/response/_submitted_files.html.erb so that when the user click on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handle GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;br /&gt;
==='''Types of submissions'''===&lt;br /&gt;
==='''Steps'''===&lt;br /&gt;
==='''Edge cases'''===&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104800</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104800"/>
		<updated>2016-11-09T00:23:27Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that open submitted files in views/response/_submitted_files.html.erb so that when the user click on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handle GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;br /&gt;
&lt;br /&gt;
=='''Approach'''==&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104796</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104796"/>
		<updated>2016-11-08T23:07:06Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='''What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that open submitted files in views/response/_submitted_files.html.erb so that when the user click on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handle GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104795</id>
		<title>CSC/ECE 517 Fall 2016/E1705. Tracking the time students look at the others' submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1705._Tracking_the_time_students_look_at_the_others%27_submissions&amp;diff=104795"/>
		<updated>2016-11-08T23:06:48Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: Created page with &amp;quot;=='''Introduction'''== ==='''Purpose'''=== Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to lear...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=='''Introduction'''==&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
Expertiza provides the functionality of peer reviews. The best advantage of peer review for the students is that it allows them to learn from each other work. In order to help them to do this, we have to be able to track the time that students spend observing the other's work. Unfortunately, most peer assessment systems do not manage the content of students’ submission within the systems. They usually allow the authors submit external links to the submission, which makes it difficult for the system to track the time that the reviewers spend on the submissions. The purpose of the project is to be able to successfully track the time that each student spends on peer reviewing the work.&lt;br /&gt;
&lt;br /&gt;
==='What needs to be done'''===&lt;br /&gt;
#Design a database schema for logging the time a reviewer spend on a submission&lt;br /&gt;
#Design and implement a solution that handles the use case, where students’ submissions are hosted on an external website e.g.,&lt;br /&gt;
#Modify the reviewer interface in expertiza to accommodate your solution e.g., change the link that open submitted files in views/response/_submitted_files.html.erb so that when the user click on the link, it opens a popup window that shows the submission, record time when it opens and closes.&lt;br /&gt;
#Design and implement a solution that handle GitHub and Youtube use cases&lt;br /&gt;
#Modify Review report (views/review_mapping/_review_report.html.erb) to show the time spent on each submission&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=104793</id>
		<title>CSC/ECE 517 Fall 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=104793"/>
		<updated>2016-11-08T22:51:33Z</updated>

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

		<summary type="html">&lt;p&gt;Nsingh9: /* To Test if a user is able to Import/Export CSV files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Link to deployed application===&lt;br /&gt;
*http://152.46.16.205:3000/&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)     #To identify teaching assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        owner_flag= (current_user.id == owner_inst_id)&lt;br /&gt;
&lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          owner_flag = (owner_flag or (current_ta.parent_id == owner_inst_id))&lt;br /&gt;
        end&lt;br /&gt;
        return owner_flag&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
  def import&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      uploaded_io = params[:csv]&lt;br /&gt;
      File.open(Rails.root.join('spec', 'features/import_export_csv_oss/', uploaded_io.original_filename), 'wb') do |file|&lt;br /&gt;
        file.write(uploaded_io.read)&lt;br /&gt;
      end&lt;br /&gt;
        file_data = File.read(Rails.root.join('spec/features/import_export_csv_oss/'+uploaded_io.original_filename))&lt;br /&gt;
        a = QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
        redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
       rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
 def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # if questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
        #  row &amp;lt;&amp;lt; QuestionType.find_by_question_id(question.id).parameters&lt;br /&gt;
        # else&lt;br /&gt;
        #  row &amp;lt;&amp;lt; &amp;quot;&amp;quot;&lt;br /&gt;
        # end&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
4. The following test case validates that no error message appears on the page while exporting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should not display an error flash message while exporting', js: true  do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    click_button &amp;quot;Export questions to CSV&amp;quot;&lt;br /&gt;
    expect(page).not_to have_content('error')&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
5.The following test case validates if a user is able to edit an advice.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scenario 'clicks on edit advice', js: true do&lt;br /&gt;
&lt;br /&gt;
    #login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/advice/edit_advice/1'&lt;br /&gt;
&lt;br /&gt;
    expect(page).to have_content(&amp;quot;Edit an existing questionnaire's advice&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
6. The following test case validates that the changes made in the advice page are re-displayed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 scenario 'reloads page successfully', js: true do&lt;br /&gt;
&lt;br /&gt;
    #login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    click_on 'Add'&lt;br /&gt;
    visit '/advice/edit_advice/1'&lt;br /&gt;
    click_on 'Save and redisplay advice'&lt;br /&gt;
    expect(page).to have_content(&amp;quot;The advice was successfully saved!&amp;quot;)&lt;br /&gt;
    expect(page).to have_content(&amp;quot;Edit an existing questionnaire's advice&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    #expect(flash[:notice]).to match &amp;quot;The advice was successfully saved&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
7.The following test case validates if a user is redirected to the edit advice page after clicking on the 'Edit/View advice' button&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scenario 'redirects from questionnaire to advice', js: true do&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    click_on 'Edit/View advice'&lt;br /&gt;
    expect(page).to have_content(&amp;quot;Edit an existing questionnaire's advice&amp;quot;)&lt;br /&gt;
    #expect(AdviceController.save_advice).to be(true)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
8.The following test case validates if the changes made in the edit_advice page are saved to the database after the 'Save and redisplay advice' button is clicked.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scenario 'saves content', js: true do&lt;br /&gt;
  visit '/questionnaires/1/edit'&lt;br /&gt;
  click_on 'Add'&lt;br /&gt;
  visit '/advice/edit_advice/1'&lt;br /&gt;
    fill_in &amp;quot;horizontal_1_advice&amp;quot; , with: &amp;quot;Example&amp;quot;&lt;br /&gt;
    click_on 'Save and redisplay advice'&lt;br /&gt;
    expect(QuestionAdvice.where(id: 1, advice:&amp;quot;Example&amp;quot;)).not_to be_empty&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Impersonate 'teaching_assistant520' (is a TA under instructor6) and repeat steps 2-5&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire&lt;br /&gt;
##This can invite future research into the area, since currently, it allows the duplicated sequence number code to be added&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104322</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104322"/>
		<updated>2016-11-04T03:59:17Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Changes in source code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
# The following code uploads the file and saves it the given directory from where it can be read. This way, when deployed, any user can upload a file from his local machine&lt;br /&gt;
    uploaded_io = params[:csv]&lt;br /&gt;
    File.open(Rails.root.join('spec', 'features/import_export_csv_oss/', uploaded_io.original_filename), 'wb') do |file|&lt;br /&gt;
        file.write(uploaded_io.read)&lt;br /&gt;
    end&lt;br /&gt;
#The following code reads and imports the saved file&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(Rails.root.join('spec/features/import_export_csv_oss/'+params[:csv]))&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Impersonate 'teaching_assistant520' (is a TA under instructor6) and repeat steps 2-5&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104321</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104321"/>
		<updated>2016-11-04T03:56:25Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Changes in source code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    uploaded_io = params[:csv]&lt;br /&gt;
    File.open(Rails.root.join('spec', 'features/import_export_csv_oss/', uploaded_io.original_filename), 'wb') do |file|&lt;br /&gt;
        file.write(uploaded_io.read)&lt;br /&gt;
    end&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(Rails.root.join('spec/features/import_export_csv_oss/'+params[:csv]))&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Impersonate 'teaching_assistant520' (is a TA under instructor6) and repeat steps 2-5&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104152</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104152"/>
		<updated>2016-10-31T23:19:34Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Changes in source code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(Rails.root.join('spec/features/import_export_csv_oss/'+params[:csv]))&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Impersonate 'teaching_assistant520' (is a TA under instructor6) and repeat steps 2-5&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104144</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104144"/>
		<updated>2016-10-31T21:21:49Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Testing on UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Impersonate 'teaching_assistant520' (is a TA under instructor6) and repeat steps 2-5&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content&lt;br /&gt;
#Click on any one of the Review tab (For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104143</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=104143"/>
		<updated>2016-10-31T21:20:37Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing on UI===&lt;br /&gt;
====To Test only if an Instructor who owns the rubric or his TA can edit the rubric====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.]&lt;br /&gt;
#Click on any one of the Review tab(For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 (This can be found out from the expertiza_development database using query: select name from questionnaires where instructor_id=6;)&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire.&lt;br /&gt;
#Impersonate 'teaching_assistant520'(is a TA under instructor6) and repeat steps 2-5.&lt;br /&gt;
#User should be redirected to a page where he can edit the questionnaire.&lt;br /&gt;
#Repeat the above steps for a questionnaire which is not owned by the instructor.&lt;br /&gt;
#An error message is displayed above the 'Manage Content' title.&lt;br /&gt;
&lt;br /&gt;
====To Test if a user is able to Import/Export CSV files====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.]&lt;br /&gt;
#Click on any one of the Review tab(For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'Browse' button under 'Import/Export (from/to CSV format)' and select a file of CSV format which contains the questions.&lt;br /&gt;
#Click on 'Import from CSV' button. The questions in the files should be saved into the questionnaire.&lt;br /&gt;
#Click on 'Export questions to CSV'. The questions should be saved to the local system in a file of CSV format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to edit advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.]&lt;br /&gt;
#Click on any one of the Review tab(For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on edit advice button. This should redirect to a page containing the advice for that questionnaire.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====To test if a user is able to save edited advice for a questionnaire====&lt;br /&gt;
#Login to expertiza as 'instructor6' (Username: instructor6 Password:password)&lt;br /&gt;
#Select 'Questionnaire' Tab under Manage Content.]&lt;br /&gt;
#Click on any one of the Review tab(For eg: Review, Metareview, Author Feedback)&lt;br /&gt;
#Click on edit button of a questionnaire which is owned by instructor6 &lt;br /&gt;
#Click on 'save and redisplay' button. This should reload the same page with the edited advice.&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103882</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103882"/>
		<updated>2016-10-29T04:30:21Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Testing using RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of feature tests using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The file to be uploaded should not be an empty file. The following test case checks if the imported file is empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).not_to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. The following example shows that this test case passes when there's an error in the column name of the imported file. If we change this test file with the one in the above two cases, and change expect().to to expect().not_to, we can see that it does exactly what we require it to.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''References'''===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[http://research.csc.ncsu.edu/efg/expertiza Details of the Expertiza Project]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103874</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103874"/>
		<updated>2016-10-29T04:14:14Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Changes in source code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which generates a CSV out of the data in the question table which can then be exported to a local machine.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of test cases using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The following test case checks if the imported file is not empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''References'''===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[http://research.csc.ncsu.edu/efg/expertiza Details of the Expertiza Project]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103862</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103862"/>
		<updated>2016-10-29T04:05:30Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Changes in source code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. &lt;br /&gt;
a. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
b. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which converts an imported file to csv format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of test cases using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The following test case checks if the imported file is not empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''References'''===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[http://research.csc.ncsu.edu/efg/expertiza Details of the Expertiza Project]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103854</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103854"/>
		<updated>2016-10-29T04:02:04Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* New functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics but can only view them. If he attempts to do so, an error message will be displayed and he will be redirected back.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* A CSV file containing the questions with the correct column names can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in CSV format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
4. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which converts an imported file to csv format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of test cases using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The following test case checks if the imported file is not empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''References'''===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[http://research.csc.ncsu.edu/efg/expertiza Details of the Expertiza Project]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103844</id>
		<title>CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1653._Fix_and_improve_rubric_criteria&amp;diff=103844"/>
		<updated>2016-10-29T03:58:07Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Tasks identified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1653. Fix and Improve Rubric Criteria==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expertiza background===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source web application based on [http://rubyonrails.org/ Ruby on Rails] framework. This application facilitates submission and peer review of assignments and team projects. Students can upload their assignments and URLs linked to their work on expertiza which can be reviewed by the instructor and peer reviewed by other students. Expertiza also expedites the process of selecting/assigning topics and choosing team mates for team projects. Instructors can also create and customize assignments for students and create review rubrics which are used by students for peer reviewing others' work.&lt;br /&gt;
&lt;br /&gt;
===Tasks identified===&lt;br /&gt;
* Change allow_action? method of questionnaires controller to restrict unauthorized access to edit review rubrics. Only those Instructors who own the rubric or their Teaching Assistants should be allowed edit them.&lt;br /&gt;
* Display an error message when a user who is not the owner of a questionnaire attempts to edit it and redirect him back to the page he came from.&lt;br /&gt;
*Fix the working of import and export methods(dumping and loading criterion) in the Questionnaire controller.&lt;br /&gt;
*Perform feature testing for the import and export methods of questionnaire controller.&lt;br /&gt;
*Remove old and unused code related to rubric import and export.&lt;br /&gt;
*Write feature tests for criterion advice.&lt;br /&gt;
&lt;br /&gt;
===Modified/Created files===&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*QuestionnaireHelper.rb&lt;br /&gt;
*Questionnaire.rb&lt;br /&gt;
*questionnaire_spec.rb&lt;br /&gt;
*spec/features/import_export_csv_oss/ (New folder created containing 3 test files)&lt;br /&gt;
&lt;br /&gt;
===Summary of implementation===&lt;br /&gt;
====New functionality====&lt;br /&gt;
* An instructor can no longer change others' review rubrics. If he attempts to do so, an error message will be displayed.&lt;br /&gt;
* Only those review rubrics can be modified by an instructor which are owned by him.&lt;br /&gt;
* A Teaching Assistant can modify only those review rubrics which are owned by the instructor under whom he works.&lt;br /&gt;
* Import and export methods are working. &lt;br /&gt;
* A csv file containing the questions can now be imported into the rubric.&lt;br /&gt;
* A rubric can also be exported in csv format to a destination path on our local system.&lt;br /&gt;
&lt;br /&gt;
====Changes in source code====&lt;br /&gt;
1. Changes in allow_action? method of the Questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The action_allow? method earlier provided access to all users to modify or view any review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code before implementation.&lt;br /&gt;
   def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    ['Super-Administrator',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Instructor',&lt;br /&gt;
     'Teaching Assistant', 'Student'].include? current_role_name&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The action_allow? method now provides access to modify a rubric to those instructors who own the rubric or the Teaching Assistants who work under them. However, any user can view the contents of the review rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Source code after implementation.&lt;br /&gt;
def action_allowed?&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
      when 'edit', 'update', 'delete', 'toggle_access'&lt;br /&gt;
        #Modifications can only be done by papertrail&lt;br /&gt;
        q= Questionnaire.find_by(id:params[:id])&lt;br /&gt;
        owner_inst_id = q.instructor_id&lt;br /&gt;
        if(current_user.role_id==6)                          #Identifying if the current user is a Teaching Assistant&lt;br /&gt;
          current_ta = current_user;&lt;br /&gt;
        end&lt;br /&gt;
        b= (current_user.id == owner_inst_id)   &lt;br /&gt;
        if(!current_ta.nil?)&lt;br /&gt;
          b = b or (current_ta.parent_id == owner_inst_id)&lt;br /&gt;
        end&lt;br /&gt;
        return b&lt;br /&gt;
&lt;br /&gt;
      else&lt;br /&gt;
        #Allow all others&lt;br /&gt;
        ['Super-Administrator',&lt;br /&gt;
         'Administrator',&lt;br /&gt;
         'Instructor',&lt;br /&gt;
         'Teaching Assistant',&lt;br /&gt;
         'Student'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
2. Modification of import method declared in the questionnaires controller.&lt;br /&gt;
&lt;br /&gt;
The code initially was not using the read method to read the file data and was unable to import a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def import&lt;br /&gt;
    @questionnaire = Questionnaire.find(params[:id])&lt;br /&gt;
    file = params['csv']&lt;br /&gt;
    @questionnaire.questions &amp;lt;&amp;lt; QuestionnaireHelper.get_questions_from_csv(@questionnaire, file)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The modified code now reads data from the file and calls the method get_questions_from_csv and passes the data to it. The method reads data in rows and saves each row as a question. It then saves each question.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def import&lt;br /&gt;
&lt;br /&gt;
    questionnaire_id = (params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      file_data = File.read(params[:csv])&lt;br /&gt;
      QuestionnaireHelper.get_questions_from_csv(file_data,params[:id])&lt;br /&gt;
      #Questionnaire.import(file_data)&lt;br /&gt;
&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: &amp;quot;All questions have been successfully imported!&amp;quot;&lt;br /&gt;
    rescue&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym), notice: $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
3. Removing unwanted code and modifying the get_questions_from_csv method declared in the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
The method get_questions_from_csv defined in the questionnaire helper was unable to read data from the file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code before implementation&lt;br /&gt;
def self.get_questions_from_csv(questionnaire, file)&lt;br /&gt;
    questions = []&lt;br /&gt;
    custom_rubric = questionnaire.section == &amp;quot;Custom&amp;quot;&lt;br /&gt;
    CSV::Reader.parse(file) do |row|&lt;br /&gt;
      unless row.empty?&lt;br /&gt;
        i = 0&lt;br /&gt;
        score = questionnaire.max_question_score&lt;br /&gt;
        q = Question.new&lt;br /&gt;
        q_type = QuestionType.new if custom_rubric&lt;br /&gt;
        q.true_false = false&lt;br /&gt;
        row.each do |cell|&lt;br /&gt;
          case i&lt;br /&gt;
          when CSV_QUESTION&lt;br /&gt;
            q.txt = cell.strip unless cell.nil?&lt;br /&gt;
          when CSV_TYPE&lt;br /&gt;
            unless cell.nil?&lt;br /&gt;
              q.true_false = cell.downcase.strip == Question::TRUE_FALSE.downcase&lt;br /&gt;
              q_type.q_type = cell.strip if custom_rubric&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_PARAM&lt;br /&gt;
            if custom_rubric&lt;br /&gt;
              q_type.parameters = cell.strip if cell&lt;br /&gt;
            end&lt;br /&gt;
          when CSV_WEIGHT&lt;br /&gt;
            q.weight = cell.strip.to_i if cell&lt;br /&gt;
          else&lt;br /&gt;
            if score &amp;gt;= questionnaire.min_question_score and !cell.nil?&lt;br /&gt;
              a = QuestionAdvice.new(score: score, advice: cell.strip) if custom_rubric&lt;br /&gt;
              a = QuestionAdvice.new(score: questionnaire.min_question_score + i - 4, advice: cell.strip)&lt;br /&gt;
              score -= 1&lt;br /&gt;
              q.question_advices &amp;lt;&amp;lt; a&lt;br /&gt;
            end&lt;br /&gt;
          end&lt;br /&gt;
          i += 1&lt;br /&gt;
        end&lt;br /&gt;
        q.save&lt;br /&gt;
        q_type.question = q if custom_rubric&lt;br /&gt;
        q_type.save if custom_rubric&lt;br /&gt;
        questions &amp;lt;&amp;lt; q&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    questions&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The unwanted code from the get_questions_from_csv method is now removed and the modified code successfully reads data from the csv file and saves questions present in the from of rows in the rubric.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#source code after implementation&lt;br /&gt;
def self.get_questions_from_csv(file_data,id)&lt;br /&gt;
    CSV.parse(file_data, headers: true) do |row|&lt;br /&gt;
      #  row.each do |cell|&lt;br /&gt;
      questions_hash = row.to_hash&lt;br /&gt;
      ques = Question.new(questions_hash)&lt;br /&gt;
      ques.questionnaire_id=id&lt;br /&gt;
      ques.save&lt;br /&gt;
    end # end CSV.parse&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
4. Removing dysfunctional code from the QuestionnaireHelper and adding a new method in questionnaire.rb model&lt;br /&gt;
&lt;br /&gt;
The create_questionnaire_csv method was not functional and was removed from the QuestionnaireHelper&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.create_questionnaire_csv(questionnaire, _user_name)&lt;br /&gt;
    csv_data = CSV.generate do |csv|&lt;br /&gt;
      for question in questionnaire.questions&lt;br /&gt;
        # Each row is formatted as follows&lt;br /&gt;
        # Question, question advice (from high score to low), type, weight&lt;br /&gt;
        row = []&lt;br /&gt;
        row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
        row &amp;lt;&amp;lt; question.type&lt;br /&gt;
        row &amp;lt;&amp;lt; question.alternatives || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
        row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
&lt;br /&gt;
        # loop through all the question advice from highest score to lowest score&lt;br /&gt;
        adjust_advice_size(questionnaire, question)&lt;br /&gt;
        for advice in question.question_advices.sort {|x, y| y.score &amp;lt;=&amp;gt; x.score }&lt;br /&gt;
          row &amp;lt;&amp;lt; advice.advice&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        csv &amp;lt;&amp;lt; row&lt;br /&gt;
    end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    csv_data&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The to_csv function was added in the questionnaire.rb model class which converts an imported file to csv format&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def to_csv(ques)&lt;br /&gt;
        questions = ques&lt;br /&gt;
        csv_data = CSV.generate do |csv|&lt;br /&gt;
          row = ['seq','txt','type','weight','size','max_label','min_label','alternatives']&lt;br /&gt;
          csv &amp;lt;&amp;lt; row&lt;br /&gt;
          for question in questions&lt;br /&gt;
            row = []&lt;br /&gt;
            row &amp;lt;&amp;lt; question.seq&lt;br /&gt;
            row &amp;lt;&amp;lt; question.txt&lt;br /&gt;
            row &amp;lt;&amp;lt; question.type&lt;br /&gt;
            row &amp;lt;&amp;lt; question.weight&lt;br /&gt;
            row &amp;lt;&amp;lt; question.size || ''&lt;br /&gt;
            row &amp;lt;&amp;lt; question.max_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.min_label&lt;br /&gt;
            row &amp;lt;&amp;lt; question.alternatives&lt;br /&gt;
&lt;br /&gt;
            csv &amp;lt;&amp;lt; row&lt;br /&gt;
&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing using RSpec===&lt;br /&gt;
&lt;br /&gt;
A set of test cases using the RSpec framework have been added to test the implemented functionalities. Test data from spec/features/import_export_csv_oss/ was used to run the test cases.&lt;br /&gt;
&lt;br /&gt;
1. The following test case checks if the imported file is not empty.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe 'Import questions from CSV' do&lt;br /&gt;
&lt;br /&gt;
    it 'should not be an empty file', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('No such file')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2.The following test case validates an imported CSV file. The test case passes if all the questions get successfully imported.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
it 'should be a valid CSV file', js: true do&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/questionnaires/1/edit'&lt;br /&gt;
    file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot.csv&amp;quot;&lt;br /&gt;
    attach_file('csv',file_path)&lt;br /&gt;
    click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
    expect(page).to have_content('All questions have been successfully imported!')&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. The following test case validates the names of all columns in the imported CSV file. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 it 'should have valid column names', js: true do&lt;br /&gt;
      login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
      visit '/questionnaires/1/edit'&lt;br /&gt;
      file_path=Rails.root+&amp;quot;spec/features/import_export_csv_oss/navjot (propername).csv&amp;quot;&lt;br /&gt;
      attach_file('csv',file_path)&lt;br /&gt;
      click_button &amp;quot;Import from CSV&amp;quot;&lt;br /&gt;
      expect(page).to have_content('unknown attribute')&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==='''References'''===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[http://research.csc.ncsu.edu/efg/expertiza Details of the Expertiza Project]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=102718</id>
		<title>CSC/ECE 517 Fall 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=102718"/>
		<updated>2016-10-28T14:41:09Z</updated>

		<summary type="html">&lt;p&gt;Nsingh9: /* Writing Assignments 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.example.com link title]==Calibration Assignment Submissions==&lt;br /&gt;
*[[Calibration Assignment Submission (Firebrick JS)]]&lt;br /&gt;
*[[Calibration Assignment Submission (Active Job)]]&lt;br /&gt;
==Writing Assignments 2==&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1666. Test team functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1631. Refactoring Bidding Interface]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1674.Refactor leaderboard.rb and write unit tests]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1668.Test e-mailing functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1658. Refractor lottery_controller.rb and write integration tests]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1660. Review requirements and thresholds]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1650. Sort instructor views alphabetically by default]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1644. Refactor and test Teams Controller]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1659. Refactor on_the_fly_calc.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1657. Introduce a Student View for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1653. Fix and improve rubric criteria]]&lt;/div&gt;</summary>
		<author><name>Nsingh9</name></author>
	</entry>
</feed>