From 5a459323ff720360dbe990272cd6773c000e5f24 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 14:09:32 +0200 Subject: [PATCH 01/33] Add draft flag to DB (and config?) --- app/models/activity.rb | 7 +++++++ app/models/content_page.rb | 1 + app/models/exercise.rb | 1 + db/migrate/20230922115708_add_draft_to_activities.rb | 5 +++++ db/schema.rb | 3 ++- test/factories/content_pages.rb | 1 + test/factories/exercises.rb | 1 + test/fixtures/exercises.yml | 1 + test/models/activity_test.rb | 1 + test/models/exercise_test.rb | 1 + 10 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230922115708_add_draft_to_activities.rb diff --git a/app/models/activity.rb b/app/models/activity.rb index 8836913da8..f10a543358 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require 'pathname' @@ -66,6 +67,7 @@ class Activity < ApplicationRecord before_create :generate_repository_token, if: ->(ex) { ex.repository_token.nil? } before_create :generate_access_token + before_create :activate_draft_mode before_update :update_config scope :content_pages, -> { where(type: ContentPage.name) } @@ -298,6 +300,7 @@ def update_config c = config c.delete('visibility') c['access'] = access if defined?(access) && access != merged_config['access'] + c['draft'] = draft if defined?(draft) c['description']['names']['nl'] = name_nl if name_nl.present? || c['description']['names']['nl'].present? c['description']['names']['en'] = name_en if name_en.present? || c['description']['names']['en'].present? c['internals'] = {} @@ -506,4 +509,8 @@ def unique_labels(hash) hash['labels'] = hash['labels'].uniq if hash.key? 'labels' hash end + + def activate_draft_mode + self.draft = true + end end diff --git a/app/models/content_page.rb b/app/models/content_page.rb index 5b40275d30..6136a20dea 100644 --- a/app/models/content_page.rb +++ b/app/models/content_page.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # class ContentPage < Activity diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 23027bb738..2be76bfd3f 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require 'pathname' diff --git a/db/migrate/20230922115708_add_draft_to_activities.rb b/db/migrate/20230922115708_add_draft_to_activities.rb new file mode 100644 index 0000000000..c68e15ef53 --- /dev/null +++ b/db/migrate/20230922115708_add_draft_to_activities.rb @@ -0,0 +1,5 @@ +class AddDraftToActivities < ActiveRecord::Migration[7.0] + def change + add_column :activities, :draft, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index a501f8e4a3..8f33e0773a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_08_10_105908) do +ActiveRecord::Schema[7.0].define(version: 2023_09_22_115708) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -59,6 +59,7 @@ t.boolean "description_nl_present", default: false t.boolean "description_en_present", default: false t.integer "series_count", default: 0, null: false + t.boolean "draft", default: false t.index ["judge_id"], name: "index_activities_on_judge_id" t.index ["name_nl"], name: "index_activities_on_name_nl" t.index ["path", "repository_id"], name: "index_activities_on_path_and_repository_id", unique: true diff --git a/test/factories/content_pages.rb b/test/factories/content_pages.rb index 64df42ed1f..aa87872f6e 100644 --- a/test/factories/content_pages.rb +++ b/test/factories/content_pages.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" diff --git a/test/factories/exercises.rb b/test/factories/exercises.rb index 1399693a9c..835cd4866f 100644 --- a/test/factories/exercises.rb +++ b/test/factories/exercises.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" diff --git a/test/fixtures/exercises.yml b/test/fixtures/exercises.yml index 51040f7026..435b234b15 100644 --- a/test/fixtures/exercises.yml +++ b/test/fixtures/exercises.yml @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # python_exercise: diff --git a/test/models/activity_test.rb b/test/models/activity_test.rb index 6e3d02ff59..1a8103bdad 100644 --- a/test/models/activity_test.rb +++ b/test/models/activity_test.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require 'test_helper' diff --git a/test/models/exercise_test.rb b/test/models/exercise_test.rb index 541f8a7571..fc94dfec23 100644 --- a/test/models/exercise_test.rb +++ b/test/models/exercise_test.rb @@ -22,6 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null +# draft :boolean default(FALSE) # require 'test_helper' From 08a6d41cdfcb6c008440a7a16e229be8829d1e65 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 14:35:35 +0200 Subject: [PATCH 02/33] Add draft mode to edit screen --- app/views/activities/_form.html.erb | 21 ++++++++++++--------- config/locales/views/activities/en.yml | 4 ++++ config/locales/views/activities/nl.yml | 4 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/views/activities/_form.html.erb b/app/views/activities/_form.html.erb index 8e3a0b2ae1..c22b0e9ba5 100644 --- a/app/views/activities/_form.html.erb +++ b/app/views/activities/_form.html.erb @@ -1,7 +1,3 @@ -<% content_for :javascripts do %> - <% # TODO rename pack to activity %> - <% javascript_include_tag 'exercise' %> -<% end %> <%= form_for(activity.becomes(Activity), :url => activity_scoped_path(activity: activity, course: @course, series: @series), :html => {:class => 'form-horizontal'}) do |f| %> <% if activity.errors.any? %>
@@ -30,15 +26,22 @@
<%= f.text_field :labels, class: 'form-control', disable: !f.permission?(:labels), value: activity.labels.map(&:name).join(','), placeholder: t(".labels") %>
<%= t '.labels_delimiter' %>
+
+ <%= f.label :draft, t(".draft.title"), :class => "col-sm-3 col-12 col-form-label" %> +
+
+ <%= f.check_box :draft, class: 'form-check-input' %> + <%= f.label :draft, t(".draft.toggle-label"), class: 'form-check-label' %> +
+
+ <%= t '.draft.help' %> +
-
<%= link_to t(".open_on_github"), activity.github_url, target: '_blank', rel: 'noopener' %>
+
<%= link_to t(".open_on_github"), activity.github_url, target: '_blank', rel: 'noopener' %>
-
<%= link_to t(".info_description"), info_activity_scoped_path(activity: @activity, course: @course, series: @series), rel: 'noopener' %>
+
<%= link_to t(".info_description"), info_activity_scoped_path(activity: @activity, course: @course, series: @series), rel: 'noopener' %>
<% end %> - diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 35ae41da10..48101ab543 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -27,6 +27,10 @@ en: labels: New label info: Information info_description: Go to the information page of this learning activity + draft: + title: "Draft" + toggle-label: "Put activity in draft mode." + help: "Draft mode provides better error logging for teachers and hides the activity from students. Draft mode is activated by default for new activities." index: title: Exercises exercise: Exercise diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 2b5d2f1117..71fb802439 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -27,6 +27,10 @@ nl: labels: Nieuw label info: Informatie info_description: Ga naar de informatiepagina van deze leeractiviteit + draft: + title: "Ontwerp" + toggle-label: "Activeer de ontwerpmodus." + help: "Ontwerpmodus zorgt voor betere foutmeldingen voor leerkrachten en verbergt de activiteit voor studenten." index: title: Oefeningen exercise: Oefening From 685ed5dc6dc8e8b32a09d3a957b8797c38543cd1 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 14:46:53 +0200 Subject: [PATCH 03/33] Update access rights for draft activities --- app/models/activity.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index f10a543358..5a7808c6fe 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -319,19 +319,22 @@ def accessible?(user, course) if user&.course_admin? course return false unless course.activities.pluck(:id).include? id elsif user&.member_of? course - return false unless course.accessible_activities.pluck(:id).include? id - else - return false unless course.visible_activities.pluck(:id).include? id + return false if course.accessible_activities.pluck(:id).exclude?(id) || draft? + elsif course.visible_activities.pluck(:id).exclude?(id) || draft? + return false end return true if user&.zeus? return false unless access_public? \ || repository.allowed_courses.pluck(:id).include?(course&.id) - return true if user&.member_of? course + return true if user&.course_admin? course + return false if draft? + return true if user&.member_of?(course) return false if course.moderated && access_private? course.open_for_user?(user) else return true if user&.repository_admin? repository + return false if draft? access_public? end From 8be1451a4132e15764dc9ae42477925e17d95855 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 15:00:20 +0200 Subject: [PATCH 04/33] Do not email draft errors --- app/models/submission.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/submission.rb b/app/models/submission.rb index 2c81f58dbf..232a4ea93e 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -518,6 +518,7 @@ def update_fs end def report_if_internal_error + return if draft? return unless status_changed? && send(:'internal error?') ExceptionNotifier.notify_exception( From 64b2d960bf6e948bcc6925d083e2064aa293f789 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 15:04:10 +0200 Subject: [PATCH 05/33] Fix don't sent email function --- app/models/submission.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 232a4ea93e..4da2e8a49f 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -518,7 +518,7 @@ def update_fs end def report_if_internal_error - return if draft? + return if exercise&.draft? return unless status_changed? && send(:'internal error?') ExceptionNotifier.notify_exception( From 4c4d4c3a16fa349b4fe3936d7f124cc0276b6226 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 15:07:01 +0200 Subject: [PATCH 06/33] Allow editing draft in the policy --- app/policies/activity_policy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/policies/activity_policy.rb b/app/policies/activity_policy.rb index 87af4de6f8..eaf905f2e3 100644 --- a/app/policies/activity_policy.rb +++ b/app/policies/activity_policy.rb @@ -75,7 +75,7 @@ def read? def permitted_attributes if update? - %i[access name_nl name_en] + %i[access name_nl name_en draft] else [] end From 2f570b807f08b4847a2cc4c2a43a3b859c919cd5 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 25 Sep 2023 14:30:03 +0200 Subject: [PATCH 07/33] Show draft images on home page --- app/controllers/pages_controller.rb | 2 ++ app/models/user.rb | 7 +++++++ app/views/pages/_user_card.html.erb | 21 +++++++++++++++++++++ config/locales/views/pages/en.yml | 2 ++ config/locales/views/pages/nl.yml | 2 ++ 5 files changed, 34 insertions(+) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index ba2f81766b..7e71a5a301 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -22,6 +22,8 @@ def home @homepage_series = courses.map { |c| c.homepage_series(current_user, 0) }.flatten.sort_by(&:deadline) @jump_back_in = current_user.jump_back_in + + @draft_exercises = current_user.draft_exercises.reorder(updated_at: :desc) if current_user.a_repository_admin? else set_metrics respond_to do |format| diff --git a/app/models/user.rb b/app/models/user.rb index ccd437bd9c..35a07a9491 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -107,6 +107,13 @@ class User < ApplicationRecord has_many :repositories, through: :repository_admins, source: :repository + has_many :draft_exercises, + lambda { + where activities: + { draft: true } + }, + through: :repositories, + source: :exercises has_many :annotations, dependent: :restrict_with_error has_many :questions, dependent: :restrict_with_error diff --git a/app/views/pages/_user_card.html.erb b/app/views/pages/_user_card.html.erb index 2673cfc273..7948e33b2f 100644 --- a/app/views/pages/_user_card.html.erb +++ b/app/views/pages/_user_card.html.erb @@ -15,6 +15,27 @@ +<% if @draft_exercises.present? %> +
+
+
<%= t ".draft-exercises" %>
+ <% @draft_exercises.first(5).each do |exercise| %> +

+ <%= link_to activity_submissions_path(exercise), class: 'btn-icon float-end' do %> + + <% end %> + <%= activity_icon exercise %> + <%= link_to exercise.name, activity_path(exercise), class: "course-link", title: exercise.name %> + <%= link_to exercise.repository.name, repository_path(exercise.repository), class: "small text-muted course-link", title: exercise.repository.name %> +

+ <% end %> + <% if @draft_exercises.count > 5 %> + <%= link_to t(".all-draft-exercises") ,activities_path %> + <% end %> +
+
+<% end %> + <% deadlines = @homepage_series %> <% if deadlines.any? %>
diff --git a/config/locales/views/pages/en.yml b/config/locales/views/pages/en.yml index 3aea74565e..e498fc15de 100644 --- a/config/locales/views/pages/en.yml +++ b/config/locales/views/pages/en.yml @@ -101,6 +101,8 @@ en: submissions: Submissions correct-exercises: Correct exercises recent-exercises: Recent exercises + draft-exercises: Draft exercises + all-draft-exercises: All draft exercises getting_started_card: title: Hi there, text: It looks like you're new here. To get started, register for a course. diff --git a/config/locales/views/pages/nl.yml b/config/locales/views/pages/nl.yml index bfe7e3bed6..8861dc0e60 100644 --- a/config/locales/views/pages/nl.yml +++ b/config/locales/views/pages/nl.yml @@ -101,6 +101,8 @@ nl: submissions: Ingediende oplossingen correct-exercises: Correcte oefeningen recent-exercises: Recente oefeningen + draft-exercises: Oefeningen in ontwerpmodus + all-draft-exercises: Alle oefeningen in ontwerpmodus getting_started_card: title: Hallo, text: Welkom op Dodona! Registreer je voor een cursus om van start te gaan. From adb0e502404e0f9f2be58a7ab52c992b88604752 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 25 Sep 2023 14:46:56 +0200 Subject: [PATCH 08/33] Visualise draft modus for lists --- app/policies/activity_policy.rb | 2 +- app/views/activities/_repository_status.html.erb | 3 +++ config/locales/views/activities/en.yml | 1 + config/locales/views/activities/nl.yml | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/policies/activity_policy.rb b/app/policies/activity_policy.rb index eaf905f2e3..cbc4b0f7a4 100644 --- a/app/policies/activity_policy.rb +++ b/app/policies/activity_policy.rb @@ -4,7 +4,7 @@ def resolve if user&.zeus? scope.all else - scope.where(access: :public, status: :ok).or(scope.where(repository: user&.repositories)) + scope.where(access: :public, status: :ok, draft: false).or(scope.where(repository: user&.repositories)) end end end diff --git a/app/views/activities/_repository_status.html.erb b/app/views/activities/_repository_status.html.erb index 4e4c9f135e..e41a5f5ccb 100644 --- a/app/views/activities/_repository_status.html.erb +++ b/app/views/activities/_repository_status.html.erb @@ -6,3 +6,6 @@ <% elsif activity.not_valid? %> <% end %> +<% if activity.draft? %> + +<% end %> diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 48101ab543..5861e6c4b2 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -71,6 +71,7 @@ en: mine: "My activities" featured: "Featured activities" all: "All activities" + draft-notice: "This activity is in draft mode. It is not visible for students." show: code: Code handin: Hand in diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 71fb802439..2386b5b5ee 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -71,6 +71,7 @@ nl: mine: "Mijn activiteiten" featured: "Uitgelichte activiteiten" all: "Alle activiteiten" + draft-notice: "Deze activiteit is in ontwerpmodus. Ze is niet zichtbaar voor studenten." show: code: Code handin: Indienen From a4307f57cfe0c85f2fba303cee602742c2f840d5 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 25 Sep 2023 14:55:56 +0200 Subject: [PATCH 09/33] Filter activities by draft flag --- app/controllers/activities_controller.rb | 1 + app/models/activity.rb | 1 + app/views/pages/_user_card.html.erb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 690bf647e7..f34eb6b56c 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -25,6 +25,7 @@ class ActivitiesController < ApplicationController has_scope :by_description_languages, as: 'description_languages', type: :array has_scope :by_judge, as: 'judge_id' has_scope :by_popularities, as: 'popularity', type: :array + has_scope :is_draft, as: 'draft', type: :boolean has_scope :repository_scope, as: 'tab' do |controller, scope, value| course = Series.find(controller.params[:id]).course if controller.params[:id] diff --git a/app/models/activity.rb b/app/models/activity.rb index 5a7808c6fe..02dd268796 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -82,6 +82,7 @@ class Activity < ApplicationRecord scope :by_programming_language, ->(programming_language) { includes(:programming_language).where(programming_languages: { name: programming_language }) } scope :by_type, ->(type) { where(type: type) } scope :by_judge, ->(judge) { where(judge_id: judge) } + scope :is_draft, -> { where(draft: true) } scope :by_description_languages, lambda { |languages| by_language = all # allow chaining of scopes by_language = by_language.where(description_en_present: true) if languages.include? 'en' diff --git a/app/views/pages/_user_card.html.erb b/app/views/pages/_user_card.html.erb index 7948e33b2f..8672f001c9 100644 --- a/app/views/pages/_user_card.html.erb +++ b/app/views/pages/_user_card.html.erb @@ -30,7 +30,7 @@

<% end %> <% if @draft_exercises.count > 5 %> - <%= link_to t(".all-draft-exercises") ,activities_path %> + <%= link_to t(".all-draft-exercises") ,activities_path(draft: true) %> <% end %>
From 8535338d8fdf0c10b3bdcc699130736dc1c42916 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 26 Sep 2023 10:08:03 +0200 Subject: [PATCH 10/33] Add draft warning to the top of the page --- app/views/activities/show.html.erb | 15 +++++++++++++++ bin/server | 2 +- config/locales/views/activities/en.yml | 2 ++ config/locales/views/activities/nl.yml | 2 ++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 855ecacab3..89780746fa 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -27,6 +27,21 @@ next_tooltip_actionable = next_activity ? t('.navigation.next_actionable') : t('.navigation.back_to_course_actionable') end %> +<% if @activity.draft? %> +
+ + <%= t "activities.show.alert_draft" %> + <% if policy(@activity).edit? %> + <% edit_path = @series.present? ? + course_series_activity_path(@series&.course, @series, @activity, {activity: {draft: false}}) : + activity_path(@activity, {activity: {draft: false}}) + %> + <%= link_to t("activities.show.alert_draft_edit"), edit_path, method: :put %> + + <% end %> +
+<% end %> +
<% if @activity.exercise? %>
diff --git a/bin/server b/bin/server index ce5526cbbd..9f195aec85 100755 --- a/bin/server +++ b/bin/server @@ -1,7 +1,7 @@ #!/bin/bash bundle install yarn install -bundle exec rails s -p 3000 & +#bundle exec rails s -p 3000 & bundle exec rails jobs:work & yarn build:css --watch & NODE_ENV=development yarn build:js --watch diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 5861e6c4b2..6847cff13f 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -102,6 +102,8 @@ en: preloaded_info: "We have preloaded your latest submission into the editor." preloaded_clear: Clear editor. preloaded_restore: Restore the initial code. + alert_draft: This activity is in draft mode. It is not visible for students. + alert_draft_edit: Disable draft mode. series_activities_add_table: course_added_to_usable: "Adding this exercise will allow this course to use all of the private exercises in this exercise's repository. Are you sure?" edit: diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 2386b5b5ee..2c80b8575b 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -102,6 +102,8 @@ nl: preloaded_info: We hebben jouw laatste oplossing ingeladen in de editor. preloaded_clear: Maak de editor leeg. preloaded_restore: Zet de voorbeeldcode terug. + alert_draft: Deze activiteit is in ontwerpmodus. Ze is niet zichtbaar voor studenten. + alert_draft_edit: Ze de ontwerpmodus uit. series_activities_add_table: course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?" edit: From 71c5747fc6da4fe64c36c39b3a59257de294f4da Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 26 Sep 2023 10:09:05 +0200 Subject: [PATCH 11/33] Fix server file --- bin/server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/server b/bin/server index 9f195aec85..ce5526cbbd 100755 --- a/bin/server +++ b/bin/server @@ -1,7 +1,7 @@ #!/bin/bash bundle install yarn install -#bundle exec rails s -p 3000 & +bundle exec rails s -p 3000 & bundle exec rails jobs:work & yarn build:css --watch & NODE_ENV=development yarn build:js --watch From 0c562099956287bf75d9360d5acfbdb18c8bbca9 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 26 Sep 2023 13:25:19 +0200 Subject: [PATCH 12/33] Fix existing tests --- test/factories/content_pages.rb | 3 +++ test/factories/exercises.rb | 2 ++ test/policies/exercise_policy_test.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/factories/content_pages.rb b/test/factories/content_pages.rb index aa87872f6e..a1539be93f 100644 --- a/test/factories/content_pages.rb +++ b/test/factories/content_pages.rb @@ -32,6 +32,7 @@ factory :content_page do access { 'public' } status { 'ok' } + draft { false } sequence(:path) { |n| "content_page#{n}" } @@ -57,6 +58,8 @@ stub_status(content, 'ok') content.stubs(:description_localized).returns(c.description_md_stubbed) end + # Draft is set to true by default, but we want to test non-draft activities + content.update(draft: false) end trait :config_stubbed do diff --git a/test/factories/exercises.rb b/test/factories/exercises.rb index 835cd4866f..80d9699b1c 100644 --- a/test/factories/exercises.rb +++ b/test/factories/exercises.rb @@ -75,6 +75,8 @@ stub_status(exercise, 'ok') exercise.stubs(:description_localized).returns(e.description_md_stubbed) end + # Draft is set to true by default, but we want to test non-draft exercises + exercise.update_column(:draft, false) end after :build do |exercise| diff --git a/test/policies/exercise_policy_test.rb b/test/policies/exercise_policy_test.rb index 185bb15333..3a6ebe1d46 100644 --- a/test/policies/exercise_policy_test.rb +++ b/test/policies/exercise_policy_test.rb @@ -27,6 +27,6 @@ def test_destroy; end policy = ExercisePolicy.new(create(:temporary_user), create(:exercise, :valid)) User.any_instance.stubs(:repository_admin?).returns(true) - assert_equal %i[access name_nl name_en], policy.permitted_attributes + assert_equal %i[access name_nl name_en draft], policy.permitted_attributes end end From ea8a8efd0a38b4102f2d765763d514e9f63217ca Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 26 Sep 2023 13:34:37 +0200 Subject: [PATCH 13/33] Fix linting --- test/factories/exercises.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/factories/exercises.rb b/test/factories/exercises.rb index 80d9699b1c..225701477f 100644 --- a/test/factories/exercises.rb +++ b/test/factories/exercises.rb @@ -76,7 +76,7 @@ exercise.stubs(:description_localized).returns(e.description_md_stubbed) end # Draft is set to true by default, but we want to test non-draft exercises - exercise.update_column(:draft, false) + exercise.update_column(:draft, false) # rubocop:disable Rails/SkipsModelValidations end after :build do |exercise| From fb6cbae21c08fffaddc7c04efc52586ef0a65f1b Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 26 Sep 2023 13:55:15 +0200 Subject: [PATCH 14/33] Add page access tests --- .../controllers/activities_controller_test.rb | 96 ++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/test/controllers/activities_controller_test.rb b/test/controllers/activities_controller_test.rb index 62ab509f36..0600c0689c 100644 --- a/test/controllers/activities_controller_test.rb +++ b/test/controllers/activities_controller_test.rb @@ -698,12 +698,106 @@ def create_exercises_return_valid assert_not resp['has_read'] end - test 'should be able to acess index when not signed in' do + test 'should be able to access index when not signed in' do sign_out @user get activities_url assert_response :success end + + test 'repo admin should be able to access own draft activities' do + sign_out @user + user = users(:staff) + sign_in user + repo = create :repository, :git_stubbed + repo.admins << user + exercise = create :exercise, :config_stubbed, repository: repo + exercise.update(draft: true) + get activity_url(exercise) + + assert_response :success + end + + test 'repo admin should not be able to access other draft activities' do + sign_out @user + user = users(:staff) + sign_in user + repo = create :repository, :git_stubbed + repo.admins << user + repo2 = create :repository, :git_stubbed + exercise = create :exercise, :config_stubbed, repository: repo2 + exercise.update(draft: true) + get activity_url(exercise) + + assert_redirected_to root_url + end + + test 'course admin should be able to access draft activities in course' do + sign_out @user + staff = users(:staff) + course_admin = users(:student) + course = create :course, series_count: 1 + course.administrating_members << staff + course.administrating_members << course_admin + + exercise = create :exercise, :config_stubbed + exercise.update(draft: true) + course.series.first.exercises << exercise + + sign_in staff + get course_activity_url(course, exercise) + + assert_response :success + sign_out staff + + sign_in course_admin + get course_activity_url(course, exercise) + + assert_response :success + end + + test 'course admin should not be able to access draft activities in other courses' do + sign_out @user + staff = users(:staff) + course_admin = users(:student) + course = create :course, series_count: 1 + course.administrating_members << staff + course.administrating_members << course_admin + + course2 = create :course, series_count: 1 + + exercise = create :exercise, :config_stubbed + exercise.update(draft: true) + course.series.first.exercises << exercise + course2.series.first.exercises << exercise + + sign_in staff + get course_activity_url(course2, exercise) + + assert_redirected_to root_url + sign_out staff + + sign_in course_admin + get course_activity_url(course2, exercise) + + assert_redirected_to root_url + end + + test 'student should not be able to access draft activities in course' do + sign_out @user + student = users(:student) + course = create :course, series_count: 1 + course.enrolled_members << student + + exercise = create :exercise, :config_stubbed + exercise.update(draft: true) + course.series.first.exercises << exercise + + sign_in student + get course_activity_url(course, exercise) + + assert_redirected_to root_url + end end class ExerciseErrorMailerTest < ActionDispatch::IntegrationTest From 4e0fcebfd2cc56fffda7ff164895895ae98b2a3a Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 27 Sep 2023 11:42:47 +0200 Subject: [PATCH 15/33] Update app/views/pages/_user_card.html.erb Co-authored-by: Niko Strijbol --- app/views/pages/_user_card.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/pages/_user_card.html.erb b/app/views/pages/_user_card.html.erb index 8672f001c9..d398f4dc0b 100644 --- a/app/views/pages/_user_card.html.erb +++ b/app/views/pages/_user_card.html.erb @@ -30,7 +30,7 @@

<% end %> <% if @draft_exercises.count > 5 %> - <%= link_to t(".all-draft-exercises") ,activities_path(draft: true) %> + <%= link_to t(".all-draft-exercises"), activities_path(draft: true) %> <% end %>
From 7b8bfaa34226d3ff36a88a00f5eb73fd785e983d Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 27 Sep 2023 11:42:54 +0200 Subject: [PATCH 16/33] Update config/locales/views/activities/nl.yml Co-authored-by: Niko Strijbol --- config/locales/views/activities/nl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 2c80b8575b..896bab6ac7 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -103,7 +103,7 @@ nl: preloaded_clear: Maak de editor leeg. preloaded_restore: Zet de voorbeeldcode terug. alert_draft: Deze activiteit is in ontwerpmodus. Ze is niet zichtbaar voor studenten. - alert_draft_edit: Ze de ontwerpmodus uit. + alert_draft_edit: Zet de ontwerpmodus uit. series_activities_add_table: course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?" edit: From 2e9dfbfc18b9ee3576c500d369717ae3d9160249 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 14:27:26 +0200 Subject: [PATCH 17/33] Mark as draft during repository reprocess --- app/models/activity.rb | 5 ----- app/models/repository.rb | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index 02dd268796..b4a26356d7 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -67,7 +67,6 @@ class Activity < ApplicationRecord before_create :generate_repository_token, if: ->(ex) { ex.repository_token.nil? } before_create :generate_access_token - before_create :activate_draft_mode before_update :update_config scope :content_pages, -> { where(type: ContentPage.name) } @@ -513,8 +512,4 @@ def unique_labels(hash) hash['labels'] = hash['labels'].uniq if hash.key? 'labels' hash end - - def activate_draft_mode - self.draft = true - end end diff --git a/app/models/repository.rb b/app/models/repository.rb index a9d0922ba0..18ff25cb01 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -212,6 +212,7 @@ def process_activities new_activities.each do |act| c = act.config + act.update(draft: true) c['internals'] = {} c['internals']['token'] = act.repository_token c['internals']['_info'] = 'These fields are used for internal bookkeeping in Dodona, please do not change them.' From 15736e25ab65428cbfeee98d42305531b3ae89c8 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 14:33:19 +0200 Subject: [PATCH 18/33] Update translation from ontwerp to concept --- config/locales/views/activities/nl.yml | 12 ++++++------ config/locales/views/pages/nl.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 896bab6ac7..8a8088679e 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -28,9 +28,9 @@ nl: info: Informatie info_description: Ga naar de informatiepagina van deze leeractiviteit draft: - title: "Ontwerp" - toggle-label: "Activeer de ontwerpmodus." - help: "Ontwerpmodus zorgt voor betere foutmeldingen voor leerkrachten en verbergt de activiteit voor studenten." + title: "Concept" + toggle-label: "Markeer als concept" + help: "Wanneer een oefening in concept modus staat, is ze onzichtbaar voor studenten en krijgen leerkrachten betere foutmeldingen." index: title: Oefeningen exercise: Oefening @@ -71,7 +71,7 @@ nl: mine: "Mijn activiteiten" featured: "Uitgelichte activiteiten" all: "Alle activiteiten" - draft-notice: "Deze activiteit is in ontwerpmodus. Ze is niet zichtbaar voor studenten." + draft-notice: "Deze activiteit is een concept. Ze is niet zichtbaar voor studenten." show: code: Code handin: Indienen @@ -102,8 +102,8 @@ nl: preloaded_info: We hebben jouw laatste oplossing ingeladen in de editor. preloaded_clear: Maak de editor leeg. preloaded_restore: Zet de voorbeeldcode terug. - alert_draft: Deze activiteit is in ontwerpmodus. Ze is niet zichtbaar voor studenten. - alert_draft_edit: Zet de ontwerpmodus uit. + alert_draft: Deze oefening is een concept. Ze is niet zichtbaar voor studenten. + alert_draft_edit: Markeer deze oefening als af. series_activities_add_table: course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?" edit: diff --git a/config/locales/views/pages/nl.yml b/config/locales/views/pages/nl.yml index 8861dc0e60..bf23a592f3 100644 --- a/config/locales/views/pages/nl.yml +++ b/config/locales/views/pages/nl.yml @@ -101,8 +101,8 @@ nl: submissions: Ingediende oplossingen correct-exercises: Correcte oefeningen recent-exercises: Recente oefeningen - draft-exercises: Oefeningen in ontwerpmodus - all-draft-exercises: Alle oefeningen in ontwerpmodus + draft-exercises: Concept oefeningen + all-draft-exercises: Alle concept oefeningen getting_started_card: title: Hallo, text: Welkom op Dodona! Registreer je voor een cursus om van start te gaan. From d34e984fe857508974df2d48651d65cfe45e2521 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 14:56:28 +0200 Subject: [PATCH 19/33] Revert "Mark as draft during repository reprocess" This reverts commit 2e9dfbfc18b9ee3576c500d369717ae3d9160249. --- app/models/activity.rb | 5 +++++ app/models/repository.rb | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index b4a26356d7..02dd268796 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -67,6 +67,7 @@ class Activity < ApplicationRecord before_create :generate_repository_token, if: ->(ex) { ex.repository_token.nil? } before_create :generate_access_token + before_create :activate_draft_mode before_update :update_config scope :content_pages, -> { where(type: ContentPage.name) } @@ -512,4 +513,8 @@ def unique_labels(hash) hash['labels'] = hash['labels'].uniq if hash.key? 'labels' hash end + + def activate_draft_mode + self.draft = true + end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 18ff25cb01..a9d0922ba0 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -212,7 +212,6 @@ def process_activities new_activities.each do |act| c = act.config - act.update(draft: true) c['internals'] = {} c['internals']['token'] = act.repository_token c['internals']['_info'] = 'These fields are used for internal bookkeeping in Dodona, please do not change them.' From 5cf0f257ecf3ffd4bc6ab2d577f17e77f20cfef0 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 11 Oct 2023 15:13:10 +0200 Subject: [PATCH 20/33] Always update draft flag --- app/models/activity.rb | 2 +- app/models/repository.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index 02dd268796..065ca160e2 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -301,7 +301,7 @@ def update_config c = config c.delete('visibility') c['access'] = access if defined?(access) && access != merged_config['access'] - c['draft'] = draft if defined?(draft) + c['draft'] = draft if defined?(draft) && draft != merged_config['draft'] c['description']['names']['nl'] = name_nl if name_nl.present? || c['description']['names']['nl'].present? c['description']['names']['en'] = name_en if name_en.present? || c['description']['names']['en'].present? c['internals'] = {} diff --git a/app/models/repository.rb b/app/models/repository.rb index a9d0922ba0..814c2a2867 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -212,6 +212,7 @@ def process_activities new_activities.each do |act| c = act.config + c['draft'] = act.draft # should be true as it is set in before_create c['internals'] = {} c['internals']['token'] = act.repository_token c['internals']['_info'] = 'These fields are used for internal bookkeeping in Dodona, please do not change them.' From a8647acb44e2c231296b31e3ded0f6f5ddc119ce Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 14:47:28 +0200 Subject: [PATCH 21/33] Apply suggestions from code review Co-authored-by: Bart Mesuere --- config/locales/views/activities/en.yml | 10 +++++----- config/locales/views/activities/nl.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 6847cff13f..19bd83c157 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -29,8 +29,8 @@ en: info_description: Go to the information page of this learning activity draft: title: "Draft" - toggle-label: "Put activity in draft mode." - help: "Draft mode provides better error logging for teachers and hides the activity from students. Draft mode is activated by default for new activities." + toggle-label: "Mark activity as draft." + help: "Mark activities as draft while you are still working on them." index: title: Exercises exercise: Exercise @@ -71,7 +71,7 @@ en: mine: "My activities" featured: "Featured activities" all: "All activities" - draft-notice: "This activity is in draft mode. It is not visible for students." + draft-notice: "This activity is a draft and thus not visible for students." show: code: Code handin: Hand in @@ -102,8 +102,8 @@ en: preloaded_info: "We have preloaded your latest submission into the editor." preloaded_clear: Clear editor. preloaded_restore: Restore the initial code. - alert_draft: This activity is in draft mode. It is not visible for students. - alert_draft_edit: Disable draft mode. + alert_draft: This activity is a draft and thus not visible for students. + alert_draft_edit: Publish activity. series_activities_add_table: course_added_to_usable: "Adding this exercise will allow this course to use all of the private exercises in this exercise's repository. Are you sure?" edit: diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 8a8088679e..2e85eac343 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -30,7 +30,7 @@ nl: draft: title: "Concept" toggle-label: "Markeer als concept" - help: "Wanneer een oefening in concept modus staat, is ze onzichtbaar voor studenten en krijgen leerkrachten betere foutmeldingen." + help: "Markeer een oefening als concept zolang je ze nog aan het opstellen bent." index: title: Oefeningen exercise: Oefening @@ -71,7 +71,7 @@ nl: mine: "Mijn activiteiten" featured: "Uitgelichte activiteiten" all: "Alle activiteiten" - draft-notice: "Deze activiteit is een concept. Ze is niet zichtbaar voor studenten." + draft-notice: "Deze activiteit is nog een concept. Ze is niet zichtbaar voor studenten." show: code: Code handin: Indienen @@ -102,8 +102,8 @@ nl: preloaded_info: We hebben jouw laatste oplossing ingeladen in de editor. preloaded_clear: Maak de editor leeg. preloaded_restore: Zet de voorbeeldcode terug. - alert_draft: Deze oefening is een concept. Ze is niet zichtbaar voor studenten. - alert_draft_edit: Markeer deze oefening als af. + alert_draft: Deze oefening is nog een concept. Ze is niet zichtbaar voor studenten. + alert_draft_edit: Deze oefening publiceren. series_activities_add_table: course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?" edit: From 0d493d20ec7136692032704c5aef7760d2f5bacc Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 16:48:10 +0200 Subject: [PATCH 22/33] Concept => ongepubliceerd --- config/locales/views/pages/nl.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/views/pages/nl.yml b/config/locales/views/pages/nl.yml index bf23a592f3..c1eee849de 100644 --- a/config/locales/views/pages/nl.yml +++ b/config/locales/views/pages/nl.yml @@ -101,8 +101,8 @@ nl: submissions: Ingediende oplossingen correct-exercises: Correcte oefeningen recent-exercises: Recente oefeningen - draft-exercises: Concept oefeningen - all-draft-exercises: Alle concept oefeningen + draft-exercises: Ongepubliceerde oefeningen + all-draft-exercises: Alle ongepubliceerde oefeningen getting_started_card: title: Hallo, text: Welkom op Dodona! Registreer je voor een cursus om van start te gaan. From 925b65a811fe5553050395fe4e570723433dfebc Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 17:01:53 +0200 Subject: [PATCH 23/33] Add links to doc --- app/models/repository.rb | 20 +++++++++++--------- app/views/activities/_form.html.erb | 2 +- app/views/activities/show.html.erb | 2 +- config/locales/views/activities/en.yml | 4 ++-- config/locales/views/activities/nl.yml | 4 ++-- db/schema.rb | 4 +++- test/factories/repositories.rb | 20 +++++++++++--------- test/models/repository_test.rb | 20 +++++++++++--------- 8 files changed, 42 insertions(+), 34 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 814c2a2867..0dda2643b4 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,15 +2,17 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) +# reprocess_queued :boolean default(FALSE) +# reprocess_running :boolean default(FALSE) # require 'open3' require 'pathname' diff --git a/app/views/activities/_form.html.erb b/app/views/activities/_form.html.erb index c22b0e9ba5..773e571a92 100644 --- a/app/views/activities/_form.html.erb +++ b/app/views/activities/_form.html.erb @@ -34,7 +34,7 @@ <%= f.label :draft, t(".draft.toggle-label"), class: 'form-check-label' %> - <%= t '.draft.help' %> + <%= t '.draft.help_html' %>
diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 89780746fa..7c4e77aff1 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -30,7 +30,7 @@ end %> <% if @activity.draft? %>
- <%= t "activities.show.alert_draft" %> + <%= t "activities.show.alert_draft_html" %> <% if policy(@activity).edit? %> <% edit_path = @series.present? ? course_series_activity_path(@series&.course, @series, @activity, {activity: {draft: false}}) : diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 19bd83c157..ed34bb736a 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -30,7 +30,7 @@ en: draft: title: "Draft" toggle-label: "Mark activity as draft." - help: "Mark activities as draft while you are still working on them." + help_html: Mark activities as draft while you are still working on them. index: title: Exercises exercise: Exercise @@ -102,7 +102,7 @@ en: preloaded_info: "We have preloaded your latest submission into the editor." preloaded_clear: Clear editor. preloaded_restore: Restore the initial code. - alert_draft: This activity is a draft and thus not visible for students. + alert_draft_html: This activity is a draft and thus not visible for students. alert_draft_edit: Publish activity. series_activities_add_table: course_added_to_usable: "Adding this exercise will allow this course to use all of the private exercises in this exercise's repository. Are you sure?" diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 2e85eac343..e962ce8f23 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -30,7 +30,7 @@ nl: draft: title: "Concept" toggle-label: "Markeer als concept" - help: "Markeer een oefening als concept zolang je ze nog aan het opstellen bent." + help_html: Markeer een oefening als concept zolang je ze nog aan het opstellen bent. index: title: Oefeningen exercise: Oefening @@ -102,7 +102,7 @@ nl: preloaded_info: We hebben jouw laatste oplossing ingeladen in de editor. preloaded_clear: Maak de editor leeg. preloaded_restore: Zet de voorbeeldcode terug. - alert_draft: Deze oefening is nog een concept. Ze is niet zichtbaar voor studenten. + alert_draft_html: Deze oefening is nog een concept. Ze is niet zichtbaar voor studenten. alert_draft_edit: Deze oefening publiceren. series_activities_add_table: course_added_to_usable: "Deze oefening toevoegen zal deze cursus toegang geven tot alle privé oefeningen in de repository van deze oefening. Ben je zeker?" diff --git a/db/schema.rb b/db/schema.rb index 8f33e0773a..f75e53ca6b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_22_115708) do +ActiveRecord::Schema[7.1].define(version: 2023_10_03_115520) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -393,6 +393,8 @@ t.datetime "updated_at", precision: nil, null: false t.integer "clone_status", default: 1, null: false t.boolean "featured", default: false + t.boolean "reprocess_queued", default: false + t.boolean "reprocess_running", default: false t.index ["judge_id"], name: "index_repositories_on_judge_id" t.index ["name"], name: "index_repositories_on_name", unique: true t.index ["path"], name: "index_repositories_on_path", unique: true diff --git a/test/factories/repositories.rb b/test/factories/repositories.rb index 7f45ca9bfa..f58c95831e 100644 --- a/test/factories/repositories.rb +++ b/test/factories/repositories.rb @@ -2,15 +2,17 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) +# reprocess_queued :boolean default(FALSE) +# reprocess_running :boolean default(FALSE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" diff --git a/test/models/repository_test.rb b/test/models/repository_test.rb index 66c5d068d6..d7adf8cd03 100644 --- a/test/models/repository_test.rb +++ b/test/models/repository_test.rb @@ -2,15 +2,17 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) +# reprocess_queued :boolean default(FALSE) +# reprocess_running :boolean default(FALSE) # require 'test_helper' From 3a39a7abf53875734e9e64cb8fdf3efb767d460c Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 19 Oct 2023 17:04:49 +0200 Subject: [PATCH 24/33] Undo unwanted annotations --- app/models/repository.rb | 20 +++++++++----------- db/schema.rb | 2 -- test/factories/repositories.rb | 20 +++++++++----------- test/models/repository_test.rb | 20 +++++++++----------- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 0dda2643b4..814c2a2867 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,17 +2,15 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) -# reprocess_queued :boolean default(FALSE) -# reprocess_running :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) # require 'open3' require 'pathname' diff --git a/db/schema.rb b/db/schema.rb index f75e53ca6b..c25f75171a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -393,8 +393,6 @@ t.datetime "updated_at", precision: nil, null: false t.integer "clone_status", default: 1, null: false t.boolean "featured", default: false - t.boolean "reprocess_queued", default: false - t.boolean "reprocess_running", default: false t.index ["judge_id"], name: "index_repositories_on_judge_id" t.index ["name"], name: "index_repositories_on_name", unique: true t.index ["path"], name: "index_repositories_on_path", unique: true diff --git a/test/factories/repositories.rb b/test/factories/repositories.rb index f58c95831e..7f45ca9bfa 100644 --- a/test/factories/repositories.rb +++ b/test/factories/repositories.rb @@ -2,17 +2,15 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) -# reprocess_queued :boolean default(FALSE) -# reprocess_running :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" diff --git a/test/models/repository_test.rb b/test/models/repository_test.rb index d7adf8cd03..66c5d068d6 100644 --- a/test/models/repository_test.rb +++ b/test/models/repository_test.rb @@ -2,17 +2,15 @@ # # Table name: repositories # -# id :integer not null, primary key -# name :string(255) -# remote :string(255) -# path :string(255) -# judge_id :integer -# created_at :datetime not null -# updated_at :datetime not null -# clone_status :integer default("queued"), not null -# featured :boolean default(FALSE) -# reprocess_queued :boolean default(FALSE) -# reprocess_running :boolean default(FALSE) +# id :integer not null, primary key +# name :string(255) +# remote :string(255) +# path :string(255) +# judge_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# clone_status :integer default("queued"), not null +# featured :boolean default(FALSE) # require 'test_helper' From 9a4499caea11315f6d8410002eb2023b806a37d7 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 26 Oct 2023 10:04:08 +0200 Subject: [PATCH 25/33] Apply feedback to simplify pr --- app/models/activity.rb | 12 +++--------- app/models/content_page.rb | 2 +- app/models/exercise.rb | 2 +- app/models/repository.rb | 1 - app/views/activities/_form.html.erb | 10 ---------- config/locales/views/activities/en.yml | 4 ---- config/locales/views/activities/nl.yml | 4 ---- .../20231026075353_make_draft_default_true.rb | 5 +++++ db/schema.rb | 4 ++-- db/seeds.rb | 3 +++ test/controllers/activities_controller_test.rb | 15 +++++---------- test/factories/content_pages.rb | 4 +--- test/factories/exercises.rb | 5 ++--- test/fixtures/exercises.yml | 2 +- test/models/activity_test.rb | 2 +- test/models/exercise_test.rb | 2 +- 16 files changed, 26 insertions(+), 51 deletions(-) create mode 100644 db/migrate/20231026075353_make_draft_default_true.rb diff --git a/app/models/activity.rb b/app/models/activity.rb index 7ec2bc0777..c963eb2cf4 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require 'pathname' @@ -67,7 +67,6 @@ class Activity < ApplicationRecord before_create :generate_repository_token, if: ->(ex) { ex.repository_token.nil? } before_create :generate_access_token - before_create :activate_draft_mode before_update :update_config scope :content_pages, -> { where(type: ContentPage.name) } @@ -300,7 +299,6 @@ def update_config c = config c.delete('visibility') c['access'] = access if defined?(access) && access != merged_config['access'] - c['draft'] = draft if defined?(draft) && draft != merged_config['draft'] c['description']['names']['nl'] = name_nl if name_nl.present? || c['description']['names']['nl'].present? c['description']['names']['en'] = name_en if name_en.present? || c['description']['names']['en'].present? c['internals'] = {} @@ -319,8 +317,8 @@ def accessible?(user, course) if user&.course_admin? course return false unless course.activities.pluck(:id).include? id elsif user&.member_of? course - return false if course.accessible_activities.pluck(:id).exclude?(id) || draft? - elsif course.visible_activities.pluck(:id).exclude?(id) || draft? + return false if course.accessible_activities.pluck(:id).exclude?(id) + elsif course.visible_activities.pluck(:id).exclude?(id) return false end return true if user&.zeus? @@ -512,8 +510,4 @@ def unique_labels(hash) hash['labels'] = hash['labels'].uniq if hash.key? 'labels' hash end - - def activate_draft_mode - self.draft = true - end end diff --git a/app/models/content_page.rb b/app/models/content_page.rb index 6136a20dea..36aba73448 100644 --- a/app/models/content_page.rb +++ b/app/models/content_page.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # class ContentPage < Activity diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 2be76bfd3f..034b759d21 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require 'pathname' diff --git a/app/models/repository.rb b/app/models/repository.rb index 814c2a2867..a9d0922ba0 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -212,7 +212,6 @@ def process_activities new_activities.each do |act| c = act.config - c['draft'] = act.draft # should be true as it is set in before_create c['internals'] = {} c['internals']['token'] = act.repository_token c['internals']['_info'] = 'These fields are used for internal bookkeeping in Dodona, please do not change them.' diff --git a/app/views/activities/_form.html.erb b/app/views/activities/_form.html.erb index 773e571a92..310f41a821 100644 --- a/app/views/activities/_form.html.erb +++ b/app/views/activities/_form.html.erb @@ -26,16 +26,6 @@
<%= f.text_field :labels, class: 'form-control', disable: !f.permission?(:labels), value: activity.labels.map(&:name).join(','), placeholder: t(".labels") %>
<%= t '.labels_delimiter' %>
-
- <%= f.label :draft, t(".draft.title"), :class => "col-sm-3 col-12 col-form-label" %> -
-
- <%= f.check_box :draft, class: 'form-check-input' %> - <%= f.label :draft, t(".draft.toggle-label"), class: 'form-check-label' %> -
-
- <%= t '.draft.help_html' %> -
<%= link_to t(".open_on_github"), activity.github_url, target: '_blank', rel: 'noopener' %>
diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index ed34bb736a..c2a93c19a0 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -27,10 +27,6 @@ en: labels: New label info: Information info_description: Go to the information page of this learning activity - draft: - title: "Draft" - toggle-label: "Mark activity as draft." - help_html: Mark activities as draft while you are still working on them. index: title: Exercises exercise: Exercise diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index e962ce8f23..1b6773c2c7 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -27,10 +27,6 @@ nl: labels: Nieuw label info: Informatie info_description: Ga naar de informatiepagina van deze leeractiviteit - draft: - title: "Concept" - toggle-label: "Markeer als concept" - help_html: Markeer een oefening als concept zolang je ze nog aan het opstellen bent. index: title: Oefeningen exercise: Oefening diff --git a/db/migrate/20231026075353_make_draft_default_true.rb b/db/migrate/20231026075353_make_draft_default_true.rb new file mode 100644 index 0000000000..cbdb1a6b16 --- /dev/null +++ b/db/migrate/20231026075353_make_draft_default_true.rb @@ -0,0 +1,5 @@ +class MakeDraftDefaultTrue < ActiveRecord::Migration[7.1] + def change + change_column_default :activities, :draft, from: false, to: true + end +end diff --git a/db/schema.rb b/db/schema.rb index c25f75171a..c7a60a2e37 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_10_03_115520) do +ActiveRecord::Schema[7.1].define(version: 2023_10_26_075353) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -59,7 +59,7 @@ t.boolean "description_nl_present", default: false t.boolean "description_en_present", default: false t.integer "series_count", default: 0, null: false - t.boolean "draft", default: false + t.boolean "draft", default: true t.index ["judge_id"], name: "index_activities_on_judge_id" t.index ["name_nl"], name: "index_activities_on_name_nl" t.index ["path", "repository_id"], name: "index_activities_on_path_and_repository_id", unique: true diff --git a/db/seeds.rb b/db/seeds.rb index b62c99253c..50bb9b6099 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -296,6 +296,9 @@ def fill_series_with_realistic_submissions(s) contents_list = ContentPage.all.to_a exercises_list = Exercise.all.to_a + # remove draft status from all activities + Activity.update_all(draft: false) + puts "Add series, content pages, exercises, read states and submissions to courses (#{Time.now - start})" # These callback take a good amount of time and aren't necessary diff --git a/test/controllers/activities_controller_test.rb b/test/controllers/activities_controller_test.rb index 0600c0689c..8e56c27f40 100644 --- a/test/controllers/activities_controller_test.rb +++ b/test/controllers/activities_controller_test.rb @@ -711,8 +711,7 @@ def create_exercises_return_valid sign_in user repo = create :repository, :git_stubbed repo.admins << user - exercise = create :exercise, :config_stubbed, repository: repo - exercise.update(draft: true) + exercise = create :exercise, :config_stubbed, repository: repo, draft: true get activity_url(exercise) assert_response :success @@ -725,8 +724,7 @@ def create_exercises_return_valid repo = create :repository, :git_stubbed repo.admins << user repo2 = create :repository, :git_stubbed - exercise = create :exercise, :config_stubbed, repository: repo2 - exercise.update(draft: true) + exercise = create :exercise, :config_stubbed, repository: repo2, draft: true get activity_url(exercise) assert_redirected_to root_url @@ -740,8 +738,7 @@ def create_exercises_return_valid course.administrating_members << staff course.administrating_members << course_admin - exercise = create :exercise, :config_stubbed - exercise.update(draft: true) + exercise = create :exercise, :config_stubbed, draft: true course.series.first.exercises << exercise sign_in staff @@ -766,8 +763,7 @@ def create_exercises_return_valid course2 = create :course, series_count: 1 - exercise = create :exercise, :config_stubbed - exercise.update(draft: true) + exercise = create :exercise, :config_stubbed, draft: true course.series.first.exercises << exercise course2.series.first.exercises << exercise @@ -789,8 +785,7 @@ def create_exercises_return_valid course = create :course, series_count: 1 course.enrolled_members << student - exercise = create :exercise, :config_stubbed - exercise.update(draft: true) + exercise = create :exercise, :config_stubbed, draft: true course.series.first.exercises << exercise sign_in student diff --git a/test/factories/content_pages.rb b/test/factories/content_pages.rb index a1539be93f..fda8ed24ba 100644 --- a/test/factories/content_pages.rb +++ b/test/factories/content_pages.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" @@ -58,8 +58,6 @@ stub_status(content, 'ok') content.stubs(:description_localized).returns(c.description_md_stubbed) end - # Draft is set to true by default, but we want to test non-draft activities - content.update(draft: false) end trait :config_stubbed do diff --git a/test/factories/exercises.rb b/test/factories/exercises.rb index 225701477f..fc4317dae8 100644 --- a/test/factories/exercises.rb +++ b/test/factories/exercises.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require "#{File.dirname(__FILE__)}/../testhelpers/stub_helper.rb" @@ -37,6 +37,7 @@ description_en_present { false } access { 'public' } status { 'ok' } + draft { false } sequence(:path) { |n| "exercise#{n}" } @@ -75,8 +76,6 @@ stub_status(exercise, 'ok') exercise.stubs(:description_localized).returns(e.description_md_stubbed) end - # Draft is set to true by default, but we want to test non-draft exercises - exercise.update_column(:draft, false) # rubocop:disable Rails/SkipsModelValidations end after :build do |exercise| diff --git a/test/fixtures/exercises.yml b/test/fixtures/exercises.yml index 435b234b15..342d59cebe 100644 --- a/test/fixtures/exercises.yml +++ b/test/fixtures/exercises.yml @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # python_exercise: diff --git a/test/models/activity_test.rb b/test/models/activity_test.rb index 1a8103bdad..397e416b06 100644 --- a/test/models/activity_test.rb +++ b/test/models/activity_test.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require 'test_helper' diff --git a/test/models/exercise_test.rb b/test/models/exercise_test.rb index fc94dfec23..c262d3be84 100644 --- a/test/models/exercise_test.rb +++ b/test/models/exercise_test.rb @@ -22,7 +22,7 @@ # description_nl_present :boolean default(FALSE) # description_en_present :boolean default(FALSE) # series_count :integer default(0), not null -# draft :boolean default(FALSE) +# draft :boolean default(TRUE) # require 'test_helper' From 242f61a18b9b65263a7e7bf8494aed600c7e3b38 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 26 Oct 2023 10:27:24 +0200 Subject: [PATCH 26/33] Do not allow reset to draft --- app/models/activity.rb | 1 + .../controllers/activities_controller_test.rb | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/app/models/activity.rb b/app/models/activity.rb index c963eb2cf4..c3e27c8794 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -57,6 +57,7 @@ class Activity < ApplicationRecord has_many :labels, through: :activity_labels validates :path, uniqueness: { scope: :repository_id, case_sensitive: false }, allow_nil: true + validates :draft, inclusion: { in: [false] }, unless: :draft_was token_generator :repository_token, length: 64 token_generator :access_token diff --git a/test/controllers/activities_controller_test.rb b/test/controllers/activities_controller_test.rb index 8e56c27f40..d6630565c8 100644 --- a/test/controllers/activities_controller_test.rb +++ b/test/controllers/activities_controller_test.rb @@ -793,6 +793,49 @@ def create_exercises_return_valid assert_redirected_to root_url end + + test 'repository admin should be able to publish draft activities' do + stub_all_activities! + sign_out @user + user = users(:staff) + sign_in user + repo = create :repository, :git_stubbed + repo.admins << user + exercise = create :exercise, repository: repo, draft: true + + put activity_url(exercise), params: { activity: { draft: false } } + + assert_not exercise.reload.draft + end + + test 'repository admin should not be able to reset an activity to draft' do + stub_all_activities! + sign_out @user + user = users(:staff) + sign_in user + repo = create :repository, :git_stubbed + repo.admins << user + exercise = create :exercise, repository: repo, draft: false + + put activity_url(exercise), params: { activity: { draft: true } } + + assert_not exercise.reload.draft + end + + test 'repository admin can update draft activity' do + stub_all_activities! + sign_out @user + user = users(:staff) + sign_in user + repo = create :repository, :git_stubbed + repo.admins << user + exercise = create :exercise, repository: repo, draft: true, name_en: 'old name' + + put activity_url(exercise), params: { activity: { draft: true, name_en: 'new name' } } + + assert exercise.reload.draft + assert_equal 'new name', exercise.name_en + end end class ExerciseErrorMailerTest < ActionDispatch::IntegrationTest From 7fc6a262ca854acd5eca444ab91b79777324eb19 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 26 Oct 2023 10:40:54 +0200 Subject: [PATCH 27/33] Fix tests --- test/fixtures/exercises.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures/exercises.yml b/test/fixtures/exercises.yml index 342d59cebe..6b8341dbdd 100644 --- a/test/fixtures/exercises.yml +++ b/test/fixtures/exercises.yml @@ -37,3 +37,4 @@ python_exercise: type: "Exercise" access_token: "12345" repository_token: "67890" + draft: false From 87a0c7d556a6ac6c8aa98e54b48394a37145eb4f Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 26 Oct 2023 11:04:33 +0200 Subject: [PATCH 28/33] Update icon layout in lists --- .../stylesheets/models/activities.css.scss | 4 ++++ .../activities/_activities_table.html.erb | 22 ++++++++++--------- .../_series_activities_add_table.html.erb | 4 +--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/models/activities.css.scss b/app/assets/stylesheets/models/activities.css.scss index ee02238432..2a5eff6b3a 100644 --- a/app/assets/stylesheets/models/activities.css.scss +++ b/app/assets/stylesheets/models/activities.css.scss @@ -8,6 +8,10 @@ color: var(--d-on-surface-muted); } + .activity-title .mdi::before { + vertical-align: bottom; + } + th.type-icon, td.type-icon { width: 18px; diff --git a/app/views/activities/_activities_table.html.erb b/app/views/activities/_activities_table.html.erb index d58291d577..88090b60ba 100644 --- a/app/views/activities/_activities_table.html.erb +++ b/app/views/activities/_activities_table.html.erb @@ -9,7 +9,9 @@ - + <% if user_signed_in? && (current_user.repository_admin?(activity.repository) || current_user.course_admin?(@course)) %> + + <% end %> @@ -24,21 +26,21 @@ <% local_assigns[:activities].each do |activity| %> - + <% if user_signed_in? && (current_user.repository_admin?(activity.repository) || current_user.course_admin?(@course)) %> + + <% end %>
<%= t "activities.index.activity_title" %> <%= t "activities.index.languages" %>
- <% if user_signed_in? %> - <% if current_user.repository_admin?(activity.repository) || current_user.course_admin?(@course) %> - <%= render partial: 'activities/repository_status', locals: {activity: activity, series: local_assigns[:series]} %> - <% end %> - <%= render partial: 'activities/user_status_icon', locals: {activity: activity, series: local_assigns[:series], user: user} %> - <% end %> - + <%= render partial: 'activities/repository_status', locals: {activity: activity, series: local_assigns[:series]} %> + <%= activity_icon(activity) %> - <%= raw "" if activity.access_private? %> - <%= raw "" if activity.removed? %> - <%= raw "" if activity.not_valid? %> + <%= render partial: 'activities/repository_status', locals: { activity: activity } %> <%= activity_icon(activity) %>