CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors & Institutions

From Expertiza_Wiki
Jump to navigation Jump to search

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

  • E2141 Project aims to fix the associations problems between the Institution and Instructor class.
  • The forked git repository for this project can be found [1]

Problem Statement

The following tasks were accomplished in E2141 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 original issue was that when an admin tries to create a new instructor with a new institution a "No method error in Users#Create" occurs. However when running the program a different issue was seen below...

   

To resolve this the following lines were commented out in the following files :

Changed files: app/controllers/users_controller.rb

122  if @user.save
123    password = @user.reset_password 
124   #  prepared_mail = MailerHelper.send_mail_to_user(@user, "Your Expertiza account and password have been created.", "user_welcome", password)
125    # prepared_mail.deliver
126    flash[:success] = "A new password has been sent to new user's e-mail address."

Changed files: app/models/user.rb

149  # Function which has a MailerHelper which sends the mail welcome email to the user after signing up
150  def email_welcome 
151    # #this will send an account creation notification to user via email.
152    # MailerHelper.send_mail_to_user(self, "Your Expertiza account and password has been created", "user_welcome", password).deliver_now prepared_mail.deliver
153  end

This resolved the issues of being able to add an instructor with a newly created institution as seen in the images below


   
   

However due to the fact that commenting out the MailHelper could result in cascading issues in other parts of the project we decided that the best action would be to not make changes and notify the mentors of this issue until a proper resolution could be made.

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:
 Kai Gao (kgao2@ncsu.edu)
 psengo (psengo@ncsu.edu)
 kyao (kyao@ncsu.edu)
 Mentor: Yunkai Xiao (yxiao28@ncsu.edu)

References

Expertiza on GitHub

Expertiza website

Expertiza project documentation wiki

GitHub Project Repository Fork

Rspec Documentation