add feedback for exercises
This commit is contained in:
@ -32,6 +32,10 @@ class RequestForCommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def submit
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# GET /request_for_comments/1
|
# GET /request_for_comments/1
|
||||||
# GET /request_for_comments/1.json
|
# GET /request_for_comments/1.json
|
||||||
def show
|
def show
|
||||||
@ -63,6 +67,20 @@ class RequestForCommentsController < ApplicationController
|
|||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_comment_exercise
|
||||||
|
old = UserExerciseFeedback.find_by(exercise_id: params[:exercise_id], user_id: current_user.id, user_type: current_user.class.name)
|
||||||
|
if old
|
||||||
|
old.delete
|
||||||
|
end
|
||||||
|
uef = UserExerciseFeedback.new(comment_params)
|
||||||
|
|
||||||
|
if uef.save
|
||||||
|
render(json: {success: "true"})
|
||||||
|
else
|
||||||
|
render(json: {success: "false"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# DELETE /request_for_comments/1
|
# DELETE /request_for_comments/1
|
||||||
# DELETE /request_for_comments/1.json
|
# DELETE /request_for_comments/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@ -74,6 +92,10 @@ class RequestForCommentsController < ApplicationController
|
|||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_params
|
||||||
|
params.permit(:exercise_id, :feedback_text).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_request_for_comment
|
def set_request_for_comment
|
||||||
@ -85,4 +107,5 @@ class RequestForCommentsController < ApplicationController
|
|||||||
# we are using the current_user.id here, since internal users are not able to create comments. The external_user.id is a primary key and does not require the consumer_id to be unique.
|
# we are using the current_user.id here, since internal users are not able to create comments. The external_user.id is a primary key and does not require the consumer_id to be unique.
|
||||||
params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).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, :solved, :submission_id).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -27,4 +27,8 @@ class RequestForCommentPolicy < ApplicationPolicy
|
|||||||
def index?
|
def index?
|
||||||
everyone
|
everyone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_comment_exercise?
|
||||||
|
everyone
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
h5 =t('exercises.implement.comment.addComment')
|
||||||
|
textarea#commentOnExercise.form-control(style='resize:none;')
|
||||||
|
|
||||||
|
p=''
|
||||||
|
button#addCommentExerciseButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.addCommentButton')
|
@ -1,5 +1,5 @@
|
|||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<h4 id ="exercise_caption" class="list-group-item-heading" data-rfc-id = "<%= @request_for_comment.id %>" ><%= link_to(@request_for_comment.exercise.title, [:implement, @request_for_comment.exercise]) %></h4>
|
<h4 id ="exercise_caption" class="list-group-item-heading" data-exercise-id="<%=@request_for_comment.exercise.id%>" data-comment-exercise-url="<%=create_comment_exercise_request_for_comment_path%>" data-rfc-id = "<%= @request_for_comment.id %>" ><%= link_to(@request_for_comment.exercise.title, [:implement, @request_for_comment.exercise]) %></h4>
|
||||||
<p class="list-group-item-text">
|
<p class="list-group-item-text">
|
||||||
<%
|
<%
|
||||||
user = @request_for_comment.user
|
user = @request_for_comment.user
|
||||||
@ -20,14 +20,18 @@
|
|||||||
<u><%= t('activerecord.attributes.request_for_comments.question')%>:</u> <%= t('request_for_comments.no_question') %>
|
<u><%= t('activerecord.attributes.request_for_comments.question')%>:</u> <%= t('request_for_comments.no_question') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</h5>
|
</h5>
|
||||||
|
<button class="btn btn-block btn-primary" id="comment-exercise-button"><%= t('request_for_comments.comment_exercise') %></button>
|
||||||
|
|
||||||
<% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %>
|
<% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %>
|
||||||
<button class="btn btn-default" id="mark-as-solved-button"><%= t('request_for_comments.mark_as_solved') %></button>
|
<button class="btn btn-block btn-primary" id="mark-as-solved-button"><%= t('request_for_comments.mark_as_solved') %></button>
|
||||||
<% elsif (@request_for_comment.solved?) %>
|
<% elsif (@request_for_comment.solved?) %>
|
||||||
<button type="button" class="btn btn-success"><%= t('request_for_comments.solved') %></button>
|
<button type="button" class="btn btn-block btn-success"><%= t('request_for_comments.solved') %></button>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<% if @current_user.admin? && user.is_a?(ExternalUser) %>
|
<% if @current_user.admin? && user.is_a?(ExternalUser) %>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
@ -58,10 +62,13 @@ also, all settings from the rails model needed for the editor configuration in t
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %>
|
<%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %>
|
||||||
|
<%= render('shared/modal', id: 'comment-exercise-modal', title: t('exercises.implement.comment.addCommentExercise'), template: 'exercises/_comment_exercise_dialogcontent') %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var solvedButton = $('#mark-as-solved-button');
|
var solvedButton = $('#mark-as-solved-button');
|
||||||
|
var commentOnExerciseButton = $('#comment-exercise-button');
|
||||||
|
var addCommentExerciseButton = $('#addCommentExerciseButton')
|
||||||
|
|
||||||
solvedButton.on('click', function(event){
|
solvedButton.on('click', function(event){
|
||||||
var jqrequest = $.ajax({
|
var jqrequest = $.ajax({
|
||||||
@ -77,6 +84,29 @@ also, all settings from the rails model needed for the editor configuration in t
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// comment exercise
|
||||||
|
commentOnExerciseButton.on('click', function(){
|
||||||
|
$('#comment-exercise-modal').modal('show');
|
||||||
|
})
|
||||||
|
|
||||||
|
addCommentExerciseButton.on('click', function(event){
|
||||||
|
var comment = $('#commentOnExercise').val();
|
||||||
|
var url = $('#exercise_caption').data('comment-exercise-url');
|
||||||
|
var jqrequest = $.ajax({
|
||||||
|
dataType: 'json',
|
||||||
|
method: 'POST',
|
||||||
|
url: url,
|
||||||
|
data: {
|
||||||
|
exercise_id: $('#exercise_caption').data('exercise-id'),
|
||||||
|
feedback_text: comment
|
||||||
|
},
|
||||||
|
dataType: 'json'
|
||||||
|
});
|
||||||
|
$('#comment-exercise-modal').modal('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set file paths for ace
|
// set file paths for ace
|
||||||
var ACE_FILES_PATH = '/assets/ace/';
|
var ACE_FILES_PATH = '/assets/ace/';
|
||||||
_.each(['modePath', 'themePath', 'workerPath'], function(attribute) {
|
_.each(['modePath', 'themePath', 'workerPath'], function(attribute) {
|
||||||
@ -165,6 +195,27 @@ also, all settings from the rails model needed for the editor configuration in t
|
|||||||
jqxhr.fail(ajaxError);
|
jqxhr.fail(ajaxError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCommentOnExercise(file_id, row, editor, commenttext){
|
||||||
|
var jqxhr = $.ajax({
|
||||||
|
data: {
|
||||||
|
comment: {
|
||||||
|
file_id: file_id,
|
||||||
|
row: row,
|
||||||
|
column: 0,
|
||||||
|
text: commenttext,
|
||||||
|
request_id: $('h4#exercise_caption').data('rfc-id')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
method: 'POST',
|
||||||
|
url: "/comments"
|
||||||
|
});
|
||||||
|
jqxhr.done(function(response){
|
||||||
|
setAnnotations(editor, file_id);
|
||||||
|
});
|
||||||
|
jqxhr.fail(ajaxError);
|
||||||
|
}
|
||||||
|
|
||||||
function handleSidebarClick(e) {
|
function handleSidebarClick(e) {
|
||||||
var target = e.domEvent.target;
|
var target = e.domEvent.target;
|
||||||
var editor = e.editor;
|
var editor = e.editor;
|
||||||
|
@ -270,8 +270,10 @@ de:
|
|||||||
line: Zeile
|
line: Zeile
|
||||||
dialogtitle: Kommentar hinzufügen
|
dialogtitle: Kommentar hinzufügen
|
||||||
others: Andere Kommentare auf dieser Zeile
|
others: Andere Kommentare auf dieser Zeile
|
||||||
|
addCommentExercise: Aufgabe kommentieren
|
||||||
addyours: Fügen Sie Ihren Kommentar hinzu
|
addyours: Fügen Sie Ihren Kommentar hinzu
|
||||||
addComment: Kommentieren
|
addComment: Hier haben Sie die Möglichkeit Ihr Feedback zu dieser Aufgabe zu geben. Fanden Sie die Aufgabe zu leicht oder schwer? War die Beschreibung eventuell nicht gut?
|
||||||
|
addCommentButton: Kommentar abschicken
|
||||||
removeAllOnLine: Meine Kommentare auf dieser Zeile löschen
|
removeAllOnLine: Meine Kommentare auf dieser Zeile löschen
|
||||||
listing: Die neuesten Kommentaranfragen
|
listing: Die neuesten Kommentaranfragen
|
||||||
request: "Kommentaranfrage stellen"
|
request: "Kommentaranfrage stellen"
|
||||||
@ -399,6 +401,7 @@ de:
|
|||||||
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
||||||
mark_as_solved: "Diese Frage als beantwortet markieren"
|
mark_as_solved: "Diese Frage als beantwortet markieren"
|
||||||
solved: "Diese Frage wurde erfolgreich beantwortet"
|
solved: "Diese Frage wurde erfolgreich beantwortet"
|
||||||
|
comment_exercise: "Ich möchte die Aufgabenstellung kommentieren"
|
||||||
sessions:
|
sessions:
|
||||||
create:
|
create:
|
||||||
failure: Fehlerhafte E-Mail oder Passwort.
|
failure: Fehlerhafte E-Mail oder Passwort.
|
||||||
|
@ -292,7 +292,9 @@ en:
|
|||||||
dialogtitle: Comment on this line
|
dialogtitle: Comment on this line
|
||||||
others: Other comments on this line
|
others: Other comments on this line
|
||||||
addyours: Add your comment
|
addyours: Add your comment
|
||||||
addComment: Comment this
|
addCommentExercise: Comment this exercise
|
||||||
|
addComment: You can give feedback to this exercise. Did you find this exercise particulary easy or difficult? Was the description easy to understand?
|
||||||
|
addCommentButton: Comment this
|
||||||
removeAllOnLine: Remove my comments on this line
|
removeAllOnLine: Remove my comments on this line
|
||||||
listing: Listing the newest comment requests
|
listing: Listing the newest comment requests
|
||||||
request: "Request Comments"
|
request: "Request Comments"
|
||||||
@ -420,6 +422,7 @@ en:
|
|||||||
no_question: "The author did not enter a question for this request."
|
no_question: "The author did not enter a question for this request."
|
||||||
mark_as_solved: "Mark this question as answered"
|
mark_as_solved: "Mark this question as answered"
|
||||||
solved: "This question has been answered"
|
solved: "This question has been answered"
|
||||||
|
comment_exercise: "I would like to give feedback for this exercise"
|
||||||
sessions:
|
sessions:
|
||||||
create:
|
create:
|
||||||
failure: Invalid email or password.
|
failure: Invalid email or password.
|
||||||
|
@ -10,6 +10,7 @@ Rails.application.routes.draw do
|
|||||||
resources :request_for_comments do
|
resources :request_for_comments do
|
||||||
member do
|
member do
|
||||||
get :mark_as_solved
|
get :mark_as_solved
|
||||||
|
post :create_comment_exercise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :comments, except: [:destroy] do
|
resources :comments, except: [:destroy] do
|
||||||
|
Reference in New Issue
Block a user