Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1971. OSS project Finklestein: Instructors & Institutions #1506

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3505823
chore: update README.md
YongjianZhu Oct 8, 2019
db56f04
fix: courses sorted alphabetically
YongjianZhu Oct 8, 2019
29f12fd
fix: create instructor with new institution error
YongjianZhu Oct 11, 2019
8278f9d
feat: listing of instructors show their institutions
YongjianZhu Oct 11, 2019
1d60747
Merge branch 'beta' into dev
YongjianZhu Oct 14, 2019
106b4ad
Merge branch 'dev' into beta
YongjianZhu Oct 18, 2019
5a9ab87
test: test courses order
YongjianZhu Oct 18, 2019
2106c11
Merge branch 'beta' of https://github.com/YongjianZhu/expertiza
Oct 18, 2019
6ac6217
fix: fix render issue
YongjianZhu Oct 18, 2019
2913e7e
Merge branch 'beta' of https://github.com/YongjianZhu/expertiza
Oct 21, 2019
610101d
issue 3 test
Oct 23, 2019
81a863b
issue3 test debug
Oct 24, 2019
49af292
fix: fix 1971 issue 2
YongjianZhu Oct 24, 2019
a0d1a08
fix: fix bug
YongjianZhu Oct 26, 2019
aab1dd0
fix: fix bugs
YongjianZhu Oct 27, 2019
2adec1f
test: selenium test for issue 2
YongjianZhu Oct 27, 2019
2dd7c52
test: selenium test for issue 1
YongjianZhu Oct 27, 2019
2b771ec
fix: change test urls
YongjianZhu Oct 28, 2019
18fd8c5
fix: change test urls
YongjianZhu Oct 28, 2019
aab5b73
Merge branch 'dev' of https://github.com/YongjianZhu/expertiza into dev
YongjianZhu Oct 28, 2019
607004f
test: #964 test
YongjianZhu Oct 28, 2019
0940a46
test: #987 test
YongjianZhu Oct 29, 2019
a241e97
test: #1188 test
YongjianZhu Oct 29, 2019
f4b250f
fix: create unsuccessfully render action new
YongjianZhu Oct 29, 2019
03edc0f
fix: create unsuccessfully render action new
YongjianZhu Oct 29, 2019
68b35b8
Merge branch 'dev' of https://github.com/YongjianZhu/expertiza into dev
YongjianZhu Oct 29, 2019
5bb828b
fix: remove personal emails in test file
YongjianZhu Nov 14, 2019
4250c4f
chore: add comments
YongjianZhu Nov 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 13 additions & 52 deletions README.md
@@ -1,59 +1,20 @@
Expertiza
E1971. OSS project Finklestein: Instructors & Institutions
=========

