From 3f76d48e605f65dd829d76a403371b382eb57d7d Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:40:59 -0400
Subject: [PATCH 01/11] Update validation
---
app/models/user.rb | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/models/user.rb b/app/models/user.rb
index 48af212e2..bc0a91085 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -17,7 +17,8 @@ class User < ApplicationRecord
has_one :github_integration
trim_field :school
- validates :first_name, :last_name, :email, presence: true
+ validates :email, presence: true
+ validate :first_or_last_name
# check if user is instructor in any course
def instructor?
@@ -261,4 +262,12 @@ def self.ldap_lookup(andrew_id)
result
end
+
+private
+
+ def first_or_last_name
+ return if first_name.present? || last_name.present?
+
+ errors.add(:base, "Student first name and last name can't both be blank")
+ end
end
From 1afcfcae4e9528a9dfeca01ae7293f220a1d0d99 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:41:16 -0400
Subject: [PATCH 02/11] Fix styling for full_name and display_name
---
app/models/user.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/models/user.rb b/app/models/user.rb
index bc0a91085..73e395c4e 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,7 +42,7 @@ def instructor_of?(user)
end
def full_name
- "#{first_name} #{last_name}"
+ [first_name, last_name].reject(&:empty?).join(' ')
end
def full_name_with_email
@@ -50,7 +50,7 @@ def full_name_with_email
end
def display_name
- first_name && last_name ? full_name : email
+ first_name.present? && last_name.present? ? full_name : email
end
def after_create
From 07dbf302acfaddbd46c2ab1d792fc2f58fe2f31b Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:41:27 -0400
Subject: [PATCH 03/11] Fix styling for gradesheet
---
app/views/assessments/viewGradesheet.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/assessments/viewGradesheet.html.erb b/app/views/assessments/viewGradesheet.html.erb
index 85ca71614..40f81f511 100755
--- a/app/views/assessments/viewGradesheet.html.erb
+++ b/app/views/assessments/viewGradesheet.html.erb
@@ -46,7 +46,7 @@
<% for s in @submissions do %>
{ "id": "",
"name": {
- name: "<%= s.course_user_datum.last_name %>, <%= s.course_user_datum.first_name %>",
+ name: "<%= [s.course_user_datum.last_name, s.course_user_datum.first_name].reject(&:blank?).join(', ') %>",
email: "<%= s.course_user_datum.email %>"
},
"lec": "<%= s.course_user_datum.lecture %>",
From 461c7a2d9bd06ebf94f2bc255ac37ea7b13ca075 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:42:21 -0400
Subject: [PATCH 04/11] Fix styling for manage submissions
---
app/views/submissions/index.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/submissions/index.html.erb b/app/views/submissions/index.html.erb
index 6b577027e..4a01ec733 100755
--- a/app/views/submissions/index.html.erb
+++ b/app/views/submissions/index.html.erb
@@ -99,7 +99,7 @@
- <%= "#{submission.course_user_datum.last_name}, #{submission.course_user_datum.first_name}" %>
+ | <%= [submission.course_user_datum.last_name, submission.course_user_datum.first_name].reject(&:blank?).join(', ') %>
<%= link_to submission.course_user_datum.email,
history_course_assessment_path(@course, @assessment, cud_id: submission.course_user_datum_id, partial: true),
{remote: true, class: :trigger}
From 8e8573de6c7e19e860b478c0a20d5c39e9a50597 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:44:04 -0400
Subject: [PATCH 05/11] Fix styling for Account page
---
app/views/users/show.html.erb | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index f07e9a649..c7fffda6e 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -5,8 +5,18 @@
<%= @user.email %>
About
- First name <%= @user.first_name %>
- Last name <%= @user.last_name %>
+ <% if @user.first_name.present? %>
+ First name: <%= @user.first_name %>
+ <% else %>
+ First name: (student has no first name)
+ <% end %>
+
+ <% if @user.last_name.present? %>
+ Last name: <%= @user.last_name %>
+ <% else %>
+ Last name: (student has no last name)
+ <% end %>
+
Courses
<% if @cuds.empty? %>
None
From be6988dc67ee9cdf78d08710aaaee1103fd7b8e8 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:44:59 -0400
Subject: [PATCH 06/11] Fix styling for view Student page
---
app/views/course_user_data/show.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/course_user_data/show.html.erb b/app/views/course_user_data/show.html.erb
index d87bc19f2..b8d800651 100755
--- a/app/views/course_user_data/show.html.erb
+++ b/app/views/course_user_data/show.html.erb
@@ -1,8 +1,8 @@
-<%= @requestedUser.first_name %> <%= @requestedUser.last_name %> (<%= @requestedUser.nickname %>)
+<%= @requestedUser.full_name %> (<%= @requestedUser.nickname %>)
- Contact
<%= @requestedUser.email %>
- - About
+ - About
Lecture <%= @requestedUser.lecture %>
Section <%= @requestedUser.section %>
Course <%= @requestedUser.course.full_name %>
From 37754c8f0b95a08be77c1378a3c4f30aa41130f0 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 15:46:08 -0400
Subject: [PATCH 07/11] Prevent roster success flash from persisting
unnecessarily
---
app/controllers/courses_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index d9c542134..f29442ed0 100755
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -258,7 +258,7 @@ def upload_roster
if params[:doIt]
begin
save_uploaded_roster
- flash[:success] = "Success!"
+ flash.now[:success] = "Successfully updated roster!"
rescue StandardError => e
if e != "Roster validation error"
flash[:error] = e
From d2124cbfe2bbb2baed7df98a5ac598df9ca5c7b9 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 16:47:41 -0400
Subject: [PATCH 08/11] Fix styling for watchlist
---
app/assets/javascripts/watchlist.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/assets/javascripts/watchlist.js b/app/assets/javascripts/watchlist.js
index d3f5f06aa..f33b53ea8 100644
--- a/app/assets/javascripts/watchlist.js
+++ b/app/assets/javascripts/watchlist.js
@@ -373,7 +373,8 @@ function get_watchlist_function(){
var id = _.get(watchlist_instance,'id');
var course_id = _.get(watchlist_instance,'course_id');
var user_id = _.get(watchlist_instance,'course_user_datum_id');
- var user_name = _.get(data,`["users"][${user_id}].first_name`) + " " + _.get(data,`["users"][${user_id}].last_name`);
+ // https://stackoverflow.com/questions/19902860/join-strings-with-a-delimiter-only-if-strings-are-not-null-or-empty
+ var user_name = [_.get(data,`["users"][${user_id}].first_name`), _.get(data,`["users"][${user_id}].last_name`)].filter(Boolean).join(' ');
var user_email = _.get(data,`["users"][${user_id}].email`);
var risk_condition_id = _.get(watchlist_instance,'risk_condition_id');
var watchlist_status = _.get(watchlist_instance,'status');
From 21f4083abd716537d4b675daf2fbc6621e06b323 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 16:47:53 -0400
Subject: [PATCH 09/11] Fix styling for scoreboard
---
app/controllers/scoreboards_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/scoreboards_controller.rb b/app/controllers/scoreboards_controller.rb
index cd8340ce2..a89b1643a 100755
--- a/app/controllers/scoreboards_controller.rb
+++ b/app/controllers/scoreboards_controller.rb
@@ -51,7 +51,7 @@ def show
@grades[uid] = {}
@grades[uid][:nickname] = user.nickname
@grades[uid][:andrewID] = user.email
- @grades[uid][:fullName] = "#{user.first_name} #{user.last_name}"
+ @grades[uid][:fullName] = user.full_name
@grades[uid][:problems] = {}
end
if @grades[uid][:version] != row["version"]
From d531e7b13124a3d32b35a5f82ebc45fad5aaf5bc Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 16:50:00 -0400
Subject: [PATCH 10/11] Fix styling for (unused?) course_user_data pages
---
app/views/course_user_data/index.html.erb | 2 +-
app/views/course_user_data/user.html.erb | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/views/course_user_data/index.html.erb b/app/views/course_user_data/index.html.erb
index 8fe881a49..b16bc66b1 100755
--- a/app/views/course_user_data/index.html.erb
+++ b/app/views/course_user_data/index.html.erb
@@ -1,6 +1,6 @@
Account Details for <%= @user.andrewID %>
-Name | | <%= @user.first_name %> <%= @user.last_name %> |
+Name | | <%= @user.full_name %> |
First Name | <%= @user.first_name %> |
Last Name | <%= @user.last_name %> |
andrewID | <%= @user.andrewID %> |
diff --git a/app/views/course_user_data/user.html.erb b/app/views/course_user_data/user.html.erb
index 280c94eea..99c922144 100755
--- a/app/views/course_user_data/user.html.erb
+++ b/app/views/course_user_data/user.html.erb
@@ -1,9 +1,9 @@
-<%= @requestedUser.first_name %> <%= @requestedUser.last_name %> (<%= @requestedUser.nickname %>)
+<%= @requestedUser.full_name %> (<%= @requestedUser.nickname %>)
- Contact
<%= @requestedUser.andrewID %> (andrewid)
<%= @requestedUser.email %>
- - About
+ - About
Lecture <%= @requestedUser.lecture %>
Section <%= @requestedUser.section %>
Course <%= @requestedUser.course.display_name %>
From e14601061a26569662dc89a89ea88974c7975314 Mon Sep 17 00:00:00 2001
From: Damian Ho
Date: Sun, 28 Aug 2022 16:57:07 -0400
Subject: [PATCH 11/11] Fix styling for grader information
---
app/controllers/assessment/grading.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/assessment/grading.rb b/app/controllers/assessment/grading.rb
index fa829998d..90a019bbb 100755
--- a/app/controllers/assessment/grading.rb
+++ b/app/controllers/assessment/grading.rb
@@ -293,11 +293,11 @@ def score_grader_info
grader = (if score then score.grader else nil end)
grader_info = ""
if grader
- grader_info = "#{grader.first_name} #{grader.last_name} (#{grader.email})"
+ grader_info = grader.full_name_with_email
end
feedback = score.feedback
- response = {"grader" => grader_info, "feedback" => feedback, "score" => score.score}
+ response = { "grader" => grader_info, "feedback" => feedback, "score" => score.score }
render json: response
end
|