From 7ff3d261b714998a84f7698b919dd833ef9b488e Mon Sep 17 00:00:00 2001 From: TimonDB Date: Thu, 5 Aug 2021 17:18:38 +0200 Subject: [PATCH 1/3] Set the current user's name as default teacher name when creating new course --- app/views/courses/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_form.html.erb b/app/views/courses/_form.html.erb index d2ba4d6ed9..83d3d86b46 100644 --- a/app/views/courses/_form.html.erb +++ b/app/views/courses/_form.html.erb @@ -51,7 +51,7 @@
<%= f.label :teacher, :class => "col-sm-3 col-form-label" %> -
<%= f.text_field :teacher, class: "form-control" %>
+
<%= f.text_field :teacher, class: "form-control", :value => current_user.full_name %>
<%= t ".teacher-help" %>
From 0f6c205fd35b613bbcf34b2334045845f24f3aa4 Mon Sep 17 00:00:00 2001 From: TimonDB Date: Thu, 5 Aug 2021 17:25:42 +0200 Subject: [PATCH 2/3] Set default value in controller instead of view --- app/controllers/courses_controller.rb | 5 ++++- app/views/courses/_form.html.erb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2d3ed7e57d..262c4e85e9 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -75,7 +75,10 @@ def new }.merge(@copy_options).symbolize_keys else @copy_options = nil - @course = Course.new(institution: current_user.institution) + @course = Course.new( + teacher: current_user.full_name, + institution: current_user.institution + ) end @title = I18n.t('courses.new.title') diff --git a/app/views/courses/_form.html.erb b/app/views/courses/_form.html.erb index 83d3d86b46..d2ba4d6ed9 100644 --- a/app/views/courses/_form.html.erb +++ b/app/views/courses/_form.html.erb @@ -51,7 +51,7 @@
<%= f.label :teacher, :class => "col-sm-3 col-form-label" %> -
<%= f.text_field :teacher, class: "form-control", :value => current_user.full_name %>
+
<%= f.text_field :teacher, class: "form-control" %>
<%= t ".teacher-help" %>
From 914f914490c4d3a0a0075982e532acfe7e9926f3 Mon Sep 17 00:00:00 2001 From: TimonDB Date: Mon, 9 Aug 2021 09:30:59 +0200 Subject: [PATCH 3/3] Set better default values when copying a course --- app/controllers/courses_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 262c4e85e9..0be2e6203f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -62,10 +62,10 @@ def new @course = Course.new( name: @copy_options[:base].name, description: @copy_options[:base].description, - institution: @copy_options[:base].institution, + institution: current_user.institution, visibility: @copy_options[:base].visibility, registration: @copy_options[:base].registration, - teacher: @copy_options[:base].teacher + teacher: current_user.full_name ) @copy_options = { admins: current_user.course_admin?(@copy_options[:base]),