removed requested_at
partly using submission_id some cleanup
This commit is contained in:
@ -1215,7 +1215,6 @@ $(function() {
|
|||||||
var question = $('#question').val();
|
var question = $('#question').val();
|
||||||
|
|
||||||
var createRequestForComments = function(submission) {
|
var createRequestForComments = function(submission) {
|
||||||
console.log(submission);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/request_for_comments',
|
url: '/request_for_comments',
|
||||||
|
@ -17,6 +17,8 @@ class RequestForComment < ActiveRecord::Base
|
|||||||
Submission.find(file.context_id)
|
Submission.find(file.context_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# not used right now, finds the last submission for the respective user and exercise.
|
||||||
|
# might be helpful to check whether the exercise has been solved in the meantime.
|
||||||
def last_submission
|
def last_submission
|
||||||
Submission.find_by_sql(" select * from submissions
|
Submission.find_by_sql(" select * from submissions
|
||||||
where exercise_id = #{exercise_id} AND
|
where exercise_id = #{exercise_id} AND
|
||||||
@ -25,33 +27,15 @@ class RequestForComment < ActiveRecord::Base
|
|||||||
limit 1").first
|
limit 1").first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# not used any longer, since we directly saved the submission_id now.
|
||||||
|
# Was used before that to determine the submission belonging to the request_for_comment.
|
||||||
def last_submission_before_creation
|
def last_submission_before_creation
|
||||||
submission1 = Submission.find_by_sql(" select * from submissions
|
Submission.find_by_sql(" select * from submissions
|
||||||
where exercise_id = #{exercise_id} AND
|
where exercise_id = #{exercise_id} AND
|
||||||
user_id = #{user_id} AND
|
user_id = #{user_id} AND
|
||||||
'#{created_at.localtime}' > created_at
|
'#{created_at.localtime}' > created_at
|
||||||
order by created_at desc
|
order by created_at desc
|
||||||
limit 1").first
|
limit 1").first
|
||||||
submission2 = Submission.find_by_sql(" select * from submissions
|
|
||||||
where exercise_id = #{exercise_id} AND
|
|
||||||
user_id = #{user_id} AND
|
|
||||||
'#{created_at}' > created_at
|
|
||||||
order by created_at desc
|
|
||||||
limit 1").first
|
|
||||||
submission3 = Submission.find_by_sql(" select * from submissions
|
|
||||||
where exercise_id = #{exercise_id} AND
|
|
||||||
user_id = #{user_id} AND
|
|
||||||
'#{created_at.strftime('%Y-%m-%d %H:%M:%S.%N')}' > created_at
|
|
||||||
order by created_at desc
|
|
||||||
limit 1").first
|
|
||||||
submission4 = Submission.find_by_sql(" select * from submissions
|
|
||||||
where exercise_id = #{exercise_id} AND
|
|
||||||
user_id = #{user_id} AND
|
|
||||||
'#{created_at.localtime.strftime('%Y-%m-%d %H:%M:%S.%N')}' > created_at
|
|
||||||
order by created_at desc
|
|
||||||
limit 1").first
|
|
||||||
binding.pry
|
|
||||||
submission1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def comments_count
|
def comments_count
|
||||||
@ -64,6 +48,6 @@ class RequestForComment < ActiveRecord::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
def self.row_number_user_sql
|
def self.row_number_user_sql
|
||||||
select("id, user_id, exercise_id, file_id, question, requested_at, created_at, updated_at, user_type, solved, row_number() OVER (PARTITION BY user_id ORDER BY created_at DESC) as row_number").to_sql
|
select("id, user_id, exercise_id, file_id, question, created_at, updated_at, user_type, solved, submission_id, row_number() OVER (PARTITION BY user_id ORDER BY created_at DESC) as row_number").to_sql
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,6 +27,6 @@ h1 = RequestForComment.model_name.human(count: 2)
|
|||||||
td = '-'
|
td = '-'
|
||||||
td = request_for_comment.comments_count
|
td = request_for_comment.comments_count
|
||||||
td = request_for_comment.user.displayname
|
td = request_for_comment.user.displayname
|
||||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.requested_at))
|
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
|
||||||
|
|
||||||
= render('shared/pagination', collection: @request_for_comments)
|
= render('shared/pagination', collection: @request_for_comments)
|
@ -1,11 +1,11 @@
|
|||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<h4 id ="exercise_caption" class="list-group-item-heading" data-rfc-id = "<%= @request_for_comment.id %>" ><%= Exercise.find(@request_for_comment.exercise_id) %></h4>
|
<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>
|
||||||
<p class="list-group-item-text">
|
<p class="list-group-item-text">
|
||||||
<%
|
<%
|
||||||
user = @request_for_comment.user
|
user = @request_for_comment.user
|
||||||
submission = @request_for_comment.last_submission_before_creation
|
submission = @request_for_comment.last_submission_before_creation
|
||||||
%>
|
%>
|
||||||
<%= user.displayname %> | <%= @request_for_comment.requested_at.localtime %>
|
<%= user.displayname %> | <%= @request_for_comment.created_at.localtime %>
|
||||||
</p>
|
</p>
|
||||||
<h5>
|
<h5>
|
||||||
<u><%= t('activerecord.attributes.exercise.description') %>:</u> "<%= render_markdown(@request_for_comment.exercise.description) %>"
|
<u><%= t('activerecord.attributes.exercise.description') %>:</u> "<%= render_markdown(@request_for_comment.exercise.description) %>"
|
||||||
|
@ -173,10 +173,9 @@ ActiveRecord::Schema.define(version: 20160704143402) do
|
|||||||
add_index "internal_users", ["reset_password_token"], name: "index_internal_users_on_reset_password_token", using: :btree
|
add_index "internal_users", ["reset_password_token"], name: "index_internal_users_on_reset_password_token", using: :btree
|
||||||
|
|
||||||
create_table "request_for_comments", force: true do |t|
|
create_table "request_for_comments", force: true do |t|
|
||||||
t.integer "user_id", null: false
|
t.integer "user_id", null: false
|
||||||
t.integer "exercise_id", null: false
|
t.integer "exercise_id", null: false
|
||||||
t.integer "file_id", null: false
|
t.integer "file_id", null: false
|
||||||
t.datetime "requested_at"
|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "user_type"
|
t.string "user_type"
|
||||||
|
Reference in New Issue
Block a user