E1826 Add student view for instructor: Difference between revisions
No edit summary |
No edit summary |
||
Line 97: | Line 97: | ||
[[File: | [[File:default_view.png]] | ||
Line 103: | Line 103: | ||
[[File: | [[File:new_student_view.png]] | ||
== Automated Test Plan == | == Automated Test Plan == |
Revision as of 20:37, 28 October 2018
Introduction
Background
The navigation for an instructor follows the below structure.
- Home
- Manage...
- Users
- Questionnaires
- Courses
- Assignments
- Impersonate User
- Anonymized View
- Survey Deployments
- Assignments
- Course Evaluation
- Profile
- Contact Us
And that for a student follows the below structure.
- Home
- Assignments
- Pending Surveys
- Profile
- Contact Us
For an instructor, the menu item 'Assignments' is present in 2 places - in the main menu as 'Assignments' and in the sub-menu as 'Manage.../Assignments' (italicized above). This could potentially be confusing. 'Manage.../Assignments' sub-menu item allows the instructor to create/edit assignments. The menu item 'Assignments' allows an instructor to participate in assignments. This is typically something that the instructor wants to do in a student role and hence there needs to be a student view for instructors to act as students without impersonating them and thus reducing confusion. The same needs to be implemented for admin and super admin as well.
Problem statement
Create a student view for instructors so that they can perform student operations without impersonating them. When an instructor logs in, he/she is in the default view with corresponding menu items (with the exception of the 'Assignments' menu item). There should be an option to switch to and revert back from the student view. When in student view, an instructor is presented with the student menu as listed above.
Implementation
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/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/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
References
Expertiza
Expertiza Github
Expertiza Documentation
RSpec Documentation