From f82737a7d4702968cfb41ab426c42888b52dc9f9 Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Mon, 19 Dec 2016 15:08:51 +0100
Subject: [PATCH 1/5] some small changes to staging environment (no caching and
eager loading, some more errors).
---
config/environments/staging.rb | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/config/environments/staging.rb b/config/environments/staging.rb
index dfe8cefb..ca1a98bb 100644
--- a/config/environments/staging.rb
+++ b/config/environments/staging.rb
@@ -1,14 +1,17 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
- # Code is not reloaded between requests.
- config.cache_classes = true
+ # true: Code is not reloaded between requests.
+ # false: In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
- config.eager_load = true
+ # true: Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = false
#enable web console in staging
config.web_console.development_only = false
@@ -17,6 +20,17 @@ Rails.application.configure do
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Adds additional error checking when serving assets at runtime.
+ # Checks for improperly declared sprockets dependencies.
+ # Raises helpful error messages.
+ config.assets.raise_runtime_errors = true
+
+ # Raise errors for missing translations.
+ config.action_view.raise_on_missing_translations = true
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
From a03d604861acee8827df55f0b19aaed43a27a02d Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Mon, 19 Dec 2016 18:29:33 +0100
Subject: [PATCH 2/5] fix points rounding in results view, clear results view
on new scoring attempt.
---
app/assets/javascripts/editor/editor.js.erb | 4 ++--
app/assets/javascripts/editor/evaluation.js.erb | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb
index 8b3db444..50e14514 100644
--- a/app/assets/javascripts/editor/editor.js.erb
+++ b/app/assets/javascripts/editor/editor.js.erb
@@ -351,7 +351,7 @@ configureEditors: function () {
},
isBrowserSupported: function () {
- // websockets is used for run, score and test
+ // websockets are used for run, score and test
return Modernizr.websockets;
},
@@ -361,7 +361,7 @@ configureEditors: function () {
panel.find('.panel-title .number').text(index + 1);
panel.find('.row .col-sm-9').eq(0).find('.number').eq(0).text(result.passed);
panel.find('.row .col-sm-9').eq(0).find('.number').eq(1).text(result.count);
- panel.find('.row .col-sm-9').eq(1).find('.number').eq(0).text((result.score * result.weight).toFixed(2));
+ panel.find('.row .col-sm-9').eq(1).find('.number').eq(0).text(parseFloat((result.score * result.weight).toFixed(2)));
panel.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
panel.find('.row .col-sm-9').eq(2).text(result.message);
if (result.error_messages) panel.find('.row .col-sm-9').eq(3).text(result.error_messages.join(', '));
diff --git a/app/assets/javascripts/editor/evaluation.js.erb b/app/assets/javascripts/editor/evaluation.js.erb
index f7b51f30..e4182413 100644
--- a/app/assets/javascripts/editor/evaluation.js.erb
+++ b/app/assets/javascripts/editor/evaluation.js.erb
@@ -6,6 +6,7 @@ CodeOceanEditorEvaluation = {
*/
scoreCode: function (event) {
event.preventDefault();
+ this.clearScoringOutput();
this.createSubmission('#assess', null, function (response) {
this.showSpinner($('#assess'));
$('#score_div').removeClass('hidden');
@@ -139,6 +140,14 @@ CodeOceanEditorEvaluation = {
$('#output pre').remove();
},
+ clearScoringOutput: function() {
+ $('#results ul').first().html('');
+ $('.test-count .number').html(0);
+ $('#score').data('score', 0);
+ this.renderScore();
+ this.clearOutput();
+ },
+
printOutput: function (output, colorize, index) {
var element = this.findOrCreateOutputElement(index);
if (!colorize) {
From 0a795b521f62fd0b2489ff859e25fe6ebf047a12 Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Mon, 19 Dec 2016 18:30:06 +0100
Subject: [PATCH 3/5] only show RFCs that have a question set
---
app/controllers/exercises_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 31e970f3..c6847a54 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -264,7 +264,7 @@ class ExercisesController < ApplicationController
return
# else: show open rfc for same exercise if available
- elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).order("RANDOM()").first
+ elsif rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise).where.not(question: nil).order("RANDOM()").first
# set a message that informs the user that his score was perfect and help in RFC is greatly appreciated.
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
flash.keep(:notice)
From 1108f954bac634aad7eb74005ebaf52b19b3250f Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Mon, 19 Dec 2016 18:30:39 +0100
Subject: [PATCH 4/5] show admin menu on RFC page for admins
---
app/views/request_for_comments/show.html.erb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index 5ad78b58..9c492070 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -6,7 +6,9 @@
submission = @request_for_comment.submission
%>
<%= user.displayname %> | <%= @request_for_comment.created_at.localtime %>
+
+
<%= t('activerecord.attributes.exercise.description') %>: <%= render_markdown(@request_for_comment.exercise.description) %>
@@ -25,6 +27,20 @@
<% else %>
<% end %>
+
+ <% if @current_user.admin? && user.is_a?(ExternalUser) %>
+
+
+ Admin Menu
+
+
+ - <%= raiselink_to "User's current status of this exercise", statistics_external_user_exercise_path(id: @request_for_comment.exercise_id, external_user_id: @request_for_comment.user_id) %>
+ - <%= link_to "All exercises of this user", statistics_external_user_path(id: @request_for_comment.user_id) %>
+ - <%= link_to "Implement the exercise yourself", implement_exercise_path(id: @request_for_comment.exercise_id) %>
+ - <%= link_to "Show the exercise", exercise_path(id: @request_for_comment.exercise_id) %>
+
+
+ <% end %>