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 83: Line 83:
=== expertiza/config/routes.rb ===
=== expertiza/config/routes.rb ===


New post methods are added in ''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.


<pre>
<pre>
   resources :tree_display, only: [] do
   resources :instructor, only: [] do
     collection do
     collection do
      get :action
       post :set_student_view
      post :list
       post :revert_to_instructor_view
      post :children_node_ng
      post :children_node_2_ng
      post :bridge_to_is_available
      get :session_last_open_tab
      get :set_session_last_open_tab
       post :set_student_view
       post :revert_to_instructor_view
     end
     end
   end
   end


</pre>
</pre>


== Testing ==
== Testing ==

Revision as of 00:39, 2 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. Our project is to introduce a student view to the instructors. Currently, an instructor sees the following menus across the top:

Home Manage Survey Deployments Assignments Course Evaluation Profile Contact Us

A student sees these menus:

Home Assignments Course Evaluations 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.

Hence, to avoid confusion, when in instructor view,the following menus are displayed across the top:

Home Manage Survey Deployments Profile Contact Us

When in student view, the following menus are displayed across the top:

Home Assignments Course Evaluations Profile Contact Us

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.

Team

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

Mentor - Ed Gehringer

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

Based on whether the instructor is on the Student View or Instructor View, some menu items need to be hidden. Thus, an appropriate 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
  def set_student_view
    session[:student_view] = true
    MenuItemsHelper.set_student_view_hidden_menu_items(session)
    redirect_to controller: 'student_task', action: 'list'
  end

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

end

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

Testing

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

1. Log into Expertiza as an instructor.

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



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


External Links

  1. link for forked repository [[1]]