From 7a1e5662d4395973c0a8a06c64a9f476e525e7bd Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Thu, 23 May 2024 14:54:52 +0200 Subject: [PATCH 1/2] First draft --- .../stylesheets/models/activities.css.scss | 2 +- app/controllers/activities_controller.rb | 6 + app/views/activities/_info.html.erb | 216 ++++++++++++++++++ app/views/activities/show.html.erb | 207 ++++++++--------- 4 files changed, 317 insertions(+), 114 deletions(-) create mode 100644 app/views/activities/_info.html.erb diff --git a/app/assets/stylesheets/models/activities.css.scss b/app/assets/stylesheets/models/activities.css.scss index 37d47c35e6..e0453265d8 100644 --- a/app/assets/stylesheets/models/activities.css.scss +++ b/app/assets/stylesheets/models/activities.css.scss @@ -129,7 +129,7 @@ center img { // editor #editor-text .cm-editor { - height: 300px; + height: 775px; } // white background for transparent images diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index c55b68f742..cf06460a01 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -106,6 +106,12 @@ def available end def show + @repository = @activity.repository + @config = @activity.ok? ? @activity.merged_config : {} + @config_locations = @activity.ok? ? @activity.merged_config_locations : {} + @courses_series = policy_scope(@activity.series).group_by(&:course).sort do |a, b| + [b.first.year, a.first.name] <=> [a.first.year, b.first.name] + end flash.now[:alert] = I18n.t('activities.show.not_a_member') if @course && !current_user&.member_of?(@course) # Double check if activity still exists within this course (And throw a 404 when it does not) diff --git a/app/views/activities/_info.html.erb b/app/views/activities/_info.html.erb new file mode 100644 index 0000000000..4d7be61d0d --- /dev/null +++ b/app/views/activities/_info.html.erb @@ -0,0 +1,216 @@ +<% content_for :javascripts do %> + <%= javascript_include_tag 'submission' %> +<% end %> +<% + solutions = if @activity.exercise? + @activity.solutions.sort(&method(:compare_solutions)) + end +%> +
+ <% if @activity.labels.any? %> +
+
+

+ <% @activity.labels.each do |label| %> + <%= link_to label_path(label) do %> + <%= label.name %> + <% end %> + <% end %> +

+
+ <% end %> +
+
+
+
+
+ <% if (contact_info = @config['contact'] || @repository.first_admin&.pretty_email) %> +
+

+ + <%= mail_to(contact_info) %> +

+ <% end %> + <% if @activity.exercise? %> +
+

+ + <% if policy(@activity.judge).show? %> + <%= link_to @activity.judge.name, judge_path(@activity.judge) %> + <% else %> + <%= @activity.judge.name %> + <% end %> +

+ <% end %> +
+

+ + <% if policy(@repository).show? %> + <%= link_to @repository.name, repository_path(@repository) %> + <% else %> + <%= @repository.name %> + <% end %> +

+
+ <% if current_user&.repository_admin?(@repository) %> +

+ + <%= github_link @repository, @activity.path %> + <% end %> +

+
+
+
+
+
+
+ <% if @activity.exercise? %> +
+

<%= @activity.programming_language ? @activity.programming_language.name.titlecase : "n/a" %>

+ <%= t '.programming_language' %> +
+ <% end %> +
+

<%= @activity.description_languages.join(', ') %>

+ <%= t '.natural_language' %> +
+ <% if @activity.exercise? %> +
+

<%= @config.dig('evaluation', 'time_limit') || SubmissionRunner.default_config['time_limit'] %>s

+ <%= t '.time_limit' %> +
+
+

+ <%= human_bytes (@config.dig('evaluation', 'memory_limit') || SubmissionRunner.default_config['memory_limit']).to_i %> +

+ <%= t '.memory_limit' %> +
+
+ <% + if @config.dig('evaluation', 'network_enabled') + network_icon = 'mdi-wan' + network_config_name = t('.network_enabled') + else + network_icon = 'mdi-lan-disconnect' + network_config_name = t('.network_disabled') + end + %> +

+ +

+ <%= network_config_name %> +
+
+

<%= number_with_delimiter @activity.submissions.count, delimiter: " " %>

+ <%= t '.submission_count' %> +
+ <% end %> +
+
+
+ <%= raw t('.config_info', doc_site: link_to(t('.doc_site'), 'https://docs.dodona.be/references/exercise-config/')) %> +
+
+ +
+ + +
+
+ <% if @activity.about.present? %> + <%= markdown @activity.about %> + <% else %> + <%= t '.no_readme_present' %> + <% if current_user&.repository_admin?(@repository) && @repository.github_url.present? %> + <%= github_link @repository, + "?filename=#{@activity.path}/readme.#{I18n.locale.to_s}.md", + name: t('.click_here_to_create_one'), + mode: 'new' %> + <% end %> + <% end %> +
+
+
+ +<% if @activity.exercise? %> +
+ +
+

<%= t ".sample_solutions" %>

+ <% if solutions.any? %> +
+ +
+
+ <%= t '.sample_solutions_hint' %> +
+ <% solutions.each_with_index do |(fname, code), i| %> + + <% end %> +
+
+ <% else %> + <%= t '.no_solutions' %> + <% end %> +
+<% end %> + +
+ +
+

<%= t ".usage" %>

+

<%= t('.courses_using_this_activity', count: @courses_series.count) %>

+ <% if @courses_series.any? %> +
+ + + + + + + + + + + + + + <% @courses_series.each do |course, series| %> + + + + + + + + + + <% end %> + +
<%= Course.human_attribute_name("name") %><%= Course.human_attribute_name("series") %><%= Course.human_attribute_name("teacher") %><%= Course.human_attribute_name("year") %><%= Course.human_attribute_name("institution") %><%= t 'courses.index.users' %>
+ <%= link_to course.name, course %> + + <%= raw series.map{ |s| link_to(s.name, s, class: "course-link", title: s.name).html_safe }.to_sentence %> + <%= course.teacher %><%= course.formatted_year %><%= course.institution&.short_name || t('courses.form.no_institution') %><%= course.subscribed_members_count %> + <% if policy(course).edit? %> + <%= link_to edit_course_path(course), class: "btn btn-icon" do %> + + <% end %> + <% end %> +
+
+
+ <% end %> diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 4d05e73359..e90e15a399 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -8,7 +8,8 @@ <% end %> <% end %> -<%= render 'navbar_links' %> +<% content_for :container_class do %>container-fluid<% end %> + <% if @not_registered && @lti_launch %> <%= render 'courses/not_a_member_dialog' %> @@ -38,106 +39,77 @@ end %> <% end %>
- <% if @activity.exercise? %> -
- <%= link_to '#submission-card', class: "btn btn-lg btn-down d-none d-md-block hidden-print", title: t('.handin') do %> - <%= t('.handin') %>
- - <% end %> -
- <% else %> -
 
+ <% if @series.present? %> + <% end %> -
-
-
-

+
+

<%= activity_icon(@activity, 24) %>   <%= @activity.numbered_name(@series) %>

- <% if @series.present? %> -
- <%= link_to previous_link, class: 'btn btn-icon btn-icon-inverted', title: previous_tooltip, data: {'bs-toggle': 'tooltip', placement: 'top'} do %> - - <% end %> - <%= link_to next_link, class: 'btn btn-icon btn-icon-inverted', title: next_tooltip, data: {'bs-toggle': 'tooltip', placement: 'top', title: next_tooltip_actionable}, id: 'next-exercise-link' do %> - - <% end %> -
- <% end %> -
<%= description_iframe @activity %> -

- - <% if @series.present? %> - - <% end %> - -
-<% if @activity.exercise? %> -
- -
-
-
- <% if policy(@activity).submit? %> -
- - -
- <% end %> - -
-
-
-
- <% if !user_signed_in? %> -
<%= t ".not_logged_in_html", :url => sign_in_path %>
- <% end %> - <% if policy(@activity).submit? || !user_signed_in? %> - <% if @series.present? && @series.deadline.present? %> - - +
+
+
+
+ <% if !user_signed_in? %> +
<%= t ".not_logged_in_html", :url => sign_in_path %>
<% end %> - <% if !@edit_submission && !@solution && @last_submission %> -
- <%= t ".preloaded_info" %> - - <%= t(@activity.boilerplate ? ".preloaded_restore" : ".preloaded_clear") %> - + <% if policy(@activity).submit? || !user_signed_in? %> + <% if @series.present? && @series.deadline.present? %> + + + <% end %> + <% if !@edit_submission && !@solution && @last_submission %> + + <% end %> +
+
<%= @code %>
- <% end %> -
-
<%= @code %>
-
-
- <%= t ".hand_in_info" %> - <% if @activity.exercise? && @activity.programming_language&.name == 'python' %> +
<%= t ".hand_in_info" %>
+
+ <% if @activity.exercise? && @activity.programming_language&.name == 'python' %> <%= t '.to_sandbox' %> - + + + <% end %> +
+ <% end %> +
+
+ <%= render partial: 'layouts/searchbar', locals: {statuses: Submission.statuses.keys, refresh_element: "#refresh_element"} %> +
+ <% if !user_signed_in? %> +
<%= t ".not_logged_in_html", :url => sign_in_path %>
+ <% elsif @submissions.length > 0 %> + <%= render partial: 'submissions/submissions_table', locals: {submissions: @submissions, exercise: @activity, course: @course, user: current_user} %> + <% else %> +
<%= t ".hand_in_tooltip" %>
<% end %>
- <% end %> -
-
-
- <% if !user_signed_in? %> -
<%= t ".not_logged_in_html", :url => sign_in_path %>
- <% elsif @submissions.length > 0 %> - <%= render partial: 'submissions/submissions_table', locals: {submissions: @submissions, exercise: @activity, course: @course, user: current_user} %> - <% else %> -
<%= t ".hand_in_tooltip" %>
- <% end %>
-
-
-
-
+<% if @activity.exercise? %> + <% elsif @activity.content_page? %>
From c17ecb8503f0a227f50d33e84b882e6a2c1e2acd Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 28 May 2024 10:14:33 +0200 Subject: [PATCH 2/2] minor changes --- app/views/activities/_info.html.erb | 79 +++++++++++++++-------------- app/views/activities/show.html.erb | 1 - 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/app/views/activities/_info.html.erb b/app/views/activities/_info.html.erb index 4d7be61d0d..a0f3aff7c3 100644 --- a/app/views/activities/_info.html.erb +++ b/app/views/activities/_info.html.erb @@ -7,18 +7,23 @@ end %>
+
+
+
+

+ <%= activity_icon(@activity, 24) %> + <%= @activity.numbered_name(@series) %> +

<% if @activity.labels.any? %> -
-
-

- <% @activity.labels.each do |label| %> - <%= link_to label_path(label) do %> - <%= label.name %> - <% end %> - <% end %> -

+
+ <% @activity.labels.each do |label| %> + <%= link_to label_path(label) do %> + <%= label.name %> + <% end %> + <% end %>
<% end %> +
@@ -66,23 +71,23 @@
<% if @activity.exercise? %>
-

<%= @activity.programming_language ? @activity.programming_language.name.titlecase : "n/a" %>

+

<%= @activity.programming_language ? @activity.programming_language.name.titlecase : "n/a" %>

<%= t '.programming_language' %>
<% end %>
-

<%= @activity.description_languages.join(', ') %>

+

<%= @activity.description_languages.join(', ') %>

<%= t '.natural_language' %>
<% if @activity.exercise? %>
-

<%= @config.dig('evaluation', 'time_limit') || SubmissionRunner.default_config['time_limit'] %>s

+

<%= @config.dig('evaluation', 'time_limit') || SubmissionRunner.default_config['time_limit'] %>s

<%= t '.time_limit' %>
-

+

<%= human_bytes (@config.dig('evaluation', 'memory_limit') || SubmissionRunner.default_config['memory_limit']).to_i %> -

+ <%= t '.memory_limit' %>
@@ -95,13 +100,13 @@ network_config_name = t('.network_disabled') end %> -

+

-

+ <%= network_config_name %>
-

<%= number_with_delimiter @activity.submissions.count, delimiter: " " %>

+

<%= number_with_delimiter @activity.submissions.count, delimiter: " " %>

<%= t '.submission_count' %>
<% end %> @@ -111,30 +116,28 @@ <%= raw t('.config_info', doc_site: link_to(t('.doc_site'), 'https://docs.dodona.be/references/exercise-config/')) %>
+
-
- - -
-
- <% if @activity.about.present? %> - <%= markdown @activity.about %> - <% else %> - <%= t '.no_readme_present' %> - <% if current_user&.repository_admin?(@repository) && @repository.github_url.present? %> - <%= github_link @repository, - "?filename=#{@activity.path}/readme.#{I18n.locale.to_s}.md", - name: t('.click_here_to_create_one'), - mode: 'new' %> - <% end %> - <% end %> -
-
-
- +
+
+
+

README

+
+ <% if @activity.about.present? %> + <%= markdown @activity.about %> + <% else %> + <%= t '.no_readme_present' %> + <% if current_user&.repository_admin?(@repository) && @repository.github_url.present? %> + <%= github_link @repository, + "?filename=#{@activity.path}/readme.#{I18n.locale.to_s}.md", + name: t('.click_here_to_create_one'), + mode: 'new' %> + <% end %> + <% end %> +
+
<% if @activity.exercise? %>
-

<%= t ".sample_solutions" %>

<% if solutions.any? %> diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index e90e15a399..2d3db102c3 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -58,7 +58,6 @@ end %>

<%= activity_icon(@activity, 24) %> -   <%= @activity.numbered_name(@series) %>

<%= description_iframe @activity %>