From 2caf4b123e365fb90a4fc4110df480a0611d7d3f Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Mon, 27 Feb 2017 15:32:51 +0100 Subject: [PATCH] added intervention modals back into editor.js and html --- app/assets/javascripts/editor/editor.js.erb | 24 +++++++++++++++++++ app/views/exercises/_editor.html.slim | 5 ++-- .../interventions/_working_too_long.html.slim | 13 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 app/views/interventions/_working_too_long.html.slim diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 0be56058..9c38aca6 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -571,6 +571,29 @@ configureEditors: function () { }, + /** + * interventions + * */ + initializeInterventionTimer: function() { + $.ajax({ + data: { + exercise_id: $('#editor').data('exercise-id'), + user_id: $('#editor').data('user-id') + }, + dataType: 'json', + method: 'GET', + url: $('#editor').data('working-times-url'), + success: function (data) { + var avg = data['working_time_avg']; + var accu = data['working_time_accumulated']; + $('#avg-working-time').text(`avg time: ${avg} and accumulated time: ${accu}`); + setTimeout(function() { + $('#intervention-modal').modal('show') + }, 10000); + } + }); + }, + initializeEverything: function() { this.initializeRegexes(); @@ -585,6 +608,7 @@ configureEditors: function () { this.initializeDescriptionToggle(); this.initializeSideBarTooltips(); this.initializeTooltips(); + this.initializeInterventionTimer(); this.initPrompt(); this.renderScore(); this.showFirstFile(); diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index ff18968c..df25104d 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -1,7 +1,7 @@ - external_user_external_id = @current_user.respond_to?(:external_id) ? @current_user.external_id : '' #'tests' #(@current_user.uuid.present? ? @current_user.uuid : '') - external_user_id = @current_user.respond_to?(:external_id) ? @current_user.id : '' #'tests' #(@current_user.uuid.present? ? @current_user.uuid : '') - consumer_id = @current_user.respond_to?(:external_id) ? @current_user.consumer_id : '' #'tests' #(@current_user.uuid.present? ? @current_user.uuid : '') -#editor.row data-exercise-id=exercise.id data-message-depleted=t('exercises.editor.depleted') 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 data-user-external-id=external_user_external_id +#editor.row data-exercise-id=exercise.id data-message-depleted=t('exercises.editor.depleted') 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 data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path div id="sidebar" class=(@exercise.hide_file_tree ? 'sidebar-col-collapsed' : 'sidebar-col') = render('editor_file_tree', exercise: @exercise, files: @files) div id='output_sidebar' class='output-col-collapsed' = render('exercises/editor_output', external_user_id: external_user_id, consumer_id: consumer_id ) div id='frames' class='editor-col' @@ -21,4 +21,5 @@ button style="display:none" id="autosave" -= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.request'), template: 'exercises/_request_comment_dialogcontent') \ No newline at end of file += render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.request'), template: 'exercises/_request_comment_dialogcontent') += render('shared/modal', id: 'intervention-modal', title: 'Leg mal eine Pause ein', template: 'interventions/_working_too_long') \ No newline at end of file diff --git a/app/views/interventions/_working_too_long.html.slim b/app/views/interventions/_working_too_long.html.slim new file mode 100644 index 00000000..31e8a963 --- /dev/null +++ b/app/views/interventions/_working_too_long.html.slim @@ -0,0 +1,13 @@ +/h5 = t('exercises.implement.comment.question') + +h5 = 'Aufpassen!' +/textarea.form-control#question(style='resize:none;') +p = 'Uns ist aufgefallen, dass Sie schon sehr lange an dieser Aufgabe sitzen. Wollen Sie nicht vielleicht mal eine Pause einlegen?' +#avg-working-time + +/p = "AVG: #{@working_time_avg}" +/p = "ACCUMULATED: #{@working_time_accumulated}" + +/ data-cause='requestComments' is not used here right now, we pass the button #requestComments (not askForCommentsButton) as initiator of the action. +/ But if we use this button, it will work since the correct cause is supplied +/button#askForCommentsButton.btn.btn-block.btn-primary(type='button' data-cause='requestComments' data-message-success=t('exercises.editor.request_for_comments_sent')) =t('exercises.implement.comment.request') \ No newline at end of file