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

From Expertiza_Wiki
Jump to navigation Jump to search
Line 171: Line 171:
===Process Video===
===Process Video===
Video Demonstration for Testing Task1: [https://youtu.be/FXQu1fcbM20 Task1-Video]
Video Demonstration for Testing Task1: [https://youtu.be/FXQu1fcbM20 Task1-Video]
Video Demonstration for Testing Task2: [https://youtu.be/3BIsI2UpNRo Task2-Video]
Video Demonstration for Testing Task3: [https://youtu.be/ZmLfvYLmLTo Task3-Video]


===Team Information===
===Team Information===

Revision as of 03:21, 28 October 2019

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    render action: 'new'
144    flash[:error] = "Create Instructor Error!"
145    redirect_to '/admin/list_instructors'
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 -%>

Test

Test for Task1
  8  it "check if the courses are sorted alphabetically" do
  9    driver = Selenium::WebDriver.for :firefox
 10    driver.get("http://localhost:3000/")
 11    driver.find_element(:id, "login_name").send_keys("super_administrator2")
 12    driver.find_element(:id, "login_password").send_keys("password")
 13    driver.find_element(:name, "commit").click()
 14    driver.get("http://localhost:3000/course/new?private=1")
 15    institutions_eles = driver.find_element(:id, "course_institutions_id")
 16    options = institutions_eles.find_elements(:tag_name, 'option')
 17    result = true
 18    for x in 0..options.size-2
 19      if (options[x].text.downcase <=> options[x+1].text.downcase) > 0
 20        result = false
 21        break
 22      end
 23    end
 24    expect(result).to be(true)
 25  end
Test for Task2
 233  it 'save successfully with a new institution' do
 234    driver = Selenium::WebDriver.for :firefox
 235    driver.get("http://localhost:3000/")
 236    driver.find_element(:id, "login_name").send_keys("super_administrator2")
 237    driver.find_element(:id, "login_password").send_keys("password")
 238    driver.find_element(:name, "commit").click()
 239    driver.get("http://localhost:3000/users/new?utf8=%E2%9C%93&role=Instructor&commit=New+Instructor")
 240    driver.find_element(:id, "user_name").send_keys("yzhu48")
 241    driver.find_element(:id, "user_fullname").send_keys("yzhu48")
 242    driver.find_element(:id, "user_email").send_keys("yzhu48@ncsu.com")
 243    driver.find_element(:id, "user_password").send_keys("111111")
 244    driver.find_element(:id, "user_password_confirmation").send_keys("111111")
 245        
 246    institutionMenu = driver.find_element(:id, 'user_institution_id')
 247    option = Selenium::WebDriver::Support::Select.new(institutionMenu)
 248    option.select_by(:text, 'Other')
 249    
 250    driver.find_element(:id, "institution_name").send_keys("yzhu48")
 251
 252    driver.find_element(:name, "commit").click()
 253    expect(response.status).to eq(200)
 254  end
Test for Task3
 17  describe "View users" do
 18    it "check if instructors show their institutions on the same line as their new feature" do
 19      require 'pp'
 20      driver = Selenium::WebDriver.for :firefox
 21      driver.get("http://localhost:3000/")
 22      driver.find_element(:id, "login_name").send_keys("instructor6")
 23      driver.find_element(:id, "login_password").send_keys("password")
 24      driver.find_element(:name, "commit").click()
 25      driver.get("http://localhost:3000/users/list")
 26
 27      has_institution = false
 28      if driver.find_element(xpath: "/html/body/div[1]/div[1]/div/div/div/div/table/tbody/tr[2]/th[3]").text == "Institution"
 29        has_institution = true
 30        expect(has_institution).to be(true)
 31      end
 32      expect(has_institution).to be(true)
 33    end
 34  end

Process Video

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

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