<?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=Zli36</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=Zli36"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Zli36"/>
	<updated>2026-07-01T22:51:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104783</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104783"/>
		<updated>2016-11-08T22:20:31Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Eexpertiza''' ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.&lt;br /&gt;
== '''Rspec''' ==&lt;br /&gt;
rspec is a meta-gem, which depends on the rspec-core, rspec-expectations and rspec-mocks gems. Each of these can be installed separately and loaded in isolation using require. Among other benefits, this allows you to use rspec-expectations, for example, in Test::Unit::TestCase if you happen to prefer that style.&lt;br /&gt;
Conversely, if you like RSpec's approach to declaring example groups and examples (describe and it) but prefer Test::Unit assertions and mocha, rr or flexmock for mocking, you'll be able to do that without having to install or load the components of RSpec that you're not using.&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests.&lt;br /&gt;
 &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
 &lt;br /&gt;
For example, the codes in quiz_spec.rb contain too much create so that prolong testing time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Create an assignment due date&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;submission&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;review&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;metareview&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;drop_topic&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;signup&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;team_formation&amp;quot;)&lt;br /&gt;
    create(:deadline_right)&lt;br /&gt;
    create(:deadline_right, name: 'Late')&lt;br /&gt;
    create(:deadline_right, name: 'OK')&lt;br /&gt;
    create :assignment_due_date, due_at: (DateTime.now + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
One solution is building an complete database to one time to support all RSpec test without create new records.&lt;br /&gt;
== '''Related Work''' ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== '''Task''' ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)).&lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Design''' ==&lt;br /&gt;
=== Database design ===&lt;br /&gt;
We design a expertiza_test database to save the test date used for Rspec. The test database owns the same structure as the real expertiza database, including the relations between tables and some restriction of attribute like it cannot be null or some other requirements for different attributes. Besides, the data in test database is the same as the data in factories part in spec, which includes FeedbackResponseMap.rb, Respone.rb, factories.rb, quiz_factory.rb. In this situation we do not need to create some data before testing, and we can use the data in test DB directly. Because of it, the overhead of testing cases will experience obvious decreasing.&lt;br /&gt;
like the Rspec statements in creating some User objects.:&lt;br /&gt;
  factory :admin, class: User do&lt;br /&gt;
    sequence(:name) {|n| &amp;quot;admin#{n}&amp;quot; }&lt;br /&gt;
    role { Role.where(name: 'Administrator').first || association(:role_of_administrator) }&lt;br /&gt;
    password &amp;quot;password&amp;quot;&lt;br /&gt;
    password_confirmation &amp;quot;password&amp;quot;&lt;br /&gt;
    sequence(:fullname) {|n| &amp;quot;#{n}, administrator&amp;quot; }&lt;br /&gt;
    email &amp;quot;expertiza@mailinator.com&amp;quot;&lt;br /&gt;
    parent_id 1&lt;br /&gt;
    private_by_default  false&lt;br /&gt;
    mru_directory_path  nil&lt;br /&gt;
    email_on_review true&lt;br /&gt;
    email_on_submission true&lt;br /&gt;
    email_on_review_of_review true&lt;br /&gt;
    is_new_user false&lt;br /&gt;
    master_permission_granted 0&lt;br /&gt;
    handle &amp;quot;handle&amp;quot;&lt;br /&gt;
    leaderboard_privacy false&lt;br /&gt;
    digital_certificate nil&lt;br /&gt;
    timezonepref nil&lt;br /&gt;
    public_key nil&lt;br /&gt;
    copy_of_emails  false&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
then transfer this into SQL query and then add the information the same as designed for Rspec test into expertiza_test database.&lt;br /&gt;
INSERT INTO User VALUES (xxxxx, xxxxxx, xxxxx, xxxxxxxx, xxxxxxx, xxxxxxx, xxxx );&lt;br /&gt;
&lt;br /&gt;
=== feature test design ===&lt;br /&gt;
To accelerate the feature test, we have to eliminate pseudo data creation. Now all the feature tests have to create their own data before each test. After building a test database, all the pseudo data creation statement can be removed from the test files. Instead, the tests reference data stored in the test database.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104779</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104779"/>
		<updated>2016-11-08T22:11:57Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Eexpertiza''' ==&lt;br /&gt;
== '''Rspec''' ==&lt;br /&gt;
rspec is a meta-gem, which depends on the rspec-core, rspec-expectations and rspec-mocks gems. Each of these can be installed separately and loaded in isolation using require. Among other benefits, this allows you to use rspec-expectations, for example, in Test::Unit::TestCase if you happen to prefer that style.&lt;br /&gt;
Conversely, if you like RSpec's approach to declaring example groups and examples (describe and it) but prefer Test::Unit assertions and mocha, rr or flexmock for mocking, you'll be able to do that without having to install or load the components of RSpec that you're not using.&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests.&lt;br /&gt;
 &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
 &lt;br /&gt;
For example, the codes in quiz_spec.rb contain too much create so that prolong testing time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Create an assignment due date&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;submission&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;review&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;metareview&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;drop_topic&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;signup&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;team_formation&amp;quot;)&lt;br /&gt;
    create(:deadline_right)&lt;br /&gt;
    create(:deadline_right, name: 'Late')&lt;br /&gt;
    create(:deadline_right, name: 'OK')&lt;br /&gt;
    create :assignment_due_date, due_at: (DateTime.now + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
One solution is building an complete database to one time to support all RSpec test without create new records.&lt;br /&gt;
== '''Related Work''' ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== '''Task''' ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)).&lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Design''' ==&lt;br /&gt;
=== Database design ===&lt;br /&gt;
We design a expertiza_test database to save the test date used for Rspec. The test database owns the same structure as the real expertiza database, including the relations between tables and some restriction of attribute like it cannot be null or some other requirements for different attributes. Besides, the data in test database is the same as the data in factories part in spec, which includes FeedbackResponseMap.rb, Respone.rb, factories.rb, quiz_factory.rb. In this situation we do not need to create some data before testing, and we can use the data in test DB directly. Because of it, the overhead of testing cases will experience obvious decreasing.&lt;br /&gt;
like the Rspec statements in creating some User objects.:&lt;br /&gt;
  factory :admin, class: User do&lt;br /&gt;
    sequence(:name) {|n| &amp;quot;admin#{n}&amp;quot; }&lt;br /&gt;
    role { Role.where(name: 'Administrator').first || association(:role_of_administrator) }&lt;br /&gt;
    password &amp;quot;password&amp;quot;&lt;br /&gt;
    password_confirmation &amp;quot;password&amp;quot;&lt;br /&gt;
    sequence(:fullname) {|n| &amp;quot;#{n}, administrator&amp;quot; }&lt;br /&gt;
    email &amp;quot;expertiza@mailinator.com&amp;quot;&lt;br /&gt;
    parent_id 1&lt;br /&gt;
    private_by_default  false&lt;br /&gt;
    mru_directory_path  nil&lt;br /&gt;
    email_on_review true&lt;br /&gt;
    email_on_submission true&lt;br /&gt;
    email_on_review_of_review true&lt;br /&gt;
    is_new_user false&lt;br /&gt;
    master_permission_granted 0&lt;br /&gt;
    handle &amp;quot;handle&amp;quot;&lt;br /&gt;
    leaderboard_privacy false&lt;br /&gt;
    digital_certificate nil&lt;br /&gt;
    timezonepref nil&lt;br /&gt;
    public_key nil&lt;br /&gt;
    copy_of_emails  false&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
then transfer this into SQL query and then add the information the same as designed for Rspec test into expertiza_test database.&lt;br /&gt;
=== feature test design ===&lt;br /&gt;
To accelerate the feature test, we have to eliminate pseudo data creation. Now all the feature tests have to create their own data before each test. After building a test database, all the pseudo data creation statement can be removed from the test files. Instead, the tests reference data stored in the test database.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104776</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104776"/>
		<updated>2016-11-08T22:11:42Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Eexpertiza''' ==&lt;br /&gt;
== '''Rspec''' ==&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests.&lt;br /&gt;
 One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
 For example, the codes in quiz_spec.rb contain too much create so that prolong testing time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Create an assignment due date&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;submission&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;review&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;metareview&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;drop_topic&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;signup&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;team_formation&amp;quot;)&lt;br /&gt;
    create(:deadline_right)&lt;br /&gt;
    create(:deadline_right, name: 'Late')&lt;br /&gt;
    create(:deadline_right, name: 'OK')&lt;br /&gt;
    create :assignment_due_date, due_at: (DateTime.now + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
One solution is building an complete database to one time to support all RSpec test without create new records.&lt;br /&gt;
== '''Related Work''' ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== '''Task''' ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)).&lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Design''' ==&lt;br /&gt;
=== Database design ===&lt;br /&gt;
We design a expertiza_test database to save the test date used for Rspec. The test database owns the same structure as the real expertiza database, including the relations between tables and some restriction of attribute like it cannot be null or some other requirements for different attributes. Besides, the data in test database is the same as the data in factories part in spec, which includes FeedbackResponseMap.rb, Respone.rb, factories.rb, quiz_factory.rb. In this situation we do not need to create some data before testing, and we can use the data in test DB directly. Because of it, the overhead of testing cases will experience obvious decreasing.&lt;br /&gt;
=== feature test design ===&lt;br /&gt;
To accelerate the feature test, we have to eliminate pseudo data creation. Now all the feature tests have to create their own data before each test. After building a test database, all the pseudo data creation statement can be removed from the test files. Instead, the tests reference data stored in the test database.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104772</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104772"/>
		<updated>2016-11-08T22:05:58Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Eexpertiza''' ==&lt;br /&gt;
== '''Rspec''' ==&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.&lt;br /&gt;
Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
For example, the codes in quiz_spec.rb contain too much create so that prolong testing time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Create an assignment due date&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;submission&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;review&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;metareview&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;drop_topic&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;signup&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;team_formation&amp;quot;)&lt;br /&gt;
    create(:deadline_right)&lt;br /&gt;
    create(:deadline_right, name: 'Late')&lt;br /&gt;
    create(:deadline_right, name: 'OK')&lt;br /&gt;
    create :assignment_due_date, due_at: (DateTime.now + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
One solution is building an complete database to one time to support all RSpec test without create new records.&lt;br /&gt;
== '''Related Work''' ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== '''Task''' ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Design''' ==&lt;br /&gt;
=== Database design ===&lt;br /&gt;
=== factories design ===&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104771</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104771"/>
		<updated>2016-11-08T22:03:37Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Eexpertiza''' ==&lt;br /&gt;
== '''Rspec''' ==&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.&lt;br /&gt;
Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
For example, the codes in quiz_spec.rb contain too much create so that prolong testing time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # Create an assignment due date&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;submission&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;review&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;metareview&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;drop_topic&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;signup&amp;quot;)&lt;br /&gt;
    create(:deadline_type, name: &amp;quot;team_formation&amp;quot;)&lt;br /&gt;
    create(:deadline_right)&lt;br /&gt;
    create(:deadline_right, name: 'Late')&lt;br /&gt;
    create(:deadline_right, name: 'OK')&lt;br /&gt;
    create :assignment_due_date, due_at: (DateTime.now + 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== '''Related Work''' ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== '''Task''' ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Design''' ==&lt;br /&gt;
=== Database design ===&lt;br /&gt;
=== factories design ===&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104766</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104766"/>
		<updated>2016-11-08T21:47:49Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Accelerate RSPec testing =&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.&lt;br /&gt;
Unfortunately, Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
== Related Work ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104765</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104765"/>
		<updated>2016-11-08T21:45:40Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Accelerate RSPec testing =&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
== Related Work ==&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
== Task ==&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104759</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104759"/>
		<updated>2016-11-08T21:43:40Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
=== Related Work ===&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
=== Task ===&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104757</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104757"/>
		<updated>2016-11-08T21:43:16Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E1701. Accelerate RSpec testing==&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
=== Related Work ===&lt;br /&gt;
* Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
* Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
=== Task ===&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104755</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104755"/>
		<updated>2016-11-08T21:42:06Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E1701. Accelerate RSpec testing==&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
=== Related Work ===&lt;br /&gt;
Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
Database involved: Expertiza_test &lt;br /&gt;
&lt;br /&gt;
=== Task ===&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104754</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104754"/>
		<updated>2016-11-08T21:41:01Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== E1701. Accelerate RSpec testing==&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
&lt;br /&gt;
=== Related Work ===&lt;br /&gt;
Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
What needs to be done:  &lt;br /&gt;
&lt;br /&gt;
=== Task ===&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104751</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104751"/>
		<updated>2016-11-08T21:39:43Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;##E1701. Accelerate RSpec testing##&lt;br /&gt;
Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
What needs to be done:  Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104750</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104750"/>
		<updated>2016-11-08T21:39:30Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;## E1701. Accelerate RSpec testing ##&lt;br /&gt;
Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
What needs to be done:  Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. &lt;br /&gt;
One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104749</id>
		<title>CSC/ECE 517 Fall 2016/E1701. Accelerate RSpec testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1701._Accelerate_RSpec_testing&amp;diff=104749"/>
		<updated>2016-11-08T21:38:50Z</updated>

		<summary type="html">&lt;p&gt;Zli36: Created page with &amp;quot;Classes involved:  All RSpec test files in Expertiza. What needs to be done:  Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all test...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Classes involved:  All RSpec test files in Expertiza.&lt;br /&gt;
What needs to be done:  Expertiza tests are really slow. If you check the TravisCI, it needs more than 9 min to run all tests. One reason is that we use fixture to create records in test DB each time running tests.&lt;br /&gt;
Formally, you need to:&lt;br /&gt;
* Create the records in test DB according to the content in fixtures.&lt;br /&gt;
* Check each test file and delete certain DB records creation code that insert default records (eg. create(:deadline_type)) &lt;br /&gt;
* And keep all the test cases passing when using test DB and make sure the time running test cases is shorter than before.&lt;br /&gt;
* You should submit the sql file of test DB to expertiza.&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=104748</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=104748"/>
		<updated>2016-11-08T21:36:49Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* 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;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=103021</id>
		<title>CSC/ECE 517 Fall 2016/E1675. Timestamp for student file &amp; hyperlink submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=103021"/>
		<updated>2016-10-28T21:02:55Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* Testing from UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passing===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
&lt;br /&gt;
#[https://youtu.be/cGXu1YPG0Ec Demo link]&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=103004</id>
		<title>CSC/ECE 517 Fall 2016/E1675. Timestamp for student file &amp; hyperlink submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=103004"/>
		<updated>2016-10-28T20:52:19Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* Parameter Passed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passing===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=102997</id>
		<title>CSC/ECE 517 Fall 2016/E1675. Timestamp for student file &amp; hyperlink submissions</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1675._Timestamp_for_student_file_%26_hyperlink_submissions&amp;diff=102997"/>
		<updated>2016-10-28T20:51:00Z</updated>

		<summary type="html">&lt;p&gt;Zli36: Created page with &amp;quot;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==  This page provides a description of the Expertiza based OSS project.    __TOC__   ===About Expertiza===  [http://ex...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016&amp;diff=102996</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=102996"/>
		<updated>2016-10-28T20:50:47Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* 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;br /&gt;
*[[CSC/ECE 517 Fall 2016/E1642. Refactor review_response_map.rb]]&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;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102962</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102962"/>
		<updated>2016-10-28T20:42:15Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* E1675.Timestamp for student file &amp;amp; hyperlink submissions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102959</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102959"/>
		<updated>2016-10-28T20:41:33Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&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;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102953</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102953"/>
		<updated>2016-10-28T20:40:17Z</updated>

		<summary type="html">&lt;p&gt;Zli36: /* E1675.Timestamp for student file &amp;amp; hyperlink submissions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&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;
#[https://github.com/rsndates/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102941</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102941"/>
		<updated>2016-10-28T20:38:31Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team.&lt;br /&gt;
* Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user-expertiza $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
66 examples, 0 failures&lt;br /&gt;
&lt;br /&gt;
Randomized with seed 19254&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Following are a few testcases with respectto our code changes that can be tried from UI:&lt;br /&gt;
1. To go to versions index page, type in the following url after logging in:&lt;br /&gt;
   http://152.46.16.81:3000/versions&lt;br /&gt;
&lt;br /&gt;
2. After logging in as student/instructor or admin : Try accessing the  new, create, edit, update actions. These actions are not allowed to any of the users.&lt;br /&gt;
   http://152.46.16.81:3000/versions/new&lt;br /&gt;
   This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.&lt;br /&gt;
&lt;br /&gt;
3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:&lt;br /&gt;
   http://152.46.16.81:3000/versions/search&lt;br /&gt;
&lt;br /&gt;
4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102937</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102937"/>
		<updated>2016-10-28T20:37:03Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team * Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
* In order to make the exist hyperlinks clickable, we will choose whose operation is Submit Hyperlink in database.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if record.operation == &amp;quot;Submit Hyperlink&amp;quot; %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;a href=&amp;quot;&amp;lt;%= record.content %&amp;gt;&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% else %&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;%= record.content %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
         &amp;lt;% end %&amp;gt;&lt;br /&gt;
        &amp;lt;td&amp;gt;&amp;lt;%= record.created_at %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parameter Passed===&lt;br /&gt;
We utilize the params hash from the previous view called List_submissions. We then use a where query that matches the team_id from the submissions record table.  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to &amp;quot;Show Submission Records&amp;quot;, submission_records_path(team_id: team.id) %&amp;gt;(View:list_submission)&lt;br /&gt;
     @submission_records = SubmissionRecord.where(team_id: params[:team_id])(submission_record_controller)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user-expertiza $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
66 examples, 0 failures&lt;br /&gt;
&lt;br /&gt;
Randomized with seed 19254&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Following are a few testcases with respectto our code changes that can be tried from UI:&lt;br /&gt;
1. To go to versions index page, type in the following url after logging in:&lt;br /&gt;
   http://152.46.16.81:3000/versions&lt;br /&gt;
&lt;br /&gt;
2. After logging in as student/instructor or admin : Try accessing the  new, create, edit, update actions. These actions are not allowed to any of the users.&lt;br /&gt;
   http://152.46.16.81:3000/versions/new&lt;br /&gt;
   This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.&lt;br /&gt;
&lt;br /&gt;
3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:&lt;br /&gt;
   http://152.46.16.81:3000/versions/search&lt;br /&gt;
&lt;br /&gt;
4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102799</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102799"/>
		<updated>2016-10-28T18:33:21Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team * Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
Relationships:&lt;br /&gt;
* belongs_to : teams&lt;br /&gt;
* has_many : list_submissions&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user-expertiza $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
66 examples, 0 failures&lt;br /&gt;
&lt;br /&gt;
Randomized with seed 19254&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Following are a few testcases with respectto our code changes that can be tried from UI:&lt;br /&gt;
1. To go to versions index page, type in the following url after logging in:&lt;br /&gt;
   http://152.46.16.81:3000/versions&lt;br /&gt;
&lt;br /&gt;
2. After logging in as student/instructor or admin : Try accessing the  new, create, edit, update actions. These actions are not allowed to any of the users.&lt;br /&gt;
   http://152.46.16.81:3000/versions/new&lt;br /&gt;
   This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.&lt;br /&gt;
&lt;br /&gt;
3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:&lt;br /&gt;
   http://152.46.16.81:3000/versions/search&lt;br /&gt;
&lt;br /&gt;
4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102797</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102797"/>
		<updated>2016-10-28T18:30:20Z</updated>

		<summary type="html">&lt;p&gt;Zli36: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team * Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured, create, update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right control to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====View Submission Record =====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user-expertiza $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
66 examples, 0 failures&lt;br /&gt;
&lt;br /&gt;
Randomized with seed 19254&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Following are a few testcases with respectto our code changes that can be tried from UI:&lt;br /&gt;
1. To go to versions index page, type in the following url after logging in:&lt;br /&gt;
   http://152.46.16.81:3000/versions&lt;br /&gt;
&lt;br /&gt;
2. After logging in as student/instructor or admin : Try accessing the  new, create, edit, update actions. These actions are not allowed to any of the users.&lt;br /&gt;
   http://152.46.16.81:3000/versions/new&lt;br /&gt;
   This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.&lt;br /&gt;
&lt;br /&gt;
3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:&lt;br /&gt;
   http://152.46.16.81:3000/versions/search&lt;br /&gt;
&lt;br /&gt;
4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102793</id>
		<title>User talk:Zli36</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User_talk:Zli36&amp;diff=102793"/>
		<updated>2016-10-28T18:25:21Z</updated>

		<summary type="html">&lt;p&gt;Zli36: Created page with &amp;quot;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==  This page provides a description of the Expertiza based OSS project.    __TOC__   ===About Expertiza===  [http://ex...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E1675.Timestamp for student file &amp;amp; hyperlink submissions ==&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
In Expertiza we accept hyperlinks as well as files submitted by students, which makes it harder to track the updates for students' submission. In this project you are required to keep track of timestamp records for students' submissions and updates of artifacts (submitted files or hyperlinks). Authors can delete or re-submit files and hyperlinks too, you should also have those activities recorded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Task Goals ===&lt;br /&gt;
What needs to be done: &lt;br /&gt;
&lt;br /&gt;
* Record the timestamps for file/hyperlink submissions.&lt;br /&gt;
* Add code to keep all those time stamps tracked and updated.&lt;br /&gt;
* Change the view of 0.0.0.0:3000/assignments/list_submissions view (by clicking the “View submissions icon”) to display the submition histories of each team * Make the available submissions clickable (some submitted items maight be deleted, so they are displayed but not clickable).&lt;br /&gt;
* After this project, the ResubmissionTime model (and related code) will not be used anymore. Please remove related code and db table.&lt;br /&gt;
* Create tests to make sure the test coverage increase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Program Design ===&lt;br /&gt;
&lt;br /&gt;
We created a set of new controller, model and views to finish the function for timestamps.&lt;br /&gt;
We added a model named SubmissionRecord that contains the following attributes.&lt;br /&gt;
&lt;br /&gt;
* Hyperlink - hyperlink that could be uploaded - String.&lt;br /&gt;
* Upload File - file that could be uploaded - File.&lt;br /&gt;
* Team id - id that links the model to the team that created it. - Integer.&lt;br /&gt;
* Created at - timestamp for time of creation.&lt;br /&gt;
* Operation - Description of what occured,create,update and delete.&lt;br /&gt;
* User - User who change the status of current table Get this from current user id.&lt;br /&gt;
* Content - String, the file name or the hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====Action_allowed=====&lt;br /&gt;
* In present code, the application has right controll to decide which kind of user could have access to the specific page. In order to let instructor see the submission_record, we need to add action_allowed method in submission_record_controller. Codes are here.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    if params[:action] == 'edit' || params[:action] == 'update'&lt;br /&gt;
      assignment = Assignment.find(params[:id])&lt;br /&gt;
      return true if ['Super-Administrator', 'Administrator'].include? current_role_name&lt;br /&gt;
      return true if assignment.instructor_id == current_user.id&lt;br /&gt;
      return true if TaMapping.exists?(ta_id: current_user.id, course_id: assignment.course_id) &amp;amp;&amp;amp;&lt;br /&gt;
      (TaMapping.where(course_id: assignment.course_id).include?TaMapping.where(ta_id: current_user.id, course_id: assignment.course_id).first)&lt;br /&gt;
      return true if assignment.course_id &amp;amp;&amp;amp; Course.find(assignment.course_id).instructor_id == current_user.id&lt;br /&gt;
      return false&lt;br /&gt;
    else&lt;br /&gt;
      ['Super-Administrator',&lt;br /&gt;
       'Administrator',&lt;br /&gt;
       'Instructor',&lt;br /&gt;
       'Teaching Assistant'].include? current_role_name&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Submit Hyperlink &amp;amp; File =====&lt;br /&gt;
* After we created the table, there isn't a specific page for us to fill in the submission_record database table. So we find the previous page for students to submitted their hyperlinks and files which are in submitted_content. And we add codes to fill in submission_record table once a hyperlink or file is submitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def submit_hyperlink&lt;br /&gt;
&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    team_hyperlinks = team.hyperlinks&lt;br /&gt;
    if team_hyperlinks.include?(params['submission'])&lt;br /&gt;
      flash[:error] = &amp;quot;You or your teammate(s) have already submitted the same hyperlink.&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      begin&lt;br /&gt;
        team.submit_hyperlink(params['submission'])&lt;br /&gt;
        @participant.update_resubmit_times&lt;br /&gt;
&lt;br /&gt;
        #create a submission record&lt;br /&gt;
        @submission_record = SubmissionRecord.new(team_id: team, user: @participant.name, assignment_id: params[:id], operation: &amp;quot;Submit Hyperlink&amp;quot;)&lt;br /&gt;
        @submission_record.save&lt;br /&gt;
      rescue&lt;br /&gt;
        flash[:error] = &amp;quot;The URL or URI is not valid. Reason: #{$ERROR_INFO}&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The link has been successfully submitted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Submit File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Remove Hyperlink or File=====&lt;br /&gt;
* When students want to delete their hyperlinks or files submitted before, the data in submission_record table should not disappear. What we want are all operations made by the team. As a result, we add specific code in the original delete function to reserve the data in submission_record table.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a submission record&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user:@participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove Hyperlink&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
    #create a submission record&lt;br /&gt;
    assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    @submission_record = SubmissionRecord.new(team_id: team.id, user: participant.name , assignment_id: assignment.id, operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
    @submission_record.save&lt;br /&gt;
    filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
    FileUtils.rm_r(filename)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza did not have any test for VersionsController. Using the test driven development(TDD) approach, we have added an exhaustive set of RSPEC tests for VersionsController, to test all the modifications we have done to the code of the controller class. The tests use double and stub features of rspec-rails gem, to fake the log in by different users - Administrator, Instructor, Student etc. The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user-expertiza $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
66 examples, 0 failures&lt;br /&gt;
&lt;br /&gt;
Randomized with seed 19254&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
Following are a few testcases with respectto our code changes that can be tried from UI:&lt;br /&gt;
1. To go to versions index page, type in the following url after logging in:&lt;br /&gt;
   http://152.46.16.81:3000/versions&lt;br /&gt;
&lt;br /&gt;
2. After logging in as student/instructor or admin : Try accessing the  new, create, edit, update actions. These actions are not allowed to any of the users.&lt;br /&gt;
   http://152.46.16.81:3000/versions/new&lt;br /&gt;
   This calls the new action. In the current production version of expertiza, it is unhandled and application gives a default 404 page.&lt;br /&gt;
&lt;br /&gt;
3. Another feature that can be tested from UI is Pagination. Try searching for a user's versions and see if the results are paginated or not. Search here:&lt;br /&gt;
   http://152.46.16.81:3000/versions/search&lt;br /&gt;
&lt;br /&gt;
4. Visit the same URL as step 3, you should see only the students under that instructor in the users dropdown.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
#[http://bit.ly/myexpertiza  Demo link] &lt;br /&gt;
#[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza project documentation wiki]&lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Zli36</name></author>
	</entry>
</feed>