added interventions back to code. added post method to be able to save interventions
This commit is contained in:
@ -545,12 +545,14 @@ configureEditors: function () {
|
|||||||
$('#output_sidebar_collapsed').addClass('hidden');
|
$('#output_sidebar_collapsed').addClass('hidden');
|
||||||
$('#output_sidebar_uncollapsed').removeClass('hidden');
|
$('#output_sidebar_uncollapsed').removeClass('hidden');
|
||||||
$('#output_sidebar').removeClass('output-col-collapsed').addClass('output-col');
|
$('#output_sidebar').removeClass('output-col-collapsed').addClass('output-col');
|
||||||
|
this.resizeAceEditors();
|
||||||
},
|
},
|
||||||
|
|
||||||
hideOutputBar: function() {
|
hideOutputBar: function() {
|
||||||
$('#output_sidebar_collapsed').removeClass('hidden');
|
$('#output_sidebar_collapsed').removeClass('hidden');
|
||||||
$('#output_sidebar_uncollapsed').addClass('hidden');
|
$('#output_sidebar_uncollapsed').addClass('hidden');
|
||||||
$('#output_sidebar').removeClass('output-col').addClass('output-col-collapsed');
|
$('#output_sidebar').removeClass('output-col').addClass('output-col-collapsed');
|
||||||
|
this.resizeAceEditors();
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeSideBarTooltips: function() {
|
initializeSideBarTooltips: function() {
|
||||||
@ -587,15 +589,15 @@ configureEditors: function () {
|
|||||||
var percentile75 = data['working_time_75_percentile'];
|
var percentile75 = data['working_time_75_percentile'];
|
||||||
var accumulatedWorkTimeUser = data['working_time_accumulated'];
|
var accumulatedWorkTimeUser = data['working_time_accumulated'];
|
||||||
|
|
||||||
var timeUntilBreak = 15 * 60;
|
var timeUntilBreak = 15 * 60 * 1000;
|
||||||
|
|
||||||
if ((accumulatedWorkTimeUser - percentile75) > 0) {
|
if ((accumulatedWorkTimeUser - percentile75) > 0) {
|
||||||
// working time is already over 75 percentile
|
// working time is already over 75 percentile
|
||||||
var timeUntilAskQuestion = 7 * 60;
|
var timeUntilAskQuestion = 10 * 60 * 1000;
|
||||||
} else {
|
} else {
|
||||||
// working time is less than 75 percentile
|
// working time is less than 75 percentile
|
||||||
// ensure we give user at least 10 minutes before we bother the user
|
// ensure we give user at least 10 minutes before we bother the user
|
||||||
var timeUntilAskQuestion = (percentile75 - accumulatedWorkTimeUser) > 10 * 60 ? (percentile75 - accumulatedWorkTimeUser) : 10 * 60;
|
var timeUntilAskQuestion = (percentile75 - accumulatedWorkTimeUser) > 10 * 60 * 1000 ? (percentile75 - accumulatedWorkTimeUser) : 10 * 60 * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if notifications are too close to each other, ensure some time differences between them
|
// if notifications are too close to each other, ensure some time differences between them
|
||||||
@ -605,7 +607,15 @@ configureEditors: function () {
|
|||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$('#intervention-text').text(`Willst du eine Pause machen? 75th percentile: ${percentile75} and accumulated time: ${accumulatedWorkTimeUser}`);
|
$('#intervention-text').text(`Willst du eine Pause machen? 75th percentile: ${percentile75} and accumulated time: ${accumulatedWorkTimeUser}`);
|
||||||
$('#intervention-modal').modal('show')
|
$('#intervention-modal').modal('show');
|
||||||
|
$.ajax({
|
||||||
|
data: {
|
||||||
|
exercise_id: $('#editor').data('exercise-id'),
|
||||||
|
user_id: $('#editor').data('user-id')
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'POST',
|
||||||
|
url: "localhost:3000/exercise/intervention"});
|
||||||
}, timeUntilBreak);
|
}, timeUntilBreak);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -6,7 +6,7 @@ class ExercisesController < ApplicationController
|
|||||||
|
|
||||||
before_action :handle_file_uploads, only: [:create, :update]
|
before_action :handle_file_uploads, only: [:create, :update]
|
||||||
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
||||||
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :run, :statistics, :submit, :reload]
|
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :intervention, :run, :statistics, :submit, :reload]
|
||||||
before_action :set_external_user, only: [:statistics]
|
before_action :set_external_user, only: [:statistics]
|
||||||
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
before_action :set_file_types, only: [:create, :edit, :new, :update]
|
||||||
|
|
||||||
@ -167,11 +167,20 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def working_times
|
def working_times
|
||||||
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user.id)
|
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user)
|
||||||
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
|
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
|
||||||
render(json: {working_time_75_percentile: working_time_75_percentile, working_time_accumulated: working_time_accumulated})
|
render(json: {working_time_75_percentile: working_time_75_percentile, working_time_accumulated: working_time_accumulated})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def intervention
|
||||||
|
uei = UserExerciseIntervention.new(
|
||||||
|
user: current_user, exercise: @exercise, intervention: Intervention.first,
|
||||||
|
accumulated_worktime: @exercise.accumulated_working_time_for_only(current_user))
|
||||||
|
|
||||||
|
puts "user: #{current_user}, intervention: #{Intervention.first} #{uei.save}"
|
||||||
|
render(json: {success: 'true'})
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = policy_scope(Exercise).search(params[:q])
|
@search = policy_scope(Exercise).search(params[:q])
|
||||||
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
|
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
|
||||||
|
@ -126,7 +126,8 @@ class Exercise < ActiveRecord::Base
|
|||||||
@working_time_statistics[user_id]["working_time"]
|
@working_time_statistics[user_id]["working_time"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def accumulated_working_time_for_only(user_id)
|
def accumulated_working_time_for_only(user)
|
||||||
|
user_type = user.external_user? ? "ExternalUser" : "InternalUser"
|
||||||
Time.parse(self.class.connection.execute("""
|
Time.parse(self.class.connection.execute("""
|
||||||
SELECT sum(working_time_new) AS working_time
|
SELECT sum(working_time_new) AS working_time
|
||||||
FROM
|
FROM
|
||||||
@ -136,7 +137,7 @@ class Exercise < ActiveRecord::Base
|
|||||||
(created_at - lag(created_at) over (PARTITION BY user_id, exercise_id
|
(created_at - lag(created_at) over (PARTITION BY user_id, exercise_id
|
||||||
ORDER BY created_at)) AS working_time
|
ORDER BY created_at)) AS working_time
|
||||||
FROM submissions
|
FROM submissions
|
||||||
WHERE exercise_id=#{id} and user_id=#{user_id} and user_type='ExternalUser') AS foo) AS bar
|
WHERE exercise_id=#{id} and user_id=#{user.id} and user_type='#{user_type}') AS foo) AS bar
|
||||||
""").first["working_time"] || "00:00:00").seconds_since_midnight
|
""").first["working_time"] || "00:00:00").seconds_since_midnight
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
return 0.0
|
return 0.0
|
||||||
end
|
end
|
||||||
points_ratio_index = ((scoring_matrix.size - 1) * points_ratio).to_i
|
points_ratio_index = ((scoring_matrix.size - 1) * points_ratio).to_i
|
||||||
working_time_user = ex.accumulated_working_time_for_only(user.id)
|
working_time_user = ex.accumulated_working_time_for_only(user)
|
||||||
quantiles_working_time = ex.get_quantiles(scoring_matrix_quantiles)
|
quantiles_working_time = ex.get_quantiles(scoring_matrix_quantiles)
|
||||||
quantile_index = quantiles_working_time.size
|
quantile_index = quantiles_working_time.size
|
||||||
quantiles_working_time.each_with_index do |quantile_time, i|
|
quantiles_working_time.each_with_index do |quantile_time, i|
|
||||||
|
@ -16,7 +16,7 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
|||||||
define_method(action) { admin? || author?}
|
define_method(action) { admin? || author?}
|
||||||
end
|
end
|
||||||
|
|
||||||
[:implement?, :working_times?, :submit?, :reload?].each do |action|
|
[:implement?, :working_times?, :intervention?, :submit?, :reload?].each do |action|
|
||||||
define_method(action) { everyone }
|
define_method(action) { everyone }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user