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
Line 10: Line 10:


=== 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, which will allow an instructor to see what 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''' (the default view that an instructor first sees when he/she logs in). Also when in '''instructor view''', an instructor must not be able to view the ''Assignment'' and ''Course Evaluation'' menu items.


=== Team ===
=== Team ===

Revision as of 00:51, 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 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 is potentially confusing. “Manage > 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.

Problem statement

Create a student view for instructors, which will allow an instructor to see what 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 (the default view that an instructor first sees when he/she logs in). Also when in instructor view, an instructor must not be able to view the Assignment and Course Evaluation menu items.

Team

  1. Akshay Ravichandran
  2. Krithika Sekhar
  3. Sameer Poudwal

Mentor - Dr. Ed Gehringer

Implementation

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.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

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 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.

    # 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.

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.
  2. Check whether Manage content and Survey Deployments are hidden in student view.

External Links

  1. link for forked repository [[1]]