search bar now searches in forum of the course from where the LTI request came from. alternatively searches in the java 2017 course.

show interventions only in the current java course
This commit is contained in:
Thomas Hille
2017-03-09 13:36:15 +01:00
parent 4f5c936dd6
commit 12adfde6c2
4 changed files with 44 additions and 15 deletions

View File

@ -601,11 +601,11 @@ configureEditors: function () {
} else {
// working time is less than 75 percentile
// ensure we give user at least 10 minutes before we bother the user
var timeUntilAskQuestion = (percentile75 - accumulatedWorkTimeUser) > minTimeUntilAskQuestion ? (percentile75 - accumulatedWorkTimeUser) : minTimeUntilAskQuestion;
var timeUntilAskForRFC = (percentile75 - accumulatedWorkTimeUser) > minTimeUntilAskQuestion ? (percentile75 - accumulatedWorkTimeUser) : minTimeUntilAskQuestion;
}
// if notifications are too close to each other, ensure some time differences between them
if (Math.abs(timeUntilAskQuestion - timeUntilBreak) < 5 * 1000 * 60){
if (Math.abs(timeUntilAskForRFC - timeUntilBreak) < 5 * 1000 * 60){
timeUntilBreak = timeUntilBreak * 2;
}
@ -634,7 +634,7 @@ configureEditors: function () {
type: 'POST',
url: $('#editor').data('intervention-save-url')});
};
}, timeUntilAskQuestion);
}, timeUntilAskForRFC);
}
});
},
@ -642,7 +642,8 @@ configureEditors: function () {
initializeSearchButton: function(){
$('#btn-search-col').button().click(function(){
var search = $('#search-col').val();
window.open(`https://open.hpi.de/courses/javaeinstieg2017/pinboard?query=${search}`, '_blank');
var course_token = $('#sidebar-collapsed').data('course_token')
window.open(`https://open.hpi.de/courses/${course_token}/pinboard?query=${search}`, '_blank');
})
$('#sidebar-search-collapsed').on('click',this.handleSideBarToggle.bind(this));

View File

@ -140,6 +140,7 @@ module Lti
lti_parameters.lti_parameters = options[:parameters].slice(*SESSION_PARAMETERS).to_json
lti_parameters.save!
@lti_parameters = lti_parameters
session[:consumer_id] = options[:consumer].id
session[:external_user_id] = @current_user.id

View File

@ -9,6 +9,7 @@ class ExercisesController < ApplicationController
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_file_types, only: [:create, :edit, :new, :update]
before_action :set_course_token, only: [:implement]
skip_before_filter :verify_authenticity_token, only: [:import_proforma_xml]
skip_after_action :verify_authorized, only: [:import_proforma_xml]
@ -155,12 +156,16 @@ class ExercisesController < ApplicationController
def implement
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
user_got_enough_interventions = UserExerciseIntervention.where(exercise: @exercise, user: current_user).count >= 3
is_java_course = @course_token && @course_token.eql?(java_course_token)
@show_interventions =
if UserExerciseIntervention.where(exercise: @exercise, user: current_user).count >= 3
if !is_java_course || user_got_enough_interventions
"false"
else
"true"
end
@search = Search.new
@search.exercise = @exercise
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
@ -174,6 +179,22 @@ class ExercisesController < ApplicationController
end
end
def set_course_token
if @lti_parameters
lti_json = @lti_parameters.lti_parameters
@course_token =
if match = lti_json.match(/^.*courses\/([a-z0-9\-]+)\/sections/)
match.captures.first
else
java_course_token
end
else
# no consumer, therefore implementation with internal user
@course_token = java_course_token
end
end
private :set_course_token
def working_times
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user)
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
@ -358,4 +379,8 @@ class ExercisesController < ApplicationController
redirect_to_lti_return_path
end
def java_course_token
"702cbd2a-c84c-4b37-923a-692d7d1532d0"
end
end

View File

@ -1,4 +1,4 @@
div id='sidebar-collapsed' class=(@exercise.hide_file_tree ? '' : 'hidden')
div id='sidebar-collapsed' class=(@exercise.hide_file_tree ? '' : 'hidden') data-course_token=@course_token
= render('editor_button', classes: 'btn-block btn-primary btn-sm', data: {:'data-toggle' => 'tooltip', :'data-placement' => 'right'}, icon: 'fa fa-plus-square', id: 'sidebar-collapse-collapsed', label:'', title:t('exercises.editor.expand_action_sidebar'))
- if @exercise.allow_file_creation and not @exercise.hide_file_tree?
@ -6,7 +6,8 @@ div id='sidebar-collapsed' class=(@exercise.hide_file_tree ? '' : 'hidden')
= render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', data: {:'data-toggle' => 'tooltip', :'data-placement' => 'right'}, icon: 'fa fa-download', id: 'download-collapsed', label:'', title: t('exercises.editor.download'))
= render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => reload_exercise_path(@exercise), :'data-toggle' => 'tooltip', :'data-placement' => 'right'}, icon: 'fa fa-history', id: 'start-over-collapsed', label:'', title: t('exercises.editor.start_over'))
= render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', data: {:'data-toggle' => 'tooltip', :'data-placement' => 'right'}, icon: 'fa fa-search', id: 'sidebar-search-collapsed', label: '', title: t('search.search_in_forum'))
- if @course_token
= render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', data: {:'data-toggle' => 'tooltip', :'data-placement' => 'right'}, icon: 'fa fa-search', id: 'sidebar-search-collapsed', label: '', title: t('search.search_in_forum'))
div id='sidebar-uncollapsed' class=(@exercise.hide_file_tree ? 'hidden' : '')
= render('editor_button', classes: 'btn-block btn-primary btn-sm', icon: 'fa fa-minus-square', id: 'sidebar-collapse', label: t('exercises.editor.collapse_action_sidebar'))
@ -25,14 +26,15 @@ div id='sidebar-uncollapsed' class=(@exercise.hide_file_tree ? 'hidden' : '')
= render('editor_button', classes: 'btn-block btn-primary btn-sm enforce-top-margin', icon: 'fa fa-download', id: 'download', label: t('exercises.editor.download'))
= render('editor_button', classes: 'btn-block btn-primary btn-sm', data: {:'data-message-confirm' => t('exercises.editor.confirm_start_over'), :'data-url' => reload_exercise_path(@exercise)}, icon: 'fa fa-history', id: 'start-over', label: t('exercises.editor.start_over'))
= form_for(@search, multipart: true, target: "_blank") do |f|
.input-group.enforce-top-margin
= f.hidden_field :exercise_id
.enforce-right-margin
= f.text_field(:search, class: 'form-control', id: "search-col", required: true, placeholder: t('search.search_in_forum'))
.input-group-btn
= button_tag(class: 'btn btn-primary', id: 'btn-search-col', model: @search.class.model_name.human) do
i.fa.fa-search
- if @course_token
= form_for(@search, multipart: true, target: "_blank") do |f|
.input-group.enforce-top-margin
= f.hidden_field :exercise_id
.enforce-right-margin
= f.text_field(:search, class: 'form-control', id: "search-col", required: true, placeholder: t('search.search_in_forum'))
.input-group-btn
= button_tag(class: 'btn btn-primary', id: 'btn-search-col', model: @search.class.model_name.human) do
i.fa.fa-search
- if @exercise.allow_file_creation?