CSC/ECE 517 Spring 2018- Project E1803: Introducing a Student View for Instructors: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(25 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
=== Background ===
=== Background ===
[http://expertiza.ncsu.edu/ Expertiza] is a web based open source peer reviewing tool developed and maintained by current and past students of [https://en.wikipedia.org/wiki/North_Carolina_State_University North Carolina State University], Raleigh. Our project is to introduce a student view to the instructors. Currently, an '''instructor''' sees the following menus across the top:
[http://expertiza.ncsu.edu/ Expertiza] is a web based open source peer reviewing tool developed and maintained by current and past students of [https://en.wikipedia.org/wiki/North_Carolina_State_University North Carolina State University], Raleigh.  


''Home Manage  Survey Deployments  Assignments  Course Evaluation  Profile  Contact Us''


A '''student''' sees these menus:
Currently, when an '''instructor''' logs into Expertiza, he/she sees the following menu items across the top:


''Home Assignments  Course Evaluations   Profile  Contact Us''
''Home Manage content  Survey Deployments  Assignments  Course Evaluation   Profile  Contact Us''


On the instructor’s Manage menu, one of the options is “Assignments”.  Having Assignments appear in two places in the menu is potentially confusing.  Manage > Assignments allows the instructor to edit and create assignments.  The Assignments menu that both students and instructors see allows them to participate in assignments.
And, a student can see the following menu items across the top:


Hence, to avoid confusion, when in '''instructor view''',the following menus are displayed across the top:
''Home Assignments Pending Surveys Profile Contact Us''


''Home Manage  Survey Deployments  Profile  Contact Us''


When in '''student view''', the following menus are displayed across the top:
On the instructor’s “Manage content” menu, one of the options is “Assignments”.  Having “Assignments” appear in two places is potentially confusing.  “Manage content > Assignments” allows the instructor to edit and create assignments, whereas the “Assignments” menu (that both students and instructors) see allows the instructor to participate in assignments.


''Home Assignments  Course Evaluations  Profile  Contact Us''
Therefore, it makes sense to create a '''student view''' for instructors, which will enable them to see menu items that are only related to students. This will help resolve the confusion.


=== Problem statement ===
=== Problem statement ===
Our aim is to create a student view for instructors, which will allow an instructor to see what the students see without having to actually impersonate a particular student. When in student view, an instructor must be able to view only the menu items that a student can view and must also be able to switch back to the instructor view. Also when in instructor view, an instructor won't be able to view the 'Assignment' and 'Course Evaluation' menu items, which as of now the instructor can see.
Create a '''student view''' for instructors. When in '''student view''', an instructor must not be able to view ''"Manage content"'' and ''"Survey Deployments"'' menu items, and must be able to switch back to the '''instructor view''' (the default view that an instructor first sees when he/she logs in). When in '''instructor view''', an instructor must not be able to view the ''"Assignment"'' and ''"Course Evaluation"'' menu items.


=== Team ===
== Implementation ==
# Akshay Ravichandran
=== expertiza/app/views/shared/_navigation.html.erb ===
# Krithika Sekhar
This file is shared between all views and is responsible for rendering all the elements in the top-most part of the web page. (i.e Displaying the menu items, the logout button etc.)
# Sameer Poudwal


'''Mentor''' - Ed Gehringer
In order to switch between '''instructor view''' and '''student view''', the following code was added. When the user is in '''instructor view''', there is a link named "Switch to Student View" to switch to '''student view''' and when the user is in '''student view''', 'here is a link named "Revert to Instructor View" to switch back to the '''instructor view'''.
 
== Development ==
=== expertiza/app/views/shared/_navigation.html.erb ===
To switch from instructor to student view and to switch back from student to instructor view, the following code was added in the _navigation.html.erb file. When the user is in instructor view, there is a link named "Switch to Student View" to switch to student view and when the user is in student view, there is a link named "Revert to Instructor View" to switch back to Instructor View.
  <% if session[:user].role.instructor? %>
  <% if session[:user].role.instructor? %>
                   <% if session.key?(:student_view) %>
                   <% if session.key?(:student_view) %>
Line 43: Line 36:


=== expertiza/app/views/menu_items/_suckerfish.html.erb ===
=== expertiza/app/views/menu_items/_suckerfish.html.erb ===
This file is responsible for rendering all menu items and their children (if any).


A condition was needed to check if the current menu item that is to be rendered is in the list of hidden menu items. The ''hidden_menu_items'' session variable holds the IDs of menu items that must not be rendered. This applies only when the type of user currently logged in is an instructor. Hence, the following condition was added.
A condition was needed to check if the current menu item that is to be rendered is in the list of hidden menu items. The ''hidden_menu_items'' session variable holds the IDs of menu items that must not be rendered. This applies only when the type of user currently logged in is an instructor. Hence, the following condition was added.
Line 115: Line 109:


=== expertiza/app/controllers/auth_controller.rb ===
=== expertiza/app/controllers/auth_controller.rb ===
The ''after_login'' method in this controller sets up the session object after the user logs in, so it is a good candidate to include the initial set up of the ''hidden_menu_items'' session variable.


The following lines were added to the ''after_login'' method. This call is intended to set the 'hidden_menu_items' variable in the session object when an instructor logs in for the first time. This is done so that the instructor is by default in Instructor View when he logs in. (i.e ''Assignments'' and ''Course Evaluation'' are hidden). The ''after_login'' method sets up the session object after the user logs in, so it seemed like a good candidate to include the initial set up of the ''hidden_menu_items'' session variable.
The following lines were added to the ''after_login'' method. This call is intended to set the 'hidden_menu_items' variable in the session object when an instructor logs in for the first time. This is done so that the instructor is by default in Instructor View when he logs in. (i.e ''Assignments'' and ''Course Evaluation'' are hidden).  
<pre>
<pre>
     # hide menu items based on type of user
     # hide menu items based on type of user
Line 142: Line 137:
</pre>
</pre>


== Testing ==
== Manual UI Testing ==


The user needs to log-in as instructor to view the developed functionality, this won't be visible for other user roles-
The user needs to log-in as an instructor to view this functionality.


1. Log into Expertiza as an instructor.
1. Log into Expertiza as an instructor. Enter 'instructor6' as username and 'password' as password.


2. Click on '''Switch to Student View''' below user name to switch to student view.
2. Click on '''Switch to Student View''' below username to switch to student view.




Line 154: Line 149:




3. Click on '''Revert to Instructor View'''' below user name to come back to instructor view.
3. Click on '''Revert to Instructor View'''' below username to come back to instructor view.




[[File:Instructor_View_1.PNG]]
[[File:Instructor_View_1.PNG]]
== Automated Test Plan ==
1. '''Check whether ''Assignments'' and ''Course Evaluation'' are hidden when in instructor view.''' 
This test case is to check if the menu items ''Assignments'' and ''Course Evaluation'' are hidden when an instructor is in instructor view. The following lines can be added to a spec/features file:
<pre>
it " can display relevant menu items after login as an admin/instructor/TA", js: true do
    create(:instructor)
    login_as 'instructor6'
    visit '/tree_display/list'
    expect(page).to have_current_path('/tree_display/list')
    expect(page).to have_content('Manage content')
    expect(page).to have_content('Survey Deployments')
    expect(page).not_to have_content('Assignments')
    expect(page).not_to have_content('Course Evaluation')
end
</pre>
2. '''Check whether ''Manage content'' and ''Survey Deployments'' are hidden in student view.'''
This test case is to check if the menu items ''Manage content'' and ''Survey Deployments'' are hidden when the instructor switches to student view. The following lines are to be added:
<pre>
it "can display relevant menu items when switching to student view", js: true do
    create(:instructor)
    login_as 'instructor6'
    visit '/tree_display/list'
    click_link 'Swtich to Student View'
    expect(page).to have_current_path('/student_task/list')
    expect(page).to have_content('Assignments')
    expect(page).to have_content('Course Evaluation')
    expect(page).not_to have_content('Manage content')
    expect(page).not_to have_content('Survey Deployments')
end
</pre>


== External Links ==
== External Links ==
# link for forked repository [[https://github.com/akshayravichandran/expertiza]]
# Link to forked repository [[https://github.com/akshayravichandran/expertiza]]
# Link to screen cast [[https://youtu.be/lRZT4q7YDLA]]
 
==References==
 
Expertiza
* https://expertiza.ncsu.edu/
 
Expertiza Github
* https://github.com/expertiza/expertiza
 
Expertiza Documentation
* http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation
 
RSpec Documentation
* http://rspec.info/documentation/

Latest revision as of 02:53, 3 April 2018

Introduction

Background

Expertiza is a web based open source peer reviewing tool developed and maintained by current and past students of North Carolina State University, Raleigh.


Currently, when an instructor logs into Expertiza, he/she sees the following menu items across the top:

Home Manage content Survey Deployments Assignments Course Evaluation Profile Contact Us

And, a student can see the following menu items across the top:

Home Assignments Pending Surveys Profile Contact Us


On the instructor’s “Manage content” menu, one of the options is “Assignments”. Having “Assignments” appear in two places is potentially confusing. “Manage content > Assignments” allows the instructor to edit and create assignments, whereas the “Assignments” menu (that both students and instructors) see allows the instructor to participate in assignments.

Therefore, it makes sense to create a student view for instructors, which will enable them to see menu items that are only related to students. This will help resolve the confusion.

Problem statement

Create a student view for instructors. When in student view, an instructor must not be able to view "Manage content" and "Survey Deployments" menu items, and must be able to switch back to the instructor view (the default view that an instructor first sees when he/she logs in). When in instructor view, an instructor must not be able to view the "Assignment" and "Course Evaluation" menu items.

Implementation

expertiza/app/views/shared/_navigation.html.erb

This file is shared between all views and is responsible for rendering all the elements in the top-most part of the web page. (i.e Displaying the menu items, the logout button etc.)

In order to switch between instructor view and student view, the following code was added. When the user is in instructor view, there is a link named "Switch to Student View" to switch to student view and when the user is in student view, 'here is a link named "Revert to Instructor View" to switch back to the instructor view.

<% if session[:user].role.instructor? %>
                 <% if session.key?(:student_view) %>
                     <%= link_to "Revert to Instructor View", {controller: "instructor", action: "revert_to_instructor_view"},
                                 method: :post, :style => "color: white" %>
                 <% else %>
                     <%= link_to "Switch to Student View", {controller: "instructor", action: "set_student_view"},
                                 method: :post, :style => "color: white" %>
                 <% end %>
             <% end %>

expertiza/app/views/menu_items/_suckerfish.html.erb

This file is responsible for rendering all menu items and their children (if any).

A condition was needed to check if the current menu item that is to be rendered is in the list of hidden menu items. The hidden_menu_items session variable holds the IDs of menu items that must not be rendered. This applies only when the type of user currently logged in is an instructor. Hence, the following condition was added.

 display_item_condition = (session[:user].role.instructor?)?(session[:hidden_menu_items].include?item_id)?false:true:true

expertiza/app/controllers/instructor_controller.rb

A new instructor_controller.rb file has been added. This controller currently contains the actions to switch to student view and revert back to instructor view.

class InstructorController < ApplicationController
  # check to see if the current action is allowed
  def action_allowed?
    # only an instructor is allowed to perform all the actions in
    # this controller
    return true if session[:user].role.instructor?
  end

  # sets student_view in session object and redirects to
  # student_task/list after updating hidden_menu_items
  def set_student_view
    session[:student_view] = true
    MenuItemsHelper.update_hidden_menu_items_for_student_view(session)
    redirect_to controller: 'student_task', action: 'list'
  end

  # destroys student_view in session object and redirects to
  # tree_display/list after updating hidden_menu_items
  def revert_to_instructor_view
    session.delete(:student_view)
    MenuItemsHelper.update_hidden_menu_items_for_instructor_view(session)
    redirect_to controller: 'tree_display', action: 'list'
  end
end

expertiza/app/helpers/menu_items_helper.rb

This is a helper for deciding what menu items must be hidden.

The update_hidden_menu_items_for_student_view method is used to hide the Survey Deployments and Manage Instructor Content menu items. It does this by including the menu item IDs of these two menus in the hidden_menu_items session variable. (The hidden_menu_item variable will be used by _suckerfish.html.erb to decide whether or not to render a given menu item).

Similarly, the update_hidden_menu_items_for_instructor_view method is used to hide the Assignments and Course Evaluation menu items.

The set_hidden_menu_items method is used to set check if the given user is an instructor. If it is, then the update_hidden_menu_items_for_instructor_view method is called. This method is used to ensure that only those items that must be visible to an instructor view are visible to an instructor when he logs in for the first time. The method has been designed in this way because, in the future, other menu items may need to be hidden based on the user type.

module MenuItemsHelper
  # sets hidden_menu_items for the given user if
  # user is an instructor. This method is needed to set
  # the hidden_menu_items during initial login by instructor.
  def self.set_hidden_menu_items(user, session)
    if user.role.instructor?
      MenuItemsHelper.update_hidden_menu_items_for_instructor_view(session)
    else
      session[:hidden_menu_items] = []
    end
  end

  # updates hidden_menu_items in session object when an instructor is
  # in student view
  def self.update_hidden_menu_items_for_student_view(session)
    # 35 - Survey Deployments, 37 - Manage Instructor Content
    session[:hidden_menu_items] = [35, 37]
  end

  # updates hidden_menu_items in session object when an instructor is
  # in instructor view
  def self.update_hidden_menu_items_for_instructor_view(session)
    # 26 - Assignments, 30 - Course Evaluation
    session[:hidden_menu_items] = [26, 30]
  end
end

expertiza/app/controllers/auth_controller.rb

The after_login method in this controller sets up the session object after the user logs in, so it is a good candidate to include the initial set up of the hidden_menu_items session variable.

The following lines were added to the after_login method. This call is intended to set the 'hidden_menu_items' variable in the session object when an instructor logs in for the first time. This is done so that the instructor is by default in Instructor View when he logs in. (i.e Assignments and Course Evaluation are hidden).

    # hide menu items based on type of user
    MenuItemsHelper.set_hidden_menu_items(user,session)

The following lines were added to the clear_session method. These lines clear the student_view and hidden_menu_items session variables.

    session[:student_view] = nil
    session[:hidden_menu_items] = nil

expertiza/config/routes.rb

New post methods are added in config/routes.rb. The routes are directed to the instructor controller's set_student_view and revert_to_instructor_view actions.

  resources :instructor, only: [] do
    collection do
      post  :set_student_view
      post  :revert_to_instructor_view
    end
  end

Manual UI Testing

The user needs to log-in as an instructor to view this functionality.

1. Log into Expertiza as an instructor. Enter 'instructor6' as username and 'password' as password.

2. Click on Switch to Student View below username to switch to student view.



3. Click on Revert to Instructor View' below username to come back to instructor view.


Automated Test Plan

1. Check whether Assignments and Course Evaluation are hidden when in instructor view. This test case is to check if the menu items Assignments and Course Evaluation are hidden when an instructor is in instructor view. The following lines can be added to a spec/features file:

it " can display relevant menu items after login as an admin/instructor/TA", js: true do
    create(:instructor)
    login_as 'instructor6'
    visit '/tree_display/list'
    expect(page).to have_current_path('/tree_display/list')
    expect(page).to have_content('Manage content')
    expect(page).to have_content('Survey Deployments')
    expect(page).not_to have_content('Assignments')
    expect(page).not_to have_content('Course Evaluation')
end

2. Check whether Manage content and Survey Deployments are hidden in student view. This test case is to check if the menu items Manage content and Survey Deployments are hidden when the instructor switches to student view. The following lines are to be added:

it "can display relevant menu items when switching to student view", js: true do
    create(:instructor)
    login_as 'instructor6'
    visit '/tree_display/list'
    click_link 'Swtich to Student View'
    expect(page).to have_current_path('/student_task/list')
    expect(page).to have_content('Assignments')
    expect(page).to have_content('Course Evaluation')
    expect(page).not_to have_content('Manage content')
    expect(page).not_to have_content('Survey Deployments')
end

External Links

  1. Link to forked repository [[1]]
  2. Link to screen cast [[2]]

References

Expertiza

Expertiza Github

Expertiza Documentation

RSpec Documentation