CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors

From Expertiza_Wiki
Revision as of 01:00, 20 October 2021 by Ggarrid (talk | contribs)
Jump to navigation Jump to search

E2146. Introduce a Student View for Instructors

Work in progress

This project is ongoing, and this page will be updated live.

Problem Statement

Currently, Expertiza is designed such that an instructor can view all the pages a student can, and is given access to a view very similar to that of a student. However, the difference between the navigational bar shown to an instructor and that which is shown to a student means that an instructor cannot perfectly emulate the view that a student has of Expertiza.

This makes activities such as demonstrating how to navigate around the website and access certain parts of assignments more difficult. While an instructor can choose to impersonate a student, this is cumbersome if they simply wish to view things as a student would from within their instructor account.

Additionally, certain features of the navigational bar are redundant. The main feature in question is the Assignments navigational link, which navigates to the same location as Manage... -> Assignments. Having such redundancy is confusing.

To summarize the problem, there is no easy way for an instructor to have the same view as a student at a moment's notice due to a difference between an instructor's and a student's navigational bars.

Goal of this Topic

The goal of this topic has two primary components:

  • Remove the redundant "Assignments" link in the current navigational bar
  • Add a new "Student View" link to the navigational bar. When clicked, the navigational bar changes to that of a student for the remainder of the session, with the addition of an "Instructor View" link. When that link is clicked, the navigational bar changes back to that of an instructor.

By making these changes, the unnecessary redundancy in the navigational bar is removed, and an instructor has an easy ability to demonstrate or visualize expertiza from the perspective of a student.

Specific Statement of Intent

The following is a precise, mechanical description of the intended changes.

When an instructor logs in, they should see a navigational bar with the following components: Home | Manage... | Survey Deployments | Course Evaluation | Profile | Contact Us | Student View

These are the same navigational components that an instructor can currently view, with the removal of Assignments and the addition of Student View.

If an instructor clicks on Student View, they are redirected to the home page and their navigational bar changes to the following:

Home | Assignments | Pending Surveys | Profile | Contact Us | Anonymized view | Instructor View

These are the same navigational links that a student can view, with the addition of Instructor View.

This navigational bar change should persist throughout the session, until the instructor chooses to change their view.

Implementation

To implement these changes, our theoretical framework was as follows: 1. Add a link to the navigational bar which directs to a new controller and its controller method. 2. Write a controller method which flips the value of a session flag. This session flag determines which navigational bar you see at any time. 3. Whenever the navigational bar is loaded, this flag is checked. If in the "student view" state, it renders the student view version of the instructor's navigational bar. if not, it renders the instructor's normal navigational bar (both with the addition of the link to switch to the other state).

To make this change, the following files were affected:

  • controllers/student_view_controller.rb: a controller with a single unique method, "flip_view", which flips the [:flip_user] session variable when called.
  • views/shared/_navigation.html.erb: the view which handles rendering the navigation bar. Has been edited to check the status of [:flip_user] and render a view accordingly.
  • config/role_instructor.yml: determines various aspects about those assigned the role of instructor. Only change made is the addition of the student_view and instructor_view Menu::Node objects, which are rendered in the navigation bar.
  • config/routes.rb: the routes for expertiza. Modified to allow a route to the newly made "flip_view" method.
  • spec/controllers/student_view_controller_spec.rb: A series of unit tests for the student view controller, ensuring proper functionality and permissions.

Each major change will now be explained in detail.

student_view_controller.rb

This controller contains only two methods, flip_view and _action_allowed? The later is a method common to all controllers, which determines who has access to the method. This is defined for the student_view_controller such that only those with instructor privileges may use it.

The flip_view function is shown below.

  def flip_view
    if(session[:flip_user] == nil || session[:flip_user] == false) then
      session[:flip_user] = true
      redirect_to '/'
    elsif(session[:flip_user] == true) then
      session[:flip_user] = false
      redirect_to '/'
    end
  end