From 3790811c22d4a7521256afbb8448d34bfbab86e0 Mon Sep 17 00:00:00 2001
From: Nishanth Prakash
Date: Fri, 1 Apr 2016 17:20:04 +0200
Subject: [PATCH 01/52] edit provision script to pull the new images required
---
provision.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/provision.sh b/provision.sh
index f5c15881..33b0e72a 100644
--- a/provision.sh
+++ b/provision.sh
@@ -39,7 +39,8 @@ sudo service docker restart
docker pull openhpi/docker_java
docker pull openhpi/docker_ruby
docker pull openhpi/docker_python
-
+docker pull openhpi/co_execenv_python
+docker pull openhpi/co_execenv_java
# rvm
apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
@@ -96,8 +97,9 @@ export RAILS_ENV=development
rake db:schema:load
rake db:migrate
rake db:seed
+sudo mkdir /shared
chown -R vagrant /shared
-ln -sf /shared tmp/files
+ln -sf /shared tmp/files #make sure you are running vagrant with admin privileges
# NGINX
if [ ! -L /etc/nginx/sites-enabled/code_ocean ]
From c11b567cbbcfebe1806528230f04e55e1472cd07 Mon Sep 17 00:00:00 2001
From: Nishanth Prakash
Date: Sun, 3 Apr 2016 12:55:24 +0200
Subject: [PATCH 02/52] minor fix - sppecify option to create dir only if not
present
---
provision.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/provision.sh b/provision.sh
index 33b0e72a..974924d2 100644
--- a/provision.sh
+++ b/provision.sh
@@ -97,7 +97,7 @@ export RAILS_ENV=development
rake db:schema:load
rake db:migrate
rake db:seed
-sudo mkdir /shared
+sudo mkdir -p /shared
chown -R vagrant /shared
ln -sf /shared tmp/files #make sure you are running vagrant with admin privileges
From e73b5389fdbf924cc00b271f81b37f3e3f3f85c0 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 12 Apr 2016 14:39:00 +0200
Subject: [PATCH 03/52] Fix unittest adapters
---
lib/junit_adapter.rb | 2 +-
lib/py_unit_adapter.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/junit_adapter.rb b/lib/junit_adapter.rb
index 87b70d84..c5b57184 100644
--- a/lib/junit_adapter.rb
+++ b/lib/junit_adapter.rb
@@ -2,7 +2,7 @@ class JunitAdapter < TestingFrameworkAdapter
COUNT_REGEXP = /Tests run: (\d+)/
FAILURES_REGEXP = /Failures: (\d+)/
SUCCESS_REGEXP = /OK \((\d+) test[s]?\)/
- ASSERTION_ERROR_REGEXP = /java\.lang\.AssertionError:\s(.*)/
+ ASSERTION_ERROR_REGEXP = /java\.lang\.AssertionError:\s(.*)|org\.junit\.ComparisonFailure:\s(.*)/
def self.framework_name
'JUnit'
diff --git a/lib/py_unit_adapter.rb b/lib/py_unit_adapter.rb
index 68cdd200..f7f98dae 100644
--- a/lib/py_unit_adapter.rb
+++ b/lib/py_unit_adapter.rb
@@ -11,7 +11,7 @@ class PyUnitAdapter < TestingFrameworkAdapter
count = COUNT_REGEXP.match(output[:stderr]).captures.first.to_i
matches = FAILURES_REGEXP.match(output[:stderr])
failed = matches ? matches.captures.try(:first).to_i : 0
- error_matches = ASSERTION_ERROR_REGEXP.match(output[:stderr]).captures
+ error_matches = ASSERTION_ERROR_REGEXP.match(output[:stderr]).try(:captures) || []
{count: count, failed: failed, error_messages: error_matches}
end
end
From 8df22b44ac4b5e2638c1e322c8415ad1b19e8c03 Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Fri, 15 Apr 2016 16:40:47 +0200
Subject: [PATCH 04/52] changes to learning analytics message format.
---
app/assets/javascripts/editor.js.erb | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index 968951a8..e3b72222 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -796,9 +796,12 @@ $(function() {
var payload = {
user: {
- resource_uuid: $('#editor').data('user-id')
+ type: 'User',
+ uuid: $('#editor').data('user-id')
+ },
+ verb: {
+ type: eventName
},
- verb: eventName,
resource: {},
timestamp: new Date().toISOString(),
with_result: {},
From ea2ce702a4141e657e69d80a196544d9e7f85135 Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Fri, 15 Apr 2016 16:50:16 +0200
Subject: [PATCH 05/52] some more changes to the LA format.
---
app/assets/javascripts/editor.js.erb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index e3b72222..7b22e8a8 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -802,7 +802,10 @@ $(function() {
verb: {
type: eventName
},
- resource: {},
+ resource: {
+ type: 'page',
+ uid: document.location.href
+ },
timestamp: new Date().toISOString(),
with_result: {},
in_context: contextData
From 171678d489a3dce77c0079c732762065d1ea7ac0 Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Fri, 15 Apr 2016 16:56:45 +0200
Subject: [PATCH 06/52] fixed small typo.
---
app/assets/javascripts/editor.js.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index 7b22e8a8..bcb3faea 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -804,7 +804,7 @@ $(function() {
},
resource: {
type: 'page',
- uid: document.location.href
+ uuid: document.location.href
},
timestamp: new Date().toISOString(),
with_result: {},
From 346a3dd6f5771281e28f108eed437d7b862dc71e Mon Sep 17 00:00:00 2001
From: Nishanth Prakash
Date: Wed, 20 Apr 2016 12:43:07 +0200
Subject: [PATCH 07/52] include pull to the openhpi/co_execenv_java_antlr
docker image in provision.sh
---
provision.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/provision.sh b/provision.sh
index 974924d2..2fbb3b69 100644
--- a/provision.sh
+++ b/provision.sh
@@ -41,6 +41,7 @@ docker pull openhpi/docker_ruby
docker pull openhpi/docker_python
docker pull openhpi/co_execenv_python
docker pull openhpi/co_execenv_java
+docker pull openhpi/co_execenv_java_antlr
# rvm
apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
From 07fa0ef2a9077e1bfb5a778bd6b841ff3da8c7dc Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 13:58:49 +0200
Subject: [PATCH 08/52] Add question to RequestForComment model
---
.../20160426114951_add_question_to_request_for_comments.rb | 5 +++++
db/schema.rb | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 db/migrate/20160426114951_add_question_to_request_for_comments.rb
diff --git a/db/migrate/20160426114951_add_question_to_request_for_comments.rb b/db/migrate/20160426114951_add_question_to_request_for_comments.rb
new file mode 100644
index 00000000..3c9fac17
--- /dev/null
+++ b/db/migrate/20160426114951_add_question_to_request_for_comments.rb
@@ -0,0 +1,5 @@
+class AddQuestionToRequestForComments < ActiveRecord::Migration
+ def change
+ add_column :request_for_comments, :question, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4ba78542..eadfd44e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160302133540) do
+ActiveRecord::Schema.define(version: 20160426114951) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -190,6 +190,7 @@ ActiveRecord::Schema.define(version: 20160302133540) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "user_type"
+ t.text "question"
end
create_table "submissions", force: true do |t|
From 1902760c6114cad7a62c363ffa5d0aa06b130488 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 14:15:40 +0200
Subject: [PATCH 09/52] Add link to own requests in navbar
---
app/views/application/_session.html.slim | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim
index 52858f8d..1b1b2e5e 100644
--- a/app/views/application/_session.html.slim
+++ b/app/views/application/_session.html.slim
@@ -8,6 +8,7 @@
ul.dropdown-menu role='menu'
li = link_to(t('consumers.show.link'), current_user.consumer) if current_user.consumer
li = link_to(t('internal_users.show.link'), current_user)
+ li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
- else
li
From ba040becebd2e26115758ab3886aeedc9ee9949c Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 14:21:25 +0200
Subject: [PATCH 10/52] Add link to all requests
---
app/views/application/_session.html.slim | 1 +
config/locales/de.yml | 1 +
config/locales/en.yml | 1 +
3 files changed, 3 insertions(+)
diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim
index 1b1b2e5e..7468d24f 100644
--- a/app/views/application/_session.html.slim
+++ b/app/views/application/_session.html.slim
@@ -8,6 +8,7 @@
ul.dropdown-menu role='menu'
li = link_to(t('consumers.show.link'), current_user.consumer) if current_user.consumer
li = link_to(t('internal_users.show.link'), current_user)
+ li = link_to(t('request_for_comments.index.all'), request_for_comments_path)
li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
- else
diff --git a/config/locales/de.yml b/config/locales/de.yml
index f35a5442..7d5710e5 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -322,6 +322,7 @@ de:
request_for_comments:
index:
get_my_comment_requests: Meine Kommentaranfragen
+ all: "Alle Kommentaranfragen"
sessions:
create:
failure: Fehlerhafte E-Mail oder Passwort.
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 399e6c66..f9306835 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -321,6 +321,7 @@ en:
subject: Password reset instructions
request_for_comments:
index:
+ all: All Requests for Comments
get_my_comment_requests: My Requests for Comments
sessions:
create:
From 96c7e5958f54a1cfadafc7e2185826d1196f4138 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 14:22:57 +0200
Subject: [PATCH 11/52] Make requests sortable
---
app/views/request_for_comments/index.html.slim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/request_for_comments/index.html.slim b/app/views/request_for_comments/index.html.slim
index 89d8c239..14007fe2 100644
--- a/app/views/request_for_comments/index.html.slim
+++ b/app/views/request_for_comments/index.html.slim
@@ -1,7 +1,7 @@
h1 = RequestForComment.model_name.human(count: 2)
.table-responsive
- table.table
+ table.table.sortable
thead
tr
th = t('activerecord.attributes.request_for_comments.exercise')
From d4061bf9b5417226669f06015a2d050577c37618 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 14:29:29 +0200
Subject: [PATCH 12/52] Remove RequestForComment button from sidebar
---
app/views/exercises/_editor_file_tree.html.slim | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/views/exercises/_editor_file_tree.html.slim b/app/views/exercises/_editor_file_tree.html.slim
index 9ed5626d..cad3c845 100644
--- a/app/views/exercises/_editor_file_tree.html.slim
+++ b/app/views/exercises/_editor_file_tree.html.slim
@@ -5,6 +5,5 @@ hr
= render('editor_button', classes: 'btn-block btn-primary btn-sm', data: {:'data-cause' => 'file'}, icon: 'fa fa-plus', id: 'create-file', label: t('exercises.editor.create_file'))
= render('editor_button', classes: 'btn-block btn-warning btn-sm', data: {:'data-cause' => 'file', :'data-message-confirm' => t('shared.confirm_destroy')}, icon: 'fa fa-times', id: 'destroy-file', label: t('exercises.editor.destroy_file'))
= render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-download', id: 'download', label: t('exercises.editor.download'))
-= render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-bullhorn', id: 'request-for-comments', label: t('exercises.editor.requestComments'))
= render('shared/modal', id: 'modal-file', template: 'code_ocean/files/_form', title: t('exercises.editor.create_file'))
From af103ef2709b12779984c498278d73444518914d Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 16:05:57 +0200
Subject: [PATCH 13/52] Remove comment modal from standard editor
---
app/assets/javascripts/editor.js.erb | 100 --------------------------
app/views/exercises/_editor.html.slim | 2 -
2 files changed, 102 deletions(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index bcb3faea..3ef7e16a 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -434,13 +434,6 @@ $(function() {
// editor itself
editor.on("paste", handlePasteEvent);
editor.on("copy", handleCopyEvent);
- editor.on("guttermousedown", handleSidebarClick);
-
- /* // alternative:
- editor.on("guttermousedown", function(e) {
- handleSidebarClick(e);
- });
- */
//session
session.on('annotationRemoval', handleAnnotationRemoval);
@@ -453,18 +446,6 @@ $(function() {
});
};
- var hasCommentsInRow = function (editor, row){
- return editor.getSession().getAnnotations().some(function(element) {
- return element.row === row;
- })
- };
-
- var getCommentsForRow = function (editor, row){
- return editor.getSession().getAnnotations().filter(function(element) {
- return element.row === row;
- })
- };
-
var setAnnotations = function (editor, file_id){
var session = editor.getSession();
var url = "/comments";
@@ -494,40 +475,6 @@ $(function() {
});
session.setAnnotations(annotations);
- }
-
- var deleteComment = function (file_id, row, editor) {
- var jqxhr = $.ajax({
- type: 'DELETE',
- url: "/comments",
- data: {
- row: row,
- file_id: file_id }
- });
- jqxhr.done(function (response) {
- setAnnotations(editor, file_id);
- });
- jqxhr.fail(ajaxError);
- }
-
- var createComment = function (file_id, row, editor, commenttext){
- var jqxhr = $.ajax({
- data: {
- comment: {
- file_id: file_id,
- row: row,
- column: 0,
- text: commenttext
- }
- },
- dataType: 'json',
- method: 'POST',
- url: "/comments"
- });
- jqxhr.done(function(response){
- setAnnotations(editor, file_id);
- });
- jqxhr.fail(ajaxError);
};
var handleAnnotationRemoval = function(removedAnnotations) {
@@ -559,52 +506,6 @@ $(function() {
})
};
- // Code for clicks on gutter / sidepanel
- var handleSidebarClick = function(e) {
- var target = e.domEvent.target;
- var editor = e.editor;
-
- if (target.className.indexOf("ace_gutter-cell") == -1) return;
- if (!editor.isFocused()) return;
- if (e.clientX > 25 + target.getBoundingClientRect().left) return;
-
- var row = e.getDocumentPosition().row;
- e.stop();
-
- var commentModal = $('#comment-modal');
-
- if (hasCommentsInRow(editor, row)) {
- var rowComments = getCommentsForRow(editor, row);
- var comments = _.pluck(rowComments, 'text').join('\n');
- commentModal.find('#other-comments').text(comments);
- } else {
- commentModal.find('#other-comments').text('none');
- }
-
- commentModal.find('#addCommentButton').off('click');
- commentModal.find('#removeAllButton').off('click');
-
- commentModal.find('#addCommentButton').on('click', function(e){
- var commenttext = commentModal.find('textarea').val();
- // attention: use id of data attribute here, not file-id (file-id is the original file)
- var file_id = $(editor.container).data('id');
-
- if (commenttext !== "") {
- createComment(file_id, row, editor, commenttext);
- commentModal.modal('hide');
- }
- });
-
- commentModal.find('#removeAllButton').on('click', function(e){
- // attention: use id of data attribute here, not file-id (file-id is the original file)
- var file_id = $(editor.container).data('id');
- deleteComment(file_id,row, editor);
- commentModal.modal('hide');
- });
-
- commentModal.modal('show');
- };
-
var initializeEventHandlers = function() {
$(document).on('click', '#results a', showOutput);
$(document).on('keypress', handleKeyPress);
@@ -1125,7 +1026,6 @@ $(function() {
$('#run').toggle(isActiveFileRunnable() && !running);
$('#stop').toggle(isActiveFileStoppable());
$('#test').toggle(isActiveFileTestable());
- $('#request-for-comments').toggle(isActiveFileSubmission() && !isActiveFileBinary());
};
var initWebsocketConnection = function(url) {
diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim
index cc5dfe7e..210e976f 100644
--- a/app/views/exercises/_editor.html.slim
+++ b/app/views/exercises/_editor.html.slim
@@ -37,5 +37,3 @@
i.fa.fa-rocket
= t('exercises.editor.test')
= render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-trophy', id: 'assess', label: t('exercises.editor.score'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + s'))
-
-= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent')
\ No newline at end of file
From 4b5cd5a22af30a4f0deba2c7837c0bcf5400117b Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 16:06:32 +0200
Subject: [PATCH 14/52] Use better modal
---
app/views/request_for_comments/show.html.erb | 140 ++++++++++++-------
1 file changed, 93 insertions(+), 47 deletions(-)
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index a47eba32..e0a76d31 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -25,27 +25,22 @@ do not put a carriage return in the line below. it will be present in the presen
<% end %>
+<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %>
+
-
From 57b773698b525237cbfd23abb3368dbbcce68cc7 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Tue, 26 Apr 2016 17:42:53 +0200
Subject: [PATCH 15/52] Fix comment policy
---
app/controllers/comments_controller.rb | 2 +-
app/policies/comment_policy.rb | 8 +++++++-
app/views/request_for_comments/show.html.erb | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 15bf99fb..7e008d07 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -112,13 +112,13 @@ class CommentsController < ApplicationController
def destroy
@comments = Comment.where(file_id: params[:file_id], row: params[:row])
+ authorize!
@comments.delete_all
respond_to do |format|
#format.html { redirect_to comments_url, notice: 'Comments were successfully destroyed.' }
format.html { head :no_content, notice: 'Comments were successfully destroyed.' }
format.json { head :no_content }
end
- authorize!
end
private
diff --git a/app/policies/comment_policy.rb b/app/policies/comment_policy.rb
index 091ed5e2..84e7a0ed 100644
--- a/app/policies/comment_policy.rb
+++ b/app/policies/comment_policy.rb
@@ -1,6 +1,12 @@
class CommentPolicy < ApplicationPolicy
def author?
- @user == @record.author
+ if @record.is_a?(ActiveRecord::Relation)
+ flag = true
+ @record.all {|item| flag = (flag and item.author == @user)}
+ flag
+ else
+ @user == @record.author
+ end
end
private :author?
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index e0a76d31..0688820d 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -143,7 +143,7 @@ do not put a carriage return in the line below. it will be present in the presen
commentModal.find('#removeAllButton').on('click', function(e){
var file_id = $(editor.container).data('file-id');
- deleteComment(file_id,row, editor);
+ deleteComment(file_id, row, editor);
commentModal.modal('hide');
});
From 8ef615ffaa1ce63fe9785eaa8971e3d1104916f0 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Wed, 27 Apr 2016 17:16:23 +0200
Subject: [PATCH 16/52] Correctly authorize comment deletion
---
app/controllers/comments_controller.rb | 5 ++---
app/policies/comment_policy.rb | 8 +-------
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 7e008d07..82e892b8 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -111,9 +111,8 @@ class CommentsController < ApplicationController
end
def destroy
- @comments = Comment.where(file_id: params[:file_id], row: params[:row])
- authorize!
- @comments.delete_all
+ @comments = Comment.where(file_id: params[:file_id], row: params[:row], user: current_user)
+ @comments.each { |comment| authorize comment; comment.destroy }
respond_to do |format|
#format.html { redirect_to comments_url, notice: 'Comments were successfully destroyed.' }
format.html { head :no_content, notice: 'Comments were successfully destroyed.' }
diff --git a/app/policies/comment_policy.rb b/app/policies/comment_policy.rb
index 84e7a0ed..091ed5e2 100644
--- a/app/policies/comment_policy.rb
+++ b/app/policies/comment_policy.rb
@@ -1,12 +1,6 @@
class CommentPolicy < ApplicationPolicy
def author?
- if @record.is_a?(ActiveRecord::Relation)
- flag = true
- @record.all {|item| flag = (flag and item.author == @user)}
- flag
- else
- @user == @record.author
- end
+ @user == @record.author
end
private :author?
From 2753608167a133e3c167481fed47188b39bb4814 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Wed, 27 Apr 2016 18:02:11 +0200
Subject: [PATCH 17/52] Restructure session menu
---
app/views/application/_session.html.slim | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/app/views/application/_session.html.slim b/app/views/application/_session.html.slim
index 7468d24f..cbbf3b12 100644
--- a/app/views/application/_session.html.slim
+++ b/app/views/application/_session.html.slim
@@ -1,21 +1,17 @@
- if current_user
- - if current_user.internal_user?
- li.dropdown
- a.dropdown-toggle data-toggle='dropdown' href='#'
- i.fa.fa-user
- = current_user
- span.caret
- ul.dropdown-menu role='menu'
+ li.dropdown
+ a.dropdown-toggle data-toggle='dropdown' href='#'
+ i.fa.fa-user
+ = current_user
+ span.caret
+ ul.dropdown-menu role='menu'
+ - if current_user.internal_user?
li = link_to(t('consumers.show.link'), current_user.consumer) if current_user.consumer
li = link_to(t('internal_users.show.link'), current_user)
- li = link_to(t('request_for_comments.index.all'), request_for_comments_path)
- li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
+ li = link_to(t('request_for_comments.index.all'), request_for_comments_path)
+ li = link_to(t('request_for_comments.index.get_my_comment_requests'), my_request_for_comments_path)
+ - if current_user.internal_user?
li = link_to(t('sessions.destroy.link'), sign_out_path, method: :delete)
- - else
- li
- p.navbar-text
- i.fa.fa-user
- = current_user
- else
li = link_to(sign_in_path) do
i.fa.fa-sign-in
From 2998d63d13c4a0dbab87ee6dd5d2c9717128a0a5 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Wed, 27 Apr 2016 18:02:37 +0200
Subject: [PATCH 18/52] Add human readable label
---
app/models/request_for_comment.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb
index e685805f..af3676c0 100644
--- a/app/models/request_for_comment.rb
+++ b/app/models/request_for_comment.rb
@@ -25,6 +25,10 @@ class RequestForComment < ActiveRecord::Base
limit 1").first
end
+ def to_s
+ "RFC-" + self.id.to_s
+ end
+
private
def self.row_number_user_sql
select("id, user_id, exercise_id, file_id, requested_at, created_at, updated_at, user_type, row_number() OVER (PARTITION BY user_id ORDER BY created_at DESC) as row_number").to_sql
From d56290f2d85ad546a20da8f6e8b02dadea95055a Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Wed, 27 Apr 2016 18:02:50 +0200
Subject: [PATCH 19/52] Remove constraints for click event
---
app/views/request_for_comments/show.html.erb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index 0688820d..aa4fcec0 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -112,8 +112,9 @@ do not put a carriage return in the line below. it will be present in the presen
var editor = e.editor;
if (target.className.indexOf("ace_gutter-cell") == -1) return;
- if (!editor.isFocused()) return;
- if (e.clientX > 25 + target.getBoundingClientRect().left) return;
+ //if (!editor.isFocused()) return;
+ //if (e.clientX > 25 + target.getBoundingClientRect().left) return;
+
var row = e.getDocumentPosition().row;
e.stop();
From 8ba67c68c03784460c88102c34bf94edb07242be Mon Sep 17 00:00:00 2001
From: Ralf Teusner
Date: Wed, 27 Apr 2016 18:33:27 +0200
Subject: [PATCH 20/52] retrieve correct displaynames for users (from consumer
if it is openHPI, otherwise use internal name)
---
app/models/external_user.rb | 9 +++++++++
app/models/internal_user.rb | 5 +++++
app/views/request_for_comments/index.html.slim | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/app/models/external_user.rb b/app/models/external_user.rb
index c1d9ad28..8038d2dc 100644
--- a/app/models/external_user.rb
+++ b/app/models/external_user.rb
@@ -3,4 +3,13 @@ class ExternalUser < ActiveRecord::Base
validates :consumer_id, presence: true
validates :external_id, presence: true
+
+ def displayname
+ result = name
+ if(consumer.name == 'openHPI')
+ result = Xikolo::UserClient.get(external_id.to_s)[:display_name]
+ end
+ result
+ end
+
end
diff --git a/app/models/internal_user.rb b/app/models/internal_user.rb
index 54b8df4d..e5cebde9 100644
--- a/app/models/internal_user.rb
+++ b/app/models/internal_user.rb
@@ -21,4 +21,9 @@ class InternalUser < ActiveRecord::Base
def teacher?
role == 'teacher'
end
+
+ def displayname
+ name
+ end
+
end
diff --git a/app/views/request_for_comments/index.html.slim b/app/views/request_for_comments/index.html.slim
index 14007fe2..80c17bf3 100644
--- a/app/views/request_for_comments/index.html.slim
+++ b/app/views/request_for_comments/index.html.slim
@@ -13,7 +13,7 @@ h1 = RequestForComment.model_name.human(count: 2)
tr data-id=request_for_comment.id
td = link_to(request_for_comment.exercise.title, request_for_comment)
td = request_for_comment.exercise.execution_environment
- td = request_for_comment.user.name
+ td = request_for_comment.user.displayname
td = request_for_comment.requested_at
= render('shared/pagination', collection: @request_for_comments)
\ No newline at end of file
From 027c6013ebf3422dccbba7bfcf691e2803a8a98b Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 12:55:58 +0200
Subject: [PATCH 21/52] Implement request modal
---
app/views/exercises/_editor.html.slim | 2 ++
app/views/exercises/_request_comment_dialogcontent.html.slim | 4 ++++
config/locales/de.yml | 2 ++
config/locales/en.yml | 2 ++
4 files changed, 10 insertions(+)
create mode 100644 app/views/exercises/_request_comment_dialogcontent.html.slim
diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim
index 210e976f..42b12e42 100644
--- a/app/views/exercises/_editor.html.slim
+++ b/app/views/exercises/_editor.html.slim
@@ -37,3 +37,5 @@
i.fa.fa-rocket
= t('exercises.editor.test')
= render('editor_button', data: {:'data-placement' => 'top', :'data-tooltip' => true}, icon: 'fa fa-trophy', id: 'assess', label: t('exercises.editor.score'), title: t('shared.tooltips.shortcut', shortcut: 'ALT + s'))
+
+= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.request'), template: 'exercises/_request_comment_dialogcontent')
\ No newline at end of file
diff --git a/app/views/exercises/_request_comment_dialogcontent.html.slim b/app/views/exercises/_request_comment_dialogcontent.html.slim
new file mode 100644
index 00000000..330501f9
--- /dev/null
+++ b/app/views/exercises/_request_comment_dialogcontent.html.slim
@@ -0,0 +1,4 @@
+h5 = t('exercises.implement.comment.question')
+textarea.form-control#question(style='resize:none;')
+p = ''
+button#askForCommentsButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.request')
\ No newline at end of file
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 7d5710e5..ec798e51 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -245,6 +245,8 @@ de:
addComment: Kommentieren
removeAllOnLine: Alle Kommentare auf dieser Zeile löschen
listing: Die neuesten Kommentaranfragen
+ request: "Kommentaranfrage stellen"
+ question: "Was ist Ihre Frage? (optional)"
index:
clone: Duplizieren
implement: Implementieren
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f9306835..1350caec 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -245,6 +245,8 @@ en:
addComment: Comment this
removeAllOnLine: Remove all comments on this line
listing: Listing the newest comment requests
+ request: "Request Comments"
+ question: "What is your question? (optional)"
index:
clone: Duplicate
implement: Implement
From bd4fbcb8fb4edb3e617ec6f334953a2a191ba154 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 13:20:10 +0200
Subject: [PATCH 22/52] Add hovering button
---
app/assets/stylesheets/editor.css.scss | 6 ++++++
app/views/exercises/_editor_frame.html.slim | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/app/assets/stylesheets/editor.css.scss b/app/assets/stylesheets/editor.css.scss
index efcf1d25..661958b5 100644
--- a/app/assets/stylesheets/editor.css.scss
+++ b/app/assets/stylesheets/editor.css.scss
@@ -88,3 +88,9 @@ button i.fa-spin {
color: #777;
font-size: 0.8em;
}
+
+#requestCommentsButton {
+ position: relative;
+ margin-top: -50px;
+ float: right;
+}
diff --git a/app/views/exercises/_editor_frame.html.slim b/app/views/exercises/_editor_frame.html.slim
index dc077e02..29c78bd3 100644
--- a/app/views/exercises/_editor_frame.html.slim
+++ b/app/views/exercises/_editor_frame.html.slim
@@ -13,3 +13,7 @@
- else
.editor-content.hidden data-file-id=file.ancestor_id = file.content
.editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id
+
+ button.btn class='btn-primary' id='requestCommentsButton' type='button'
+ i.fa.fa-comment-o
+ = t('exercises.editor.requestComments')
\ No newline at end of file
From e4246029dacc25eadf04d762207d525b37745636 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 13:26:01 +0200
Subject: [PATCH 23/52] Remove unnecessary code from editor
---
app/assets/javascripts/editor.js.erb | 62 ----------------------------
1 file changed, 62 deletions(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index 3ef7e16a..3f71589f 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -256,8 +256,6 @@ $(function() {
}
};
-
-
var getPanelClass = function(result) {
if (result.stderr && !result.score) {
return 'panel-danger';
@@ -446,66 +444,6 @@ $(function() {
});
};
- var setAnnotations = function (editor, file_id){
- var session = editor.getSession();
- var url = "/comments";
-
- var jqrequest = $.ajax({
- dataType: 'json',
- method: 'GET',
- url: url,
- data: {
- file_id: file_id
- }
- });
-
- jqrequest.done(function(response){
- setAnnotationsCallback(response, session);
- });
- jqrequest.fail(ajaxError);
- };
-
- var setAnnotationsCallback = function (response, session) {
- var annotations = response;
-
- // add classname and the username in front of each comment
- $.each(annotations, function(index, comment){
- comment.className = "code-ocean_comment";
- comment.text = comment.username + ": " + comment.text;
- });
-
- session.setAnnotations(annotations);
- };
-
- var handleAnnotationRemoval = function(removedAnnotations) {
- removedAnnotations.forEach(function(annotation) {
- $.ajax({
- method: 'DELETE',
- url: '/comment_by_id',
- data: {
- id: annotation.id,
- }
- })
- })
- };
-
- var handleAnnotationChange = function(changedAnnotations) {
- changedAnnotations.forEach(function(annotation) {
- $.ajax({
- method: 'PUT',
- url: '/comments',
- data: {
- id: annotation.id,
- user_id: $('#editor').data('user-id'),
- comment: {
- row: annotation.row,
- text: annotation.text
- }
- }
- })
- })
- };
-
var initializeEventHandlers = function() {
$(document).on('click', '#results a', showOutput);
$(document).on('keypress', handleKeyPress);
From 087a230131698f2a1ffd1dd8a51115520dc6d2b0 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 13:36:20 +0200
Subject: [PATCH 24/52] Remove more code; handle click event
---
app/assets/javascripts/editor.js.erb | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index 3f71589f..fc395951 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -110,18 +110,6 @@ $(function() {
var createSubmission = function(initiator, filter, callback) {
showSpinner(initiator);
-
- var annotations_arr = [];
-
- $('.editor').each(function(index, element) {
- var editor = ace.edit(element);
- var cleaned_annotations = editor.getSession().getAnnotations();
- for(var i = cleaned_annotations.length-1; i>=0; --i){
- cleaned_annotations[i].text = cleaned_annotations[i].text.replace(cleaned_annotations[i].username + ": ", "");
- }
- annotations_arr = annotations_arr.concat(editor.getSession().getAnnotations());
- });
-
var jqxhr = ajax({
data: {
submission: {
@@ -129,7 +117,7 @@ $(function() {
exercise_id: $('#editor').data('exercise-id'),
files_attributes: (filter || _.identity)(collectFiles())
},
- annotations_arr: annotations_arr
+ annotations_arr: []
},
dataType: 'json',
method: 'POST',
@@ -169,7 +157,6 @@ $(function() {
}
}
}
- setAnnotations(editors[i], $(editors[i].container).data('id'));
}
// toggle button states (it might be the case that the request for comments button has to be enabled
toggleButtonStates();
@@ -423,7 +410,6 @@ $(function() {
session.setUseWrapMode(true);
var file_id = $(element).data('id');
- //setAnnotations(editor, file_id);
/*
* Register event handlers
@@ -433,10 +419,6 @@ $(function() {
editor.on("paste", handlePasteEvent);
editor.on("copy", handleCopyEvent);
- //session
- session.on('annotationRemoval', handleAnnotationRemoval);
- session.on('annotationChange', handleAnnotationChange);
-
// listener for autosave
session.on("change", function (deltaObject) {
resetSaveTimer();
@@ -451,6 +433,7 @@ $(function() {
initializeFileTreeButtons();
initializeWorkflowButtons();
initializeWorkspaceButtons();
+ initializeRequestForComments()
};
var initializeFileTree = function() {
@@ -493,6 +476,12 @@ $(function() {
$('#start-over').on('click', confirmReset);
};
+ var initializeRequestForComments = function () {
+ $('#requestCommentsButton').on('click', function() {
+ $('#comment-modal').modal('show');
+ })
+ }
+
var isActiveFileBinary = function() {
return 'binary' in active_frame.data();
};
From 7182dcd04e7a7c34d11cd4a11a24e0fd428fdbe2 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 13:47:47 +0200
Subject: [PATCH 25/52] Send requests for comments with question
---
app/assets/javascripts/editor.js.erb | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb
index fc395951..0180124e 100644
--- a/app/assets/javascripts/editor.js.erb
+++ b/app/assets/javascripts/editor.js.erb
@@ -479,8 +479,10 @@ $(function() {
var initializeRequestForComments = function () {
$('#requestCommentsButton').on('click', function() {
$('#comment-modal').modal('show');
- })
- }
+ });
+
+ $('#askForCommentsButton').on('click', requestComments);
+ };
var isActiveFileBinary = function() {
return 'binary' in active_frame.data();
@@ -495,7 +497,7 @@ $(function() {
filename: filename,
id: fileId
};
- }
+ };
var isActiveFileRenderable = function() {
return 'renderable' in active_frame.data();
@@ -1135,10 +1137,11 @@ $(function() {
}
};
- var requestComments = function(e) {
+ var requestComments = function() {
var user_id = $('#editor').data('user-id')
var exercise_id = $('#editor').data('exercise-id')
var file_id = $('.editor').data('id')
+ var question = $('#question').val();
$.ajax({
method: 'POST',
@@ -1147,6 +1150,7 @@ $(function() {
request_for_comment: {
exercise_id: exercise_id,
file_id: file_id,
+ question: question,
"requested_at(1i)": 2015, // these are the timestamp values that the request handler demands
"requested_at(2i)":3, // they could be random here, because the timestamp is updated on serverside anyway
"requested_at(3i)":27,
@@ -1155,13 +1159,11 @@ $(function() {
}
}
}).done(function() {
- hideSpinner()
+ hideSpinner();
$.flash.success({ text: 'Request for comments sent!' })
- })
+ }).error(ajaxError);
- showSpinner($('#request-for-comments'))
- // hide button until next submission is created
- $('#request-for-comments').toggle(false);
+ $('#comment-modal').modal('hide');
}
var initializeCodePilot = function() {
From c4405e24b9ceffc279eab82117fbfe44bc48e696 Mon Sep 17 00:00:00 2001
From: Maximilian Grundke
Date: Sat, 30 Apr 2016 13:57:23 +0200
Subject: [PATCH 26/52] Show question in overview
---
app/controllers/request_for_comments_controller.rb | 2 +-
app/views/request_for_comments/show.html.erb | 1 +
config/locales/de.yml | 1 +
config/locales/en.yml | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb
index 1394f0c3..555dad09 100644
--- a/app/controllers/request_for_comments_controller.rb
+++ b/app/controllers/request_for_comments_controller.rb
@@ -70,6 +70,6 @@ class RequestForCommentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def request_for_comment_params
- params.require(:request_for_comment).permit(:exercise_id, :file_id, :requested_at).merge(user_id: current_user.id, user_type: current_user.class.name)
+ params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at).merge(user_id: current_user.id, user_type: current_user.class.name)
end
end
diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb
index aa4fcec0..f325f3f2 100644
--- a/app/views/request_for_comments/show.html.erb
+++ b/app/views/request_for_comments/show.html.erb
@@ -14,6 +14,7 @@
%>
<%= user %> | <%= @request_for_comment.requested_at %>
+ <%=t('activerecord.attributes.request_for_comments.question')%>: "<%= @request_for_comment.question %>"