[![Build Status](https://travis-ci.org/expertiza/expertiza.svg?branch=master)](https://travis-ci.org/expertiza/expertiza)
[![Coverage Status](https://coveralls.io/repos/github/expertiza/expertiza/badge.svg?branch=master)](https://coveralls.io/github/expertiza/expertiza?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/f3a41f16c2b6e45aa9d4/maintainability)](https://codeclimate.com/github/expertiza/expertiza/maintainability)
**Team_4430:**
lli46, rwu5, yzhu48

#### Peer review system
**Mentor**
Carmen Bentley (cnaiken@ncsu.edu)

Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.
**What is does:**
Models can have many associations. For example, a ‘role’ can have many ‘users’ and the reverse a ‘user’ belongs to a ‘role. One important association in the Expertiza system is that between instructors and the institutions to which they belong. This can be an important attribute to groups, restrict, and even validate user permissions.

Setup
-----
**What’s wrong with it:**
Currently, models that can be associated with an institution are provided a pre-populated selection scroll when being created. This list should be presented in alphabetical order, but this is not the case when creating a new course. Additionally, and more importantly, there is an issue of associating an institution with a new instructor that is not listed in the selection scroll.

### NCSU VCL image
**What needs to be done:**
* Fix Issue #987: The institution list should be sorted alphabetically.
* Fix Issue #964: Adding a new institution during creation of an instructor profile.
* Fix Issue #1188: Listing of instructors should show their institutions on the same line as their new feature.

The expertiza environment is already set up in [NC State's VCL](https://vcl.ncsu.edu) image "[CSC517, S18] Ruby on Rails / Expertiza".

Using the VCL is the quickest way to get started, but you may find it awkward developing on a remote machine
with network lag and having to reinstall gems every time you connect. Installing locally can be a pain though too.
Life is full of tradeoffs. :-) The good news is that you can start on one environment, push your work to git,
and switch to another environment if you don't like the one you started with.

### Installing locally

See the Google doc on [setting up the Expertiza development environment](https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/edit).


<sub>Depreciation warning: See the Expertiza wiki for setup instructions. Please update the wiki with corrections or additional helpful information. (http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:OSX, http://wiki.expertiza.ncsu.edu/index.php/Development:Setup:Linux:RHEL, http://wiki.expertiza.ncsu.edu/index.php/Creating_a_Linux_Development_Environment_for_Expertiza_-_Installation_Guide)</sub>

Contributing
------------

* [Fork](http://help.github.com/fork-a-repo/) the expertiza project
* [Create a new branch](http://progit.org/book) for your contribution with a descriptive name
* [Commit and push](http://progit.org/book) until you are happy with your contribution - follow the style guidelines below
* Make sure to add tests for it; the tests should fail before your contribution/fix and pass afterward
* [Send a pull request](http://help.github.com/send-pull-requests) to have your code reviewed for merging back into Expertiza

Style Guidelines
----------------

We've had many contributors in the past who have used a wide variety of ruby coding styles. It's a mess, and we're trying to unify it.

All new files/contributions should:

* Use unix line endings (Windows users: configure git to use [autocrlf](http://help.github.com/line-endings))
* Indent with 2 spaces (no tabs; configure your editor) both in ruby and erb
* Follow the [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) style for syntax, formatting, and naming
* Follow the [design guidelines](https://github.com/expertiza/expertiza/blob/master/design_document.md) for the views.

When editing existing files:

* Keep the existing tabbing (use tabs instead of spaces in files that already use tabs everywhere; otherwise use spaces)
* Keep the existing line ending style (dos/unix)
* Follow the Ruby style Guide on code you add or edit, as above

Please do no go crazy changing old code to match these guidelines; it will just create lots of potential merge conflicts.
Applying style guidelines to code you add and modify is good enough. :-)
12 changes: 10 additions & 2 deletions app/controllers/users_controller.rb
Expand Up @@ -91,7 +91,7 @@ def show
get_role
# obtain number of assignments participated
@assignment_participant_num = 0
AssignmentParticipant.where(user_id: @user.id).each {|_participant| @assignment_participant_num += 1 }
AssignmentParticipant.where(user_id: @user.id).each { |_participant| @assignment_participant_num += 1 }
# judge whether this user become reviewer or reviewee
@maps = ResponseMap.where('reviewee_id = ? or reviewer_id = ?', params[:id], params[:id])
# count the number of users in DB
Expand All @@ -116,6 +116,13 @@ def create
# if the user name already exists, register the user by email address
check = User.find_by(name: params[:user][:name])
params[:user][:name] = params[:user][:email] unless check.nil?
# check whether the institution exists or not
# if it exists, return that institution
# if not create a new one(in the view page, the user choose other institution)
if params[:user][:institution_id].empty?
institution = Institution.find_or_create_by(name: params[:institution][:name])
params[:user][:institution_id] = institution.id
end
@user = User.new(user_params)
@user.institution_id = params[:user][:institution_id]
# record the person who created this new user
Expand All @@ -137,6 +144,7 @@ def create
redirect_to action: 'list'
else
foreign
flash[:error] = "Create Instructor Error!"
render action: 'new'
end
end
Expand Down Expand Up @@ -297,7 +305,7 @@ def user_params

def requested_user_params
params.require(:user).permit(:name, :role_id, :fullname, :institution_id, :email)
.merge(self_introduction: params[:requested_user][:self_introduction])
.merge(self_introduction: params[:requested_user][:self_introduction])
end

def get_role
Expand Down
31 changes: 24 additions & 7 deletions app/models/user.rb
Expand Up @@ -47,7 +47,7 @@ def list_mine(object_type, user_id)
def get_available_users(name)
lesser_roles = role.get_parents
all_users = User.all(conditions: ['name LIKE ?', "#{name}%"], limit: 20) # higher limit, since we're filtering
visible_users = all_users.select {|user| lesser_roles.include? user.role }
visible_users = all_users.select { |user| lesser_roles.include? user.role }
visible_users[0, 10] # the first 10
end

Expand Down Expand Up @@ -108,6 +108,18 @@ def first_name(ip_address = nil)
User.anonymized_view?(ip_address) ? self.role.name : fullname.try(:[], /,.+/).try(:[], /\w+/) || ''
end

# get the user's institution
def institution(ip_address = nil)
if User.anonymized_view?(ip_address)
self.role.name + ', ' + self.id.to_s
else
# check whether this user is an instructor and has an affiliated institution
if self[:role_id] == 2
self[:institution_id].nil? ? "" : Institution.find(self[:institution_id]).name
end
end
end

def email(ip_address = nil)
User.anonymized_view?(ip_address) ? self.role.name + '_' + self.id.to_s + '@mailinator.com' : self[:email]
end
Expand Down Expand Up @@ -192,11 +204,16 @@ def get_instructor

def instructor_id
case role.name
when 'Super-Administrator' then id
when 'Administrator' then id
when 'Instructor' then id
when 'Teaching Assistant' then Ta.get_my_instructor(id)
else raise NotImplementedError, "for role #{role.name}"
when 'Super-Administrator' then
id
when 'Administrator' then
id
when 'Instructor' then
id
when 'Teaching Assistant' then
Ta.get_my_instructor(id)
else
raise NotImplementedError, "for role #{role.name}"
end
end

Expand All @@ -222,7 +239,7 @@ def generate_keys

# return the new private key
new_key.to_pem
end
end

def initialize(attributes = nil)
super(attributes)
Expand Down
3 changes: 2 additions & 1 deletion app/views/course/_course.html.erb
@@ -1,6 +1,7 @@
<!--[form:course]-->
<p><label for="institution_name">Institution Name</label><br/>
<%= select("course", "institutions_id", Institution.all.collect{ |c| [ c.name, c.id] }) %></p>
<!-- sort those institutions by name before rendering the view-->
<%= select("course", "institutions_id", Institution.all.order(:name).collect{ |c| [ c.name, c.id] }) %></p>

<p><label for="course_name">Course Name</label><br/>
<%= text_field 'course', 'name' %></p>
Expand Down
5 changes: 3 additions & 2 deletions app/views/users/list.html.erb
Expand Up @@ -17,12 +17,13 @@
<div class="exp">
<table>
<tr><th colspan=5></th><th colspan=3 class="head">E-mail on ...</th></tr>
<tr><th class="head">Name</th><th class="head">Full Name</th><th class="head">Email Address</th><th class="head">Role</th><th class="head">Parent</th><th class="head">Review</th><th class="head">Submission</th><th class="head">Meta-review</th></tr>
<tr><th class="head">Name</th><th class="head">Full Name</th><th class="head">Institution</th><th class="head">Email Address</th><th class="head">Role</th><th class="head">Parent</th><th class="head">Review</th><th class="head">Submission</th><th class="head">Metareview</th></tr>
<% for user in @users %>
<% if ((params[:show] != 'true' && !user.name(session[:ip]).include?("_hidden")) || params[:show] == 'true')%>
<tr class="exp">
<td><%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %></td>
<td><%= link_to user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => user.id %></td>
<td><%= user.institution(session[:ip]) %></td>
<td><%= user.email(session[:ip]) %></td>
<td><%= link_to user.role.name, :controller => 'roles', :action => 'show', :id => user.role.id %></td>
<td align="center"><%= user.parent.try :name %></td>
Expand All @@ -37,7 +38,7 @@
<hr/>

<hr/>
<%= render :partial => 'shared_scripts/pages' %>
<%#= render :partial => 'shared_scripts/pages' %>

<p>
<%
Expand Down
3 changes: 2 additions & 1 deletion app/views/users/new.html.erb
Expand Up @@ -4,7 +4,8 @@
<p><label for="role_id">Role</label><br/>
<%= collection_select 'user', 'role_id', @all_roles, :id, :name, {:selected => @rolename.id} %></p>

<%= render :partial => 'user', :locals => { :new_user => true , :request_user =>false} %>
<%= render :partial => 'user', :locals => {:new_user => true, :request_user => false} %>
<p style="color: red; font-weight: bold">* Please Make Sure All Information is Correct</p>
<%= submit_tag "Create" %>
<% end %>

Expand Down
1 change: 0 additions & 1 deletion db/schema.rb
Expand Up @@ -630,7 +630,6 @@
t.string "status", limit: 255
t.string "unityID", limit: 255
t.string "signup_preference", limit: 255
t.string "feedback", limit: 255
end

create_table "survey_deployments", force: :cascade do |t|
Expand Down