diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index c5b0f0ad..184e1043 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -318,7 +318,7 @@ $(function() { commentModal.find('#removeAllButton').off('click') commentModal.find('#addCommentButton').on('click', function(e){ - var user_id = 18 + var user_id = element.data('user-id') var commenttext = commentModal.find('textarea').val() if (commenttext !== "") { @@ -328,7 +328,7 @@ $(function() { }) commentModal.find('#removeAllButton').on('click', function(e){ - var user_id = 18; + var user_id = element.data('user-id') deleteComment(user_id,file_id,row,editor); commentModal.modal('hide') }) @@ -351,10 +351,7 @@ $(function() { } var setAnnotations = function (editor, file_id){ - - var session = editor.getSession(); - - // Retrieve comments for file and set them as annotations + var session = editor.getSession() var url = "/comments"; var jqrequest = $.ajax({ @@ -439,7 +436,7 @@ $(function() { url: '/comments', data: { id: annotation.id, - user_id: 18, + user_id: $('#editor').data('user-id'), comment: { row: annotation.row, text: annotation.text @@ -475,6 +472,7 @@ $(function() { $('#create-file').on('click', showFileDialog); $('#destroy-file').on('click', confirmDestroy); $('#download').on('click', downloadCode); + $('#request-for-comments').on('click', requestComments) }; var initializeTooltips = function() { @@ -833,6 +831,29 @@ $(function() { $('#test').toggle(isActiveFileTestable()); }; + var requestComments = function(e) { + var user_id = $('#editor').data('user-id') + var exercise_id = $('#editor').data('exercise-id') + var file_id = $('.editor').data('file-id') + + $.ajax({ + method: 'POST', + url: '/request_for_comments', + data: { + request_for_comment: { + requestorid: user_id, + exerciseid: exercise_id, + fileid: file_id, + "requested_at(1i)": 2015, + "requested_at(2i)":3, + "requested_at(3i)":27, + "requested_at(4i)":17, + "requested_at(5i)":06 + } + } + }) + } + if ($('#editor').isPresent()) { if (isBrowserSupported()) { $('.score, #development-environment').show(); diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 00000000..6ec6a8ff --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/controllers/request_for_comments_controller.rb b/app/controllers/request_for_comments_controller.rb new file mode 100644 index 00000000..fc0ab7b0 --- /dev/null +++ b/app/controllers/request_for_comments_controller.rb @@ -0,0 +1,62 @@ +class RequestForCommentsController < ApplicationController + before_action :set_request_for_comment, only: [:show, :edit, :update, :destroy] + + skip_after_action :verify_authorized + + + # GET /request_for_comments + # GET /request_for_comments.json + def index + @request_for_comments = RequestForComment.all + end + + # GET /request_for_comments/1 + # GET /request_for_comments/1.json + def show + end + + # GET /request_for_comments/new + def new + @request_for_comment = RequestForComment.new + end + + # GET /request_for_comments/1/edit + def edit + end + + # POST /request_for_comments + # POST /request_for_comments.json + def create + @request_for_comment = RequestForComment.new(request_for_comment_params) + + respond_to do |format| + if @request_for_comment.save + format.json { render :show, status: :created, location: @request_for_comment } + else + format.html { render :new } + format.json { render json: @request_for_comment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /request_for_comments/1 + # DELETE /request_for_comments/1.json + def destroy + @request_for_comment.destroy + respond_to do |format| + format.html { redirect_to request_for_comments_url, notice: 'Request for comment was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_request_for_comment + @request_for_comment = RequestForComment.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def request_for_comment_params + params.require(:request_for_comment).permit(:requestorid, :exerciseid, :fileid, :requested_at) + end +end diff --git a/app/helpers/request_for_comments_helper.rb b/app/helpers/request_for_comments_helper.rb new file mode 100644 index 00000000..f46a73e4 --- /dev/null +++ b/app/helpers/request_for_comments_helper.rb @@ -0,0 +1,2 @@ +module RequestForCommentsHelper +end diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb new file mode 100644 index 00000000..a22a7246 --- /dev/null +++ b/app/models/request_for_comment.rb @@ -0,0 +1,7 @@ +class RequestForComment < ActiveRecord::Base + before_create :set_requested_timestamp + + def set_requested_timestamp + self.requested_at = Time.now + end +end diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index ad637a36..b8450c29 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -1,4 +1,4 @@ -#editor.row data-exercise-id=exercise.id data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path +#editor.row data-exercise-id=exercise.id data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-errors-url=execution_environment_errors_path(exercise.execution_environment) data-submissions-url=submissions_path data-user-id=@current_user.id .col-sm-3 = render('editor_file_tree', files: @files) #frames.col-sm-9 - @files.each do |file| diff --git a/app/views/exercises/_editor_file_tree.html.slim b/app/views/exercises/_editor_file_tree.html.slim index cad3c845..36ba8c37 100644 --- a/app/views/exercises/_editor_file_tree.html.slim +++ b/app/views/exercises/_editor_file_tree.html.slim @@ -5,5 +5,6 @@ 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: 'Request comments') = render('shared/modal', id: 'modal-file', template: 'code_ocean/files/_form', title: t('exercises.editor.create_file')) diff --git a/app/views/exercises/index.html.slim b/app/views/exercises/index.html.slim index 9cc44d32..d6e37ca9 100644 --- a/app/views/exercises/index.html.slim +++ b/app/views/exercises/index.html.slim @@ -40,4 +40,4 @@ h1 = Exercise.model_name.human(count: 2) td = link_to(t('shared.statistics'), statistics_exercise_path(exercise)) = render('shared/pagination', collection: @exercises) -p = render('shared/new_button', model: Exercise) +p = render('shared/new_button', model: Exercise) \ No newline at end of file diff --git a/app/views/request_for_comments/_form.html.erb b/app/views/request_for_comments/_form.html.erb new file mode 100644 index 00000000..a8d037e9 --- /dev/null +++ b/app/views/request_for_comments/_form.html.erb @@ -0,0 +1,33 @@ +<%= form_for(@request_for_comment) do |f| %> + <% if @request_for_comment.errors.any? %> +
+ <%= InternalUser.find(request_for_comment.requestorid) %> | <%= request_for_comment.requested_at %> +
+ + <% end %> ++ <%= InternalUser.find(@request_for_comment.requestorid) %> | <%= @request_for_comment.requested_at %> +
+