<?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=Smagapu</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=Smagapu"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Smagapu"/>
	<updated>2026-08-13T12:11:21Z</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_E1687_Instructor_account_creation_over_the_web&amp;diff=106737</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106737"/>
		<updated>2016-12-11T04:51:55Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. Though the description of this table is similar to the users table, we thought it was better to go with a new one, keeping in view of the following advantages:&lt;br /&gt;
*  The users table had lot more entries which weren't needed for the requested user scenario and also vice-versa. The entries like status and reason of the '''requested_users''' table weren't necessary once the user request has been approved. This was lot more memory is saved.&lt;br /&gt;
* The users table was accessed at many places in Expertiza, so any change in that would have to be reflected at all places. It was comparatively easier to manage with a new table rather than using the existing one.&lt;br /&gt;
&lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We did write the test cases and pushed those to the github link submitted, but since we couldn't test them we have commented them. We have written test cases for the following functionalities separately. We have written them to be tested in RSpec. &lt;br /&gt;
&lt;br /&gt;
1. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
2. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;br /&gt;
&lt;br /&gt;
Note that we haven't tested for controller and views because, we were unable to run them. The controller and view tests might need lots of runs to finalize on the test.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106734</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106734"/>
		<updated>2016-12-11T02:26:03Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Working in UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
The steps mentioned below are tested in this scenario:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor6 rejects the suggestion. &lt;br /&gt;
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
This scenario accounts for testing the following steps:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor votes for the suggestion. &lt;br /&gt;
* Then the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
The scenario comprises of testing the following steps:&lt;br /&gt;
* The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. &lt;br /&gt;
* After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. &lt;br /&gt;
* The Instructor6 logs in, visits Assignment 1 suggestions to approve the suggestion “Computer Vision”. &lt;br /&gt;
* On approving the suggestion, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered for the instructor.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved.&lt;br /&gt;
&lt;br /&gt;
This can be verified through the uploaded videos on [https://www.youtube.com/watch?v=TOhofFEjgcM&amp;amp;feature=youtu.be tests] and [https://vimeo.com/190331266 functioning].&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106727</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106727"/>
		<updated>2016-12-10T23:58:24Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 6 - Suggestion with no Signup approved */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
The steps mentioned below are tested in this scenario:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor6 rejects the suggestion. &lt;br /&gt;
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
This scenario accounts for testing the following steps:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor votes for the suggestion. &lt;br /&gt;
* Then the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
The scenario comprises of testing the following steps:&lt;br /&gt;
* The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. &lt;br /&gt;
* After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. &lt;br /&gt;
* The Instructor6 logs in, visits Assignment 1 suggestions to approve the suggestion “Computer Vision”. &lt;br /&gt;
* On approving the suggestion, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered for the instructor.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106726</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106726"/>
		<updated>2016-12-10T23:55:13Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 5 - Suggestion Voted */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
The steps mentioned below are tested in this scenario:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor6 rejects the suggestion. &lt;br /&gt;
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
This scenario accounts for testing the following steps:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor votes for the suggestion. &lt;br /&gt;
* Then the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106725</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106725"/>
		<updated>2016-12-10T23:54:53Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 5 - Suggestion Voted */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
The steps mentioned below are tested in this scenario:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor6 rejects the suggestion. &lt;br /&gt;
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
This scenario accounts for testing the following steps:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and should be able to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor votes for the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106724</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106724"/>
		<updated>2016-12-10T23:53:39Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 4 - Suggestion Rejected */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
The steps mentioned below are tested in this scenario:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 for Assignment 1. &lt;br /&gt;
* After checking the comment by student2064, Instructor6 rejects the suggestion. &lt;br /&gt;
* The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106723</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106723"/>
		<updated>2016-12-10T23:52:41Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 3 - Suggestion Accepted */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
This scenario accounts for the testing the following:&lt;br /&gt;
* Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. &lt;br /&gt;
* Instructor6 logs in and checks on Assignment 1. &lt;br /&gt;
* After logging in, instructor checks that “Computer Vision” is submitted by student2064 &lt;br /&gt;
* Also the comment by the student can be viewed. &lt;br /&gt;
* After looking at the topic, the instructor approves the suggestion. &lt;br /&gt;
* Then, when the Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106722</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106722"/>
		<updated>2016-12-10T23:51:07Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 1 - Check suggested topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This automatic test case checks the following steps:&lt;br /&gt;
* User (Instructor6) logins in.&lt;br /&gt;
* On successful login, the instructor clicks the tab for Suggestions list for a particular assignment (Assignment 1).&lt;br /&gt;
* On visiting that tab, a page with content &amp;quot;Suggested topics for Assignment 1&amp;quot; is rendered with the topic name.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106721</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106721"/>
		<updated>2016-12-10T23:04:50Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Refactoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Note that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106720</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106720"/>
		<updated>2016-12-10T23:04:41Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Refactoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
Refactoring that was done for this project is:&lt;br /&gt;
* There were lot of trailing spaces in the code, which are removed. &lt;br /&gt;
* Few lines were too long and one had to scroll right to go through that line. This was taken care of as shown below. &lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
* We have edited the flash messages making them more intuitive. Also, the subject of the email that is sent has been modified to keep it more self-explanatory.&lt;br /&gt;
* An unused method, &amp;quot;confirm_save&amp;quot; has been removed.&lt;br /&gt;
* Comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
Notice that there was nothing more in terms of refactoring, as the code has been already refactored.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106719</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106719"/>
		<updated>2016-12-10T22:59:21Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Refactoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
[[File:Oss_1.PNG]]&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Oss_1.PNG&amp;diff=106718</id>
		<title>File:Oss 1.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Oss_1.PNG&amp;diff=106718"/>
		<updated>2016-12-10T22:58:57Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: uploaded a new version of &amp;amp;quot;File:Oss 1.PNG&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106717</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106717"/>
		<updated>2016-12-10T22:58:05Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Refactoring */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
[[File: oss_1.png]]&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Oss_1.PNG&amp;diff=106716</id>
		<title>File:Oss 1.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Oss_1.PNG&amp;diff=106716"/>
		<updated>2016-12-10T22:57:13Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106715</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106715"/>
		<updated>2016-12-10T22:39:18Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 2 - New Suggestion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106714</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106714"/>
		<updated>2016-12-10T22:38:36Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 6 - Suggestion approved but no signup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion with no Signup approved ====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106713</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106713"/>
		<updated>2016-12-10T22:38:10Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 6 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 - Suggestion approved but no signup====&lt;br /&gt;
&lt;br /&gt;
The Student2064 logs in and visits Assignment 1 to suggest “Computer Vision” topic. After suggesting, the student selects “No” for suggestion signup preference and submits suggestion. The Instructor6 logs in, visits Assignment 1 suggestions to approves suggestion “Computer Vision”. On approving the instructor, a page saying &amp;quot;suggestion approved successfully&amp;quot; is rendered.&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106712</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106712"/>
		<updated>2016-12-10T22:33:40Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 5 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 - Suggestion Voted ====&lt;br /&gt;
The Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in, checks that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor votes for the suggestion. Then when the Student2064 logs in, visits Assignment 1 to check that Instructor6 has voted for the suggestion.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106711</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106711"/>
		<updated>2016-12-10T22:31:27Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 3 - Suggestion Acceptance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Accepted====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106710</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106710"/>
		<updated>2016-12-10T22:31:06Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Acceptance====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 - Suggestion Rejected====&lt;br /&gt;
When Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. The Instructor6 logs in to check that “Computer Vision” is submitted by student2064 fro Assignment 1. After checking the comment by student2064, Instructor6 rejects the suggestion. The Student2064 logs in, visits Assignment 1 to find out that the suggestion “Computer Vision” has been rejected.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106709</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106709"/>
		<updated>2016-12-10T22:27:01Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 3 - */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - Suggestion Acceptance====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106708</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106708"/>
		<updated>2016-12-10T22:26:46Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 - ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1. Instructor6 logs in and checks on Assignment 1. After logging in, instructor checks that “Computer Vision” is submitted by student2064 and also the comment by the student. After looking at the topic, the instructor approves the suggestion. When Student2064 logs in and visits Assignment 1, he/she can check that the suggestion “Computer Vision” has been accepted.&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106707</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106707"/>
		<updated>2016-12-10T22:24:20Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 2 - New Suggestion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 approves the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; &lt;br /&gt;
Checks suggestion “Computer Vision” is accepted&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106706</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106706"/>
		<updated>2016-12-10T22:24:04Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 2 - New Suggestion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
* When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
* And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
* Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
* Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
* Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other scenarios that were tested are given below&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 approves the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; &lt;br /&gt;
Checks suggestion “Computer Vision” is accepted&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106705</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106705"/>
		<updated>2016-12-10T22:23:18Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 - New Suggestion====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully.&lt;br /&gt;
We have considered Student2064 for this case. We test for all the following cases:&lt;br /&gt;
# When Student2064 logs in, visits Assignment 1, clicks on new suggestion and submits a new topic. Upon submitting the topic, a page with the content saying &amp;quot;Thank you for your suggestion! Suggested topics for Assignment 1, &amp;quot;Topic title&amp;quot; initiated&amp;quot;,   should be rendered. &lt;br /&gt;
# And if view is clicked, a page with the content &amp;quot;View Suggested topic Computer Vision&amp;quot; is displayed. &lt;br /&gt;
# Adding a comment - Tests the case when a student submits the comment and whether a page with successful submission is resulted.&lt;br /&gt;
# Blank comment - In case a blank comment is added, an error should be generated. &lt;br /&gt;
# Edit title and description - Tests if changing the title and description and submitting, renders the page with the changed title and description. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other scenarios that were tested are given below&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 approves the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; &lt;br /&gt;
Checks suggestion “Computer Vision” is accepted&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106704</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106704"/>
		<updated>2016-12-10T19:56:25Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 1 - Check suggested topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
This test case is to test automatically the situation when the instructor once logged in can visit the suggested topics page for any Assignment 1. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other scenarios that were tested are given below&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 approves the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; &lt;br /&gt;
Checks suggestion “Computer Vision” is accepted&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106703</id>
		<title>CSC/ECE 517 Fall 2016/E1643. Refactor Suggestion controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016/E1643._Refactor_Suggestion_controller&amp;diff=106703"/>
		<updated>2016-12-10T19:03:40Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Scenario 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1643. Refactor and Test Suggestion Controller'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the OSS project of refactoring and testing the suggestion controller of Expertiza.&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites. &lt;br /&gt;
&lt;br /&gt;
== '''Motivation''' ==&lt;br /&gt;
This provides a great opportunity for the students to learn through collaboration. It provides a chance to contribute to an open source project. One would take back experience of working on Rails, and testing environments like RSpec. Being one of the primary user of Expertiza, students would enhance the functionalities according to their experiences using it and can view their changes implemented real-time.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
Our files to be modified are: &lt;br /&gt;
* app/views/mailer/suggested_topic_approved_message.html.erb&lt;br /&gt;
* spec/features/topic_suggestion2_spec.rb&lt;br /&gt;
&lt;br /&gt;
The current folder of suggestion_controller.rb provides a chance to suggest a new topic to work on for a project. There is also an option for the student to not work on it. One can also submit the suggestion anonymously. Once a student submits the topic, the instructor can check that in the view suggestions tab, and can either approve or reject. Once the instructor approves, the student gets a mail regarding the approval. This mail is sent only if the student doesn’t submit the topic anonymously. In the process of assigning the given suggestion as a project topic to the student, it automatically gets assigned to the whole team if the student is part of a team. &lt;br /&gt;
&lt;br /&gt;
Our problem statement includes:&lt;br /&gt;
&lt;br /&gt;
1. Modifying the code in accordance to rails 4 syntax&lt;br /&gt;
&lt;br /&gt;
2. Send email code which was duplicated needs to be replaced by a single method&lt;br /&gt;
&lt;br /&gt;
3. Fix and test the working of email functionality (an email is sent to the student who suggested the topic once the instructor approves, unless he/she sends it anonymously)&lt;br /&gt;
&lt;br /&gt;
4. Write integration tests for each method in suggestion_controller.rb (including some edge cases)&lt;br /&gt;
&lt;br /&gt;
== '''Setup''' ==&lt;br /&gt;
Before starting off with working on the Expertiza project, we need to fork the existing code from [https://github.com/expertiza/expertiza expertiza/master branch]. We are provided with 3 methods of setting up Expertiza: Docker, setting it up locally and using Expertiza image. We are describing the first two methods (the ones we used) below.&lt;br /&gt;
&lt;br /&gt;
=== Docker ===&lt;br /&gt;
&lt;br /&gt;
The Docker has been set up on a Windows PC and steps are given below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Docker on Windows&lt;br /&gt;
&lt;br /&gt;
docker run --expose 3000 -p 3000:3000 -v //c//Users//Srikar//Expertiza://c//Users//Srikar//Expertiza -it winbobob/expertiza-fall2016&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/mysql start   &lt;br /&gt;
mysql -uroot -p           &lt;br /&gt;
show databases;  &lt;br /&gt;
quit&lt;br /&gt;
&lt;br /&gt;
git clone https://github.com/srikarpotta/expertiza.git&lt;br /&gt;
cd expertiza&lt;br /&gt;
cp config/database.yml.example config/database.yml&lt;br /&gt;
cp config/secrets.yml.example config/secrets.yml&lt;br /&gt;
&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:migrate&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
npm install -g bower&lt;br /&gt;
&lt;br /&gt;
sudo rm /usr/bin/node&lt;br /&gt;
sudo ln –s /usr/bin/nodejs /usr/bin/node&lt;br /&gt;
bower install --allow-root&lt;br /&gt;
thin start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== On a Local Machine ===&lt;br /&gt;
We have used MacOS, so the following steps are in regard to MacOS.&lt;br /&gt;
The following steps will help you set up Expertiza project in your local machine. The steps are comprehensive amalgamation of steps mentioned in [http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX Development Setup], the [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit?pli=1 document]provided and also few steps that were missed in both. The order we followed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#Fork the git repository mentioned above&lt;br /&gt;
&lt;br /&gt;
#Clone the repository to your local machine&lt;br /&gt;
Install [http://brew.sh/ Homebrew]&lt;br /&gt;
&lt;br /&gt;
#Install RBENV&lt;br /&gt;
brew update&lt;br /&gt;
brew install rbenv&lt;br /&gt;
brew install ruby-build&lt;br /&gt;
&lt;br /&gt;
#Install dependencies&lt;br /&gt;
brew install aspell gcc47 libxml2 libxslt graphviz&lt;br /&gt;
&lt;br /&gt;
#Install gems&lt;br /&gt;
export JAVA_HOME=/etc/alternatives/java_sdk&lt;br /&gt;
bundle install&lt;br /&gt;
&lt;br /&gt;
#Change yml files&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename secrets.yml.example to secrets.yml&lt;br /&gt;
&lt;br /&gt;
#Go to expertiza/config and rename database.yml.example to database.yml&lt;br /&gt;
&lt;br /&gt;
#Edit database.yml to include the root password for your local MySQL in the “password” field&lt;br /&gt;
&lt;br /&gt;
#Install mysql (https://gist.github.com/nrollr/a8d156206fa1e53c6cd6) &lt;br /&gt;
&lt;br /&gt;
#Log into MySql as root (mysql is generally present in /usr/local/mysql/bin/)&lt;br /&gt;
mysql -uroot -p&lt;br /&gt;
&lt;br /&gt;
#Create expertiza user&lt;br /&gt;
create user expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Create the databases&lt;br /&gt;
create database pg_development;&lt;br /&gt;
create database pg_test;&lt;br /&gt;
&lt;br /&gt;
#Set privileges for expertiza user&lt;br /&gt;
grant all on pg_development.to expertiza@localhost;&lt;br /&gt;
grant all on pg_test.to expertiza@localhost;&lt;br /&gt;
&lt;br /&gt;
#Install javascript libraries&lt;br /&gt;
sudo apt-get install npm&lt;br /&gt;
sudo npm install bower&lt;br /&gt;
bower install&lt;br /&gt;
&lt;br /&gt;
#Download the expertiza scrubbed library (https://drive.google.com/file/d/0B2vDvVjH76uEMDJhNjZVOUFTWmM/view) &lt;br /&gt;
&lt;br /&gt;
#Load this sql file into pg_development database created using the method mentioned here.&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:migrate&lt;br /&gt;
&lt;br /&gt;
#Run bundle exec rake db:test:prepare&lt;br /&gt;
&lt;br /&gt;
#Run rails s&lt;br /&gt;
&lt;br /&gt;
#Open browser and test localhost:3000&lt;br /&gt;
&lt;br /&gt;
#Login credentials&lt;br /&gt;
Username - instructor6&lt;br /&gt;
Password - password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Our Implementation''' ==&lt;br /&gt;
There is a partial coverage of suggstion_controller using feature test and also the email functionality wasn't working. We have fixed the email functionality and also refactored parts of the code. As per our knowledge we couldn't find any code in accordance to Ruby 2 syntax. &lt;br /&gt;
&lt;br /&gt;
==='''Refactoring''' ===&lt;br /&gt;
There were lot of trailing spaces in the code, which are removed. Few lines were too long and one had to scroll right to go through that line. This was taken care of. We have also edited the messages, making them more readable and logical. Also, the unused methods in the code were removed. &lt;br /&gt;
&lt;br /&gt;
The comments were added for future readability.&lt;br /&gt;
&lt;br /&gt;
=== '''Email functionality''' ===&lt;br /&gt;
The email functionality which wasn't working before has been fixed. These are the cases considered:&lt;br /&gt;
Instructor starts a new assignment with some topics&lt;br /&gt;
* Student signs up for one topic, suggests a new one but doesn't want to work on it. Then the student receives a mail once the instructor approves.&lt;br /&gt;
* Student doesn't sign up for a topic and suggests a new one. If the student opts to work on it, then on approval, a mail is sent. If the student doesn't want to work on it, then no mail is sent even on approval. &lt;br /&gt;
* It is a team project - if there is already a team and they come up with a new topic and want to work on it, then a mail is sent on approval. If there isn't a team and a student suggests a new topic, a topic is assigned on approval and also a team of students who choose that topic. In this case, there is no email notification.&lt;br /&gt;
* A team project - there is a team and they suggest a topic but choose not to work on it and also they haven't signed up for a topic. In this case, upon the acceptance of topic by the instructor, there is no email sent and they are supposed to sign up for a topic from the given set.&lt;br /&gt;
&lt;br /&gt;
Irrespective of teams and topic, if someone suggests a topic anonymously, there won't be any email notification on approval of the topic. The key point here is there should be a signup preference that should be set for the notification. &lt;br /&gt;
&lt;br /&gt;
We have used the following accounts for testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* Login ID - instructor6                Password - password&lt;br /&gt;
* Student1 ID - student5432             Password - password&lt;br /&gt;
* Student2 Id - student5404             Password - password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The implementation can be seen in the video, where we covered few cases mentioned above.&lt;br /&gt;
&lt;br /&gt;
=== '''Testing''' ===&lt;br /&gt;
We were tasked with writing integration test cases for suggestion_controller. We came up with 6 end-to-end test cases to test “integration” of suggestion controller with other models, controllers and views. The test script can be found [https://github.com/anubhabMajumdar/expertiza/blob/amajumd/spec/features/topic_suggestion2_spec.rb here].&lt;br /&gt;
&lt;br /&gt;
==== Prerequisite ====&lt;br /&gt;
All the scenarios uses the following:&lt;br /&gt;
* Instructor6&lt;br /&gt;
* Student2064&lt;br /&gt;
* Assignment 1&lt;br /&gt;
&lt;br /&gt;
==== Scenario 1 - Check suggested topics====&lt;br /&gt;
Instructor6 logs in and visits assignment 1 to check suggested topics (currently empty)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
scenario &amp;quot;allow instructor to log in and view suggestions (suggestions should be empty) for Assignment 1&amp;quot; do	&lt;br /&gt;
   user = User.find_by_name('instructor6')&lt;br /&gt;
   stub_current_user(user, user.role.name, user.role)&lt;br /&gt;
   visit '/suggestion/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
   expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot; &lt;br /&gt;
   expect(page).to have_no_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Scenario 2 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in -&amp;gt; Visits on Assignment 1 -&amp;gt; Clicks on new suggestion -&amp;gt; Submits new topic called “Computer Vision” -&amp;gt; Checks submission is successful -&amp;gt; Adds comment -&amp;gt; Submits comment -&amp;gt; Checks successful submission of comment -&amp;gt; Tries submitting blank comment -&amp;gt; Checks unsuccessful submission of blank comment -&amp;gt; Tries editing suggestion title and suggestion description -&amp;gt; Checks edit is successful -&amp;gt; Logs out successfully&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Create new suggestion (Computer Vision)&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion'&lt;br /&gt;
select &amp;quot;N&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Thank you for your suggestion!&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision&amp;quot;	&lt;br /&gt;
expect(page).to have_content &amp;quot;Initiated&amp;quot;	&lt;br /&gt;
		&lt;br /&gt;
# View the suggestion&lt;br /&gt;
find_link('View').click&lt;br /&gt;
expect(page).to have_content &amp;quot;View Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Add comment&lt;br /&gt;
fill_in 'suggestion_comment_comments', with: 'Student2064 commenting on Computer Vision'&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;Your comment has been successfully added.&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Student2064 commenting on Computer Vision&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Try adding blank comment&lt;br /&gt;
click_button 'Submit comment'&lt;br /&gt;
expect(page).to have_content &amp;quot;There was an error adding your comment.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Edit title and description&lt;br /&gt;
find_link('Edit').click&lt;br /&gt;
expect(page).to have_content &amp;quot;Edit Suggested topic Computer Vision&amp;quot;&lt;br /&gt;
fill_in 'suggestion_title', with: 'Computer Vision 2'&lt;br /&gt;
fill_in 'suggestion_description', with: 'This is a Computer Vision suggestion 2'&lt;br /&gt;
select &amp;quot;Y&amp;quot;, :from =&amp;gt; &amp;quot;suggestion_signup_preference&amp;quot;&lt;br /&gt;
click_button 'Submit'&lt;br /&gt;
expect(page).to have_content &amp;quot;Suggested topics for Assignment 1&amp;quot;&lt;br /&gt;
expect(page).to have_content &amp;quot;Computer Vision 2&amp;quot;	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other scenarios that were tested are given below&lt;br /&gt;
&lt;br /&gt;
==== Scenario 3 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 approves the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; &lt;br /&gt;
Checks suggestion “Computer Vision” is accepted&lt;br /&gt;
&lt;br /&gt;
==== Scenario 4 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt; Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064 -&amp;gt; Instructor6 rejects the suggestion -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks suggestion “Computer Vision” is rejected&lt;br /&gt;
&lt;br /&gt;
==== Scenario 5 ====&lt;br /&gt;
Student2064 logs in and suggests a topic (Computer Vision) under Assignment 1 -&amp;gt;Instructor6 logs in and checks on Assignment 1 -&amp;gt; Checks that “Computer Vision” is submitted by student2064 -&amp;gt; Checks comment by student2064  -&amp;gt; Instructor votes for the suggestion  -&amp;gt; Student2064 logs in -&amp;gt; Visits Assignment 1 -&amp;gt; Checks Instructor6 has voted for the suggestion&lt;br /&gt;
&lt;br /&gt;
==== Scenario 6 ====&lt;br /&gt;
&lt;br /&gt;
Student2064 logs in and visits Assignment 1 -&amp;gt; Suggests “Computer Vision” -&amp;gt; Select “No” for suggestion signup preference -&amp;gt; Submits suggestion -&amp;gt; Instructor6 logs in and visits Assignment 1 suggestions -&amp;gt; Approves suggestion “Computer Vision” -&amp;gt; Checks suggestion approved successfully&lt;br /&gt;
&lt;br /&gt;
=== Why these scenarios? ===&lt;br /&gt;
&lt;br /&gt;
The scenarios are carefully designed to fulfill the following criteria:&lt;br /&gt;
*Test the integration of core functionalities of suggestion controller&lt;br /&gt;
*Have maximum code coverage&lt;br /&gt;
*Not to repeat scenarios developed by another contributor in topic_suggestion_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''' We have submitted two links to show the working of email functionality and the other one to show the tests. As suggested by the professor, this is done as an alternative to deployment. ''''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Working in UI ===&lt;br /&gt;
The steps are given as follows:&lt;br /&gt;
# Sign in Expertiza using the instructor account (login credentials mentioned above)&lt;br /&gt;
# Go to Manage tab, then click Assignments, and click New Public Assignment&lt;br /&gt;
# Give all the necessary details (Name of assignment, rubrics, due dates etc..) '''Do not forget to click on Allow students to suggest topic'''&lt;br /&gt;
# Go to Manage assignments tab, and in the assignment you just created, click on add participants and select copy from course &lt;br /&gt;
# Login from student credentials (mentioned earlier) and go to the assignment that was created&lt;br /&gt;
# Either sign up for the topic or suggest a new one directly&lt;br /&gt;
# Now to instructor account and view suggestions against the assignment created&lt;br /&gt;
# The instructor can approve or decline&lt;br /&gt;
# Open the gmail account (id: expertiza.development@gmail.com, password: qwer@1234) and look for mail if approved&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
=== What we learnt ===&lt;br /&gt;
* How to read existing codebases&lt;br /&gt;
* Understand other people’s code before contributing&lt;br /&gt;
* Refactor existing code without breaking existing functionalities&lt;br /&gt;
* Write integration test cases &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== What’s next? ===&lt;br /&gt;
&lt;br /&gt;
“'''Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.'''” - Edsger Dijkstra&lt;br /&gt;
&lt;br /&gt;
Thus, the best way to uncover bugs lurking in our code is to come up with more scenarios and implement them. We have tested the most business critical scenarios and few edge cases were covered by creators of topic_suggestion_spec.rb. They only show the absence of bugs in the routes we are following to reach from point A to point B. However, many such scenarios exists which are not yet covered. We hope to extend our work further in future to cover many such scenarios.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106552</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106552"/>
		<updated>2016-12-05T19:43:13Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. Though the description of this table is similar to the users table, we thought it was better to go with a new one, keeping in view of the following advantages:&lt;br /&gt;
*  The users table had lot more entries which weren't needed for the requested user scenario and also vice-versa. The entries like status and reason of the '''requested_users''' table weren't necessary once the user request has been approved. This was lot more memory is saved.&lt;br /&gt;
* The users table was accessed at many places in Expertiza, so any change in that would have to be reflected at all places. It was comparatively easier to manage with a new table rather than using the existing one.&lt;br /&gt;
&lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We did write the test cases and pushed those to the github link submitted, but since we couldn't test them we have commented them. We have written test cases for the following functionalities separately. We have written them to be tested in RSpec. &lt;br /&gt;
&lt;br /&gt;
1. Test all views - tested if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
NOTE that the controller shall have test cases for only these methods. &lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106551</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106551"/>
		<updated>2016-12-05T19:24:22Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Problem 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. Though the description of this table is similar to the users table, we thought it was better to go with a new one, keeping in view of the following advantages:&lt;br /&gt;
*  The users table had lot more entries which weren't needed for the requested user scenario and also vice-versa. The entries like status and reason of the '''requested_users''' table weren't necessary once the user request has been approved. This was lot more memory is saved.&lt;br /&gt;
* The users table was accessed at many places in Expertiza, so any change in that would have to be reflected at all places. It was comparatively easier to manage with a new table rather than using the existing one.&lt;br /&gt;
&lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106550</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106550"/>
		<updated>2016-12-05T19:21:28Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. Though the description of this table is similar to the users table, we thought it was better to go with a new one, keeping in view of the following advantages:&lt;br /&gt;
*  The users table had lot more entries which weren't needed for the requested user scenario and also vice-versa. The entries like status and reason of the '''requested_users''' table weren't necessary once the user request has been approved. This was lot more memory is saved.&lt;br /&gt;
* The users table was accessed at many places in Expertiza, so any change in that would have to be reflected at all places. It was comparatively easier to manage with a new table rather than using the existing one.&lt;br /&gt;
&lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106549</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106549"/>
		<updated>2016-12-05T19:03:47Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106548</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106548"/>
		<updated>2016-12-05T19:03:20Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
Note that we have used the existing modules and developed these pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below. We have put the review requested users in the menu, rather than a separate tab, making it more flexible to integrate some more features under the users option later. &lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below. This is an entirely new page wherein, the super admin can also mention the reason for a rejection of a request and view the entire list of requested users. &lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. &lt;br /&gt;
* Method 1 - request_user_create. This is to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Upon the request, this method uses the user parameters (fields entered in the request sign-up form) and a status of 'Under review' is assigned by default. On verifying the captcha, the super admin(s) gets a mail regarding the request with the user name and the requested user is redirected to the instructions page.  &lt;br /&gt;
* Method 2 - create_approved_user. This is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login.&lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106547</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106547"/>
		<updated>2016-12-05T18:46:21Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the '''Review Requested Users''' tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying that they now have the permission to access the features of Expertiza. A temporary password in clear text is also sent in the mail for login. If the request is rejected, then the reason should be mentioned in the reason column of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few 'publicly visible features' as it denies access completely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user requests for an account, upon clicking the '''request sign up''', he/she is automatically redirected to the instructions page with the video tutorials explaining various features of Expertiza and on how to access them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Manage/users/review requested users''' menu as shown below&lt;br /&gt;
[[File:Approval_new2.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Screencast'''==&lt;br /&gt;
&lt;br /&gt;
Screencast [https://youtu.be/Ro8YVQgdgIg link] to our demonstration&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106453</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106453"/>
		<updated>2016-12-03T23:12:28Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model '''requested_user''' so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106452</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106452"/>
		<updated>2016-12-03T23:12:06Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods. New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model requested_user so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106451</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106451"/>
		<updated>2016-12-03T23:11:47Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views - will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
* Does '''create_approved_user''' actually create a new user&lt;br /&gt;
* Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model requested_user so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106450</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106450"/>
		<updated>2016-12-03T23:11:20Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''' and '''Request_new.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
# Does '''create_approved_user''' actually create a new user&lt;br /&gt;
# Does '''request_user_create''' actually not create a new user request&lt;br /&gt;
&lt;br /&gt;
3. Test the model requested_user so that no invalid entries (blank email ID, blank name etc.) are accepted. &lt;br /&gt;
&lt;br /&gt;
4. Test the mailer to verify if the body, subject, the mail id sent to/from are correctly functioning.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106449</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106449"/>
		<updated>2016-12-03T23:04:05Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_approval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_approval_table.png&amp;diff=106448</id>
		<title>File:Req approval table.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_approval_table.png&amp;diff=106448"/>
		<updated>2016-12-03T23:03:37Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106447</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106447"/>
		<updated>2016-12-03T23:01:46Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. The description of the table is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106446</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106446"/>
		<updated>2016-12-03T23:01:21Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''. The status column, which isn't present in the users tables indicates the approval/rejection of the request of the user. &lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106445</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106445"/>
		<updated>2016-12-03T23:00:15Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We have created a new table called '''requested_users''' with table description that is similar to '''users'''&lt;br /&gt;
The description of the table is as follows:&lt;br /&gt;
[[File:Requested_user_db.png‎ ]]&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Requested_user_db.png&amp;diff=106443</id>
		<title>File:Requested user db.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Requested_user_db.png&amp;diff=106443"/>
		<updated>2016-12-03T22:58:15Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106440</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106440"/>
		<updated>2016-12-03T22:55:10Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def create_approved_user&lt;br /&gt;
    @user = RequestedUser.find params[:id]&lt;br /&gt;
    @user.status=params[:status]&lt;br /&gt;
    @user.reason=params[:reason]&lt;br /&gt;
    if @user.status.nil?&lt;br /&gt;
      flash[:error] = &amp;quot;Please Approve or Reject before submitting&amp;quot;&lt;br /&gt;
    elsif @user.update_attributes(params[:user])&lt;br /&gt;
      flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @user.status==&amp;quot;Approved&amp;quot;&lt;br /&gt;
      check = User.find_by_name(@user.name)&lt;br /&gt;
      @usernew = User.new()&lt;br /&gt;
      @usernew.name = @user.name&lt;br /&gt;
      @usernew.role_id = @user.role_id&lt;br /&gt;
      @usernew.institution_id = @user.institution_id&lt;br /&gt;
      @usernew.fullname = @user.fullname&lt;br /&gt;
      @usernew.email = @user.email&lt;br /&gt;
      # record the person who created this new user&lt;br /&gt;
      @usernew.parent_id = session[:user].id&lt;br /&gt;
      # set the user's timezone to its parent's&lt;br /&gt;
      @usernew.timezonepref = User.find(@usernew.parent_id).timezonepref&lt;br /&gt;
&lt;br /&gt;
      if @usernew.save&lt;br /&gt;
        password = @usernew.reset_password # the password is reset&lt;br /&gt;
        # Mail is sent to the user with a new password&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_user(@usernew, &amp;quot;Your Expertiza account and password &lt;br /&gt;
                                                            have been created.&amp;quot;, &amp;quot;user_welcome&amp;quot;, password)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
        flash[:success] = &amp;quot;A new password has been sent to new user's e-mail address.&amp;quot;&lt;br /&gt;
        if @usernew.role.name == &amp;quot;Instructor&amp;quot; or @usernew.role.name == &amp;quot;Administrator&amp;quot;&lt;br /&gt;
          AssignmentQuestionnaire.create(user_id: @user.id)&lt;br /&gt;
        end&lt;br /&gt;
        undo_link(&amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been successfully created. &amp;quot;)&lt;br /&gt;
      else&lt;br /&gt;
        foreign&lt;br /&gt;
      end&lt;br /&gt;
    else &lt;br /&gt;
      if @user.status==&amp;quot;Rejected&amp;quot;    &lt;br /&gt;
        #If the user request has been rejected, a flash message is shown and redirected to review page&lt;br /&gt;
        if @user.update_columns(reason: params[:reason], status: params[:status])&lt;br /&gt;
          flash[:success] = &amp;quot;The user \&amp;quot;#{@user.name}\&amp;quot; has been Rejected.&amp;quot;&lt;br /&gt;
          redirect_to action: 'review'&lt;br /&gt;
          return&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;Error processing request.&amp;quot;&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'review'&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We will be creating a new table called '''request_users''' with table description that is similar to '''users'''&lt;br /&gt;
Below is the table description of '''users''' table.&lt;br /&gt;
[[File:Users.png]]&lt;br /&gt;
&lt;br /&gt;
Our '''request_users''' will also be having a new column called '''status''' which describes that the user is approved or rejected.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106439</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106439"/>
		<updated>2016-12-03T22:53:35Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file in instructions, named home.html.erb is created which will have all the videos explaining how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods. One method (request_user_create) to the new user to request for an account in Expertiza and also mail all the super admins about the new user request. Other method (create_approved_user) is for the super admin to either approve or reject the user request and send a mail to the requested user if his/her account is created. The mail also contains a password for the user to login. &lt;br /&gt;
&lt;br /&gt;
The codes for each method are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def request_user_create&lt;br /&gt;
    #TODO: Do not allow duplicates&lt;br /&gt;
    #TODO: All fields should be entered&lt;br /&gt;
    @user = RequestedUser.new(user_params)&lt;br /&gt;
    @user.institution_id = params[:user][:institution_id]&lt;br /&gt;
    @user.status = 'Under Review'&lt;br /&gt;
    #The super admin receives a mail about a new user request with the user name&lt;br /&gt;
    if verify_recaptcha(model: @user) &amp;amp;&amp;amp; @user.save&lt;br /&gt;
      @super_users = User.joins(:role).where('roles.name' =&amp;gt;'Super-Administrator');&lt;br /&gt;
      @super_users.each do |super_user|&lt;br /&gt;
        prepared_mail = MailerHelper.send_mail_to_all_super_users(super_user,@user, &amp;quot;New account Request&amp;quot;)&lt;br /&gt;
        prepared_mail.deliver&lt;br /&gt;
      end&lt;br /&gt;
      flash[:success] = &amp;quot;User signup for \&amp;quot;#{@user.name}\&amp;quot; has been successfully requested. &amp;quot;&lt;br /&gt;
      redirect_to '/instructions/home'&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Error requesting sign up &amp;quot;&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'users', :action =&amp;gt; 'request_new', :role=&amp;gt;&amp;quot;Student&amp;quot;   &lt;br /&gt;
    end&lt;br /&gt;
  end  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We will be creating a new table called '''request_users''' with table description that is similar to '''users'''&lt;br /&gt;
Below is the table description of '''users''' table.&lt;br /&gt;
[[File:Users.png]]&lt;br /&gt;
&lt;br /&gt;
Our '''request_users''' will also be having a new column called '''status''' which describes that the user is approved or rejected.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_aproval_table.png&amp;diff=106436</id>
		<title>File:Req aproval table.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_aproval_table.png&amp;diff=106436"/>
		<updated>2016-12-03T22:43:41Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: uploaded a new version of &amp;amp;quot;File:Req aproval table.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106432</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106432"/>
		<updated>2016-12-03T22:38:29Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will have to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The view for this page would be as shown below.&lt;br /&gt;
[[File:req_aproval_table.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file called Instructions.html.erb which will have all the videos and instructions on how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods:&lt;br /&gt;
&lt;br /&gt;
1. '''request_list'''&lt;br /&gt;
&lt;br /&gt;
 def request_list&lt;br /&gt;
    user = session[:user]&lt;br /&gt;
    role = user.role&lt;br /&gt;
    all_users = request_user.get_requested_user_list&lt;br /&gt;
    letter = params[:letter]&lt;br /&gt;
    session[:letter] = letter&lt;br /&gt;
    if letter.nil?&lt;br /&gt;
      letter = all_users.first.name[0, 1].downcase unless all_users.empty?&lt;br /&gt;
    end&lt;br /&gt;
    @letters = []&lt;br /&gt;
    @per_page = 1&lt;br /&gt;
    @per_page = if params[:paginate_show]&lt;br /&gt;
                  params[:num_users]&lt;br /&gt;
                elsif params[:from_letter]&lt;br /&gt;
                  1&lt;br /&gt;
                else&lt;br /&gt;
                  params[:num_users]&lt;br /&gt;
                end&lt;br /&gt;
    @requested_users = paginate_list all_users&lt;br /&gt;
    @letters = ('A'..'Z').to_a&lt;br /&gt;
  end&lt;br /&gt;
2. '''approve_user'''&lt;br /&gt;
&lt;br /&gt;
  def approve_user&lt;br /&gt;
    # will be calling create method with required parameters and setting the status in request_users table to approved.&lt;br /&gt;
    # apter the user is created, email is sent to user.&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. '''reject_user'''&lt;br /&gt;
  &lt;br /&gt;
  def reject_user&lt;br /&gt;
    #will set the status in request_users to reject and send an email to user about the same.&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We will be creating a new table called '''request_users''' with table description that is similar to '''users'''&lt;br /&gt;
Below is the table description of '''users''' table.&lt;br /&gt;
[[File:Users.png]]&lt;br /&gt;
&lt;br /&gt;
Our '''request_users''' will also be having a new column called '''status''' which describes that the user is approved or rejected.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_aproval_table.png&amp;diff=106431</id>
		<title>File:Req aproval table.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Req_aproval_table.png&amp;diff=106431"/>
		<updated>2016-12-03T22:35:51Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106416</id>
		<title>CSC/ECE 517 Fall 2016 E1687 Instructor account creation over the web</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2016_E1687_Instructor_account_creation_over_the_web&amp;diff=106416"/>
		<updated>2016-12-03T15:16:29Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: /* Files changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E1687. Instructor Account Creation Over the Web'''&lt;br /&gt;
&lt;br /&gt;
This page gives a detail of the final project of creating an instructor account over the web in Expertiza.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
Expertiza is a Ruby on Rails based open source project. The main motive of this project is to make learning more effective through peer review. This website is a result of combined effort of both students and faculty at NC State, and is used not just by this university but also in many other universities. The website allows students to form teams and work on various projects listed by the instructor and also suggest new topics that seem interesting, though they can opt not to work on them. It also makes it easy for the instructor to add a new topic to an assignment/project, create a new project and add students to it. The time spent by TAs and instructor is greatly reduced. The key feature is peer review, where the students can review the work of others and provide feedback. This helps in improving the existing work and also provides a new way to learn. There isn’t any restriction on the format of submission as it accepts any form of submission varying from URL to wiki pages, which isn’t a common feature in other websites.&lt;br /&gt;
&lt;br /&gt;
== '''Problem Statement''' ==&lt;br /&gt;
In Expertiza, user and instructor accounts are currently created by existing super administrators, instructors or TAs. For new users to access the system and experiment the features offered by Expertiza, a “demo-like” feature needs to implemented. The following are the set of requirements that needs to be catered with this feature:&lt;br /&gt;
#Allow people to request instructor accounts over the web. This feature should also have security features such as Captchas to help avoid account creation by bots.&lt;br /&gt;
#When a user account is created over the web, the super-admin should get e-mail regarding the same and also the user should be notified upon approval/denial (if denied, then reason should be specified).&lt;br /&gt;
#Currently, Expertiza consists of a lot of entities that can be made publicly visible to all other users in the system. But, accounts created this way should not be able to see existing public features, until the super-admin manually gives them permission to view public courses, assignments, and questionnaires.&lt;br /&gt;
#A user who creates an account over the web should be pointed to an instruction page and/or video on how to create an assignment and register students for it, etc.&lt;br /&gt;
&lt;br /&gt;
=='''Implementation'''==&lt;br /&gt;
The following solutions shall be addressing the problems discussed above. &lt;br /&gt;
===Problem 1===&lt;br /&gt;
Once a user wants to register and try the features of Expertiza, upon opening the website, one can register by filling up the form and click the register button. There is a captcha that shall be shown below, to make sure that it isn't any bot that is accessing. It provides security to the application.&lt;br /&gt;
&lt;br /&gt;
===Problem 2===&lt;br /&gt;
Once the user requests for an account creation, the super admin receives a mail informing about the request with the name of the requested user. The super admin shall then, look for the details of the user in the Requests tab and can either approve/decline the request. Once the super admin approves the user request, the user gets a mail notifying the same. If the request is rejected, then the reason should be mentioned in the reason tab of the form. But there is no mail sent to the user regarding that.&lt;br /&gt;
&lt;br /&gt;
===Problem 3===&lt;br /&gt;
There shall be a flash message saying, “Login denied. Needs permission from super admin” that can be seen on the login page if an unregistered user tries to access the features of Expertiza.  This helps in removing the access to few publicly visible features as it denies access completely. &lt;br /&gt;
&lt;br /&gt;
===Problem 4===&lt;br /&gt;
Once the user account is approved by the super admin and the user tries to login upon notification, he/she shall be redirected to an “Instructions” page on successful login. &lt;br /&gt;
&lt;br /&gt;
This page shall contain the video tutorials explaining various features of Expertiza and also on how to access them.&lt;br /&gt;
&lt;br /&gt;
=='''Files changed'''==&lt;br /&gt;
The following are the list of files that were created/edited throughout the project.&lt;br /&gt;
* views/auth/_login.html.erb&lt;br /&gt;
* views/users/request_new.html.erb&lt;br /&gt;
* views/users/review.html&lt;br /&gt;
* views/instructions/home.html.erb&lt;br /&gt;
* views/users/edit.html.erb&lt;br /&gt;
* views/mailer/request_user_message.html.erb&lt;br /&gt;
* views/users/new.html.erb&lt;br /&gt;
* views/users/_password.html.erb&lt;br /&gt;
* views/users/_user.html.erb&lt;br /&gt;
* users_controller.rb&lt;br /&gt;
* routes.rb&lt;br /&gt;
* models&lt;br /&gt;
* mailer_helper.rb&lt;br /&gt;
* mailer.rb&lt;br /&gt;
* models/requested_user.rb&lt;br /&gt;
* config/initializers/recaptcha.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In '''_login.html.erb''' a new button called Request Sign Up was added for the new users to register. The register page will look as above. On clicking '''Request sign up''', a user will be redirected to a page like below: &lt;br /&gt;
&lt;br /&gt;
[[File:login_screen.png]]&lt;br /&gt;
&lt;br /&gt;
User will be able to fill up all the required details and request a signup.&lt;br /&gt;
When a super administrator logins to his account he can go to '''Request/reject users''' menu as shown below&lt;br /&gt;
[[File:Approval_new.png]]&lt;br /&gt;
&lt;br /&gt;
Super Admin can either approve/reject a user. The page will look like below(''' approve.html.erb'''):&lt;br /&gt;
&lt;br /&gt;
[[File:Approve.png]]&lt;br /&gt;
&lt;br /&gt;
In addition to the above files a new file called Instructions.html.erb which will have all the videos and instructions on how Expertiza works.&lt;br /&gt;
&lt;br /&gt;
In '''users_controller.rb''' we will be having two new methods:&lt;br /&gt;
&lt;br /&gt;
1. '''request_list'''&lt;br /&gt;
&lt;br /&gt;
 def request_list&lt;br /&gt;
    user = session[:user]&lt;br /&gt;
    role = user.role&lt;br /&gt;
    all_users = request_user.get_requested_user_list&lt;br /&gt;
    letter = params[:letter]&lt;br /&gt;
    session[:letter] = letter&lt;br /&gt;
    if letter.nil?&lt;br /&gt;
      letter = all_users.first.name[0, 1].downcase unless all_users.empty?&lt;br /&gt;
    end&lt;br /&gt;
    @letters = []&lt;br /&gt;
    @per_page = 1&lt;br /&gt;
    @per_page = if params[:paginate_show]&lt;br /&gt;
                  params[:num_users]&lt;br /&gt;
                elsif params[:from_letter]&lt;br /&gt;
                  1&lt;br /&gt;
                else&lt;br /&gt;
                  params[:num_users]&lt;br /&gt;
                end&lt;br /&gt;
    @requested_users = paginate_list all_users&lt;br /&gt;
    @letters = ('A'..'Z').to_a&lt;br /&gt;
  end&lt;br /&gt;
2. '''approve_user'''&lt;br /&gt;
&lt;br /&gt;
  def approve_user&lt;br /&gt;
    # will be calling create method with required parameters and setting the status in request_users table to approved.&lt;br /&gt;
    # apter the user is created, email is sent to user.&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
3. '''reject_user'''&lt;br /&gt;
  &lt;br /&gt;
  def reject_user&lt;br /&gt;
    #will set the status in request_users to reject and send an email to user about the same.&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=='''Database Changes'''==&lt;br /&gt;
&lt;br /&gt;
We will be creating a new table called '''request_users''' with table description that is similar to '''users'''&lt;br /&gt;
Below is the table description of '''users''' table.&lt;br /&gt;
[[File:Users.png]]&lt;br /&gt;
&lt;br /&gt;
Our '''request_users''' will also be having a new column called '''status''' which describes that the user is approved or rejected.&lt;br /&gt;
&lt;br /&gt;
=='''Test Plan'''==&lt;br /&gt;
&lt;br /&gt;
We will be testing each of the functionality separately.&lt;br /&gt;
&lt;br /&gt;
1. Test all views&lt;br /&gt;
&lt;br /&gt;
will be testing if '''_login.html.erb''', '''Request_new.html.erb''' and ''' approve.html.erb''' are rendered properly.&lt;br /&gt;
&lt;br /&gt;
2. Test all controller methods.&lt;br /&gt;
&lt;br /&gt;
New test cases will be included for each case: &lt;br /&gt;
   a) Does '''request_list''' method gives the proper list of requested users?&lt;br /&gt;
   b) Does '''approve_user''' actually create a new user&lt;br /&gt;
   c) Does '''reject_user''' actually not create a new user and change the status properly.&lt;br /&gt;
   d) Also test cases where the functions should not work.&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Login_screen.png&amp;diff=106415</id>
		<title>File:Login screen.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Login_screen.png&amp;diff=106415"/>
		<updated>2016-12-03T15:15:28Z</updated>

		<summary type="html">&lt;p&gt;Smagapu: uploaded a new version of &amp;amp;quot;File:Login screen.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Smagapu</name></author>
	</entry>
</feed>