CSC/ECE 517 Fall 2019 - E1971. OSS project Finklestein: Instructors & Institutions

From Expertiza_Wiki
Jump to navigation Jump to search

E1971. OSS project Finklestein: Instructors & Institutions

Expertiza is an open-source project based on Ruby on Rails framework. Expertiza allows instructors to manager courses and assignments for students. Students can form up teams in Expertiza to work on different projects and assignments and do peer review about other students' submissions.

Introduction

  • E1971 Project aims to fix the associations problems between the Institution and Instructor class.

Problem Statement

The following tasks were accomplished in E1971 project:

  • Task1: The institution list should be sorted alphabetically.
    • Details: When creating a course, the drop-down list for selecting the institution does not show in alphabetical order.
 
  • Task2: Adding a new institution during creation of an instructor profile.
    • Details: The admin can attempt to create a new institution when creating a new instructor. But, after one types in the name of the institution & clicks create, it crashes.
 
  • Task3: Listing of instructors should show their institutions on the same line as their new feature.
    • Details: When listing users, there is currently no column to display the user’s associated institution.
 

Task1

As the issue is the Institution drop-down list is not alphabetically sorted. We simply added a step of sort when the Institution list was retrieved from the Database.

Changed files: _course.html.erb

line3 <%= select("course", "institutions_id", Institution.all.order(:name).collect{ |c| [ c.name, c.id] }) %>

Task2

The issue occurs when the admin trying to create a new instructor with a new institution name. To fix this problem, we added a function to create a new institution and a confirmation prompt to alert the admin.

Changed files: app/controllers/users_controller.rb

116  # if the user name already exists, register the user by email address
117  check = User.find_by(name: params[:user][:name])
118  params[:user][:name] = params[:user][:email] unless check.nil?
119  if params[:user][:institution_id].empty?
120    institution = Institution.find_or_create_by(name: params[:institution][:name])
121    params[:user][:institution_id] = institution.id
122  end
123  @user = User.new(user_params)
124  @user.institution_id = params[:user][:institution_id]
-------------------------------------------------------------------------------------------------
142  else
143    foreign
144    flash[:error] = "Create Instructor Error!"
145    render action: 'new'
146  end
Changed files: app/views/users/new.html.erb

8  <ρ style="color: red; font-weight: bold">* Please Make Sure All Information is Correct</ρ>
9  <%= submit_tag "Create" %>

Task3

The issue is that the user page is not displaying the user's associated institution. To fix this issue, we added an 'institution' column in the HTML file retrieving the institution names of each user.

Changed files: app/models/user.rb

111  def institution(ip_address = nil)
112    if User.anonymized_view?(ip_address)
113      self.role.name + ', ' + self.id.to_s
114    else
115      if self[:role_id] == 2
116        self[:institution_id].nil? ? "" : Institution.find(self[:institution_id]).name
117      end
118    end
119  end
Changed files: app/views/users/list.html.erb
 

20 21 Name 22 Full Name 23 Institution 24 Email Address 25 Role 26 Parent 27 Review 28 Submission 29 Metareview 30 31 <% for user in @users %> 32 <% if ((params[:show] != 'true' && !user.name(session[:ip]).include?("_hidden")) || params[:show] == 'true')%> 33 34 <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %> 35 <%= link_to user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => user.id %> 36 <%= user.institution(session[:ip]) %> 37 <%= user.email(session[:ip]) %> 38 <%= link_to user.role.name, :controller => 'roles', :action => 'show', :id => user.role.id %> 39 <%= user.parent.try :name %> 40 <%= User.yesorno(user.email_on_review) %> 41 <%= User.yesorno(user.email_on_submission) %> 42 <%= User.yesorno(user.email_on_review_of_review) %> 43 44 <% end %> 45 <% end -%>

Task Demonstration

Task1


Task2



Task3


Test

Test for Task1

We created 4 institutions and check if they are alphabetically sorted in the selection box

 Changed files: spec/features/course_creation_spec.rb

 13  it "check if the courses are sorted alphabetically" do
 14    create(:superadmin, name: 'super_administrator2')
 15    login_as('super_administrator2')
 16    visit "/course/new?private=1"
 17    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[1]").text).to eq("A")
 18    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[2]").text).to eq("B")
 19    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[3]").text).to eq("C")
 20    expect(page.find(:xpath, "//*[@id=\"course_institutions_id\"]/option[4]").text).to eq("D")
 21  end

Test for Task2

We tried to create a new instructor6 with a new institution name
 Changed files: spec/controllers/users_controller_spec.rb

 233  it 'save successfully with a new institution' do
 234    session = {user: admin}
 235    params = {
 236      user: {name: 'instructor6',
 237             crypted_password: 'password',
 238             role_id: 2,
 239             password_salt: 1,
 240             fullname: '6, instructor',
 241             email: 'yzhu48@ncsu.edu',
 242             parent_id: 1,
 243             private_by_default: false,
 244             mru_directory_path: nil,
 245             email_on_review: true,
 246             email_on_submission: true,
 247             email_on_review_of_review: true,
 248             is_new_user: false,
 249             master_permission_granted: 0,
 250             handle: 'handle',
 251             digital_certificate: nil,
 252             timezonepref: 'Eastern Time (US & Canada)',
 253             public_key: nil,
 254             copy_of_emails: nil,
 255             institution_id: 666,
 256             institution: {
 257                 name: 'yzhu48'
 258             }
 259       }
 260    }  
 261    post :create, params, session
 262    allow_any_instance_of(User).to receive(:undo_link).with('The user "instructor6" has been successfully created. ').and_return(true)
 263    expect(flash[:success]).to eq "A new password has been sent to new user's e-mail address."
 264    expect(response).to redirect_to('http://test.host/users/list')
 265  end

Test for Task3

We tested if the Institution column was on the page
 Changed files: spec/controllers/users_controller_spec.rb

 18  it "check if instructors show their institutions on the same line as their new feature" do
 19    create(:superadmin, name: 'super_administrator2')
 20    login_as('super_administrator2')
 21    visit "/users/list"
 22    expect(page.has_content?("Institution")).to eq(true)
 23  end

Process Video

Video Demonstration for Testing Task1: Task1-Video
Video Demonstration for Testing Task2: Task2-Video
Video Demonstration for Testing Task3: Task3-Video

Project Deployment

Expertiza_Team_4430

Team Information

 Team_4430:
 Ruiwen Wu (rwu5@ncsu.edu)
 Yongjian Zhu (yzhu48@ncsu.edu)
 Ling Li (lli46@ncsu.edu)
 Mentor: Carmen Bentley (cnaiken@ncsu.edu)

References

Expertiza on GitHub

Expertiza website

Expertiza project documentation wiki

GitHub Project Repository Fork

Rspec Documentation