Merge pull request #891 from openHPI/adapt_python_experiments
Adapt python experiments
This commit is contained in:
@ -94,7 +94,7 @@ module SubmissionScoring
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Return all test results except for those of a linter if not allowed
|
# Return all test results except for those of a linter if not allowed
|
||||||
show_linter = Python20CourseWeek.show_linter? submission.exercise, submission.user_id
|
show_linter = Python20CourseWeek.show_linter? submission.exercise
|
||||||
outputs&.reject do |output|
|
outputs&.reject do |output|
|
||||||
next if show_linter || output.blank?
|
next if show_linter || output.blank?
|
||||||
|
|
||||||
|
@ -298,11 +298,6 @@ class ExercisesController < ApplicationController
|
|||||||
else
|
else
|
||||||
current_user.id
|
current_user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
# Tips are collected and set with set_available_tips.
|
|
||||||
# Delete tips for those users who should not see them.
|
|
||||||
# Doing this here is beneficial because all other (admin) routes still work.
|
|
||||||
@tips = nil unless Python20CourseWeek.show_tips? @exercise, current_user.id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_course_token
|
def set_course_token
|
||||||
|
@ -18,7 +18,6 @@ class RequestForCommentsController < ApplicationController
|
|||||||
.with_last_activity
|
.with_last_activity
|
||||||
.ransack(params[:q])
|
.ransack(params[:q])
|
||||||
@request_for_comments = @search.result
|
@request_for_comments = @search.result
|
||||||
.where("question NOT LIKE '%#loesung%'")
|
|
||||||
.joins(:exercise)
|
.joins(:exercise)
|
||||||
.where(exercises: {unpublished: false})
|
.where(exercises: {unpublished: false})
|
||||||
.includes(submission: [:study_group])
|
.includes(submission: [:study_group])
|
||||||
@ -99,8 +98,6 @@ class RequestForCommentsController < ApplicationController
|
|||||||
|
|
||||||
@request_for_comment = RequestForComment.new(request_for_comment_params)
|
@request_for_comment = RequestForComment.new(request_for_comment_params)
|
||||||
|
|
||||||
@request_for_comment.solved = true if @request_for_comment.question.include?('#loesung')
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @request_for_comment.save
|
if @request_for_comment.save
|
||||||
# create thread here and execute tests. A run is triggered from the frontend and does not need to be handled here.
|
# create thread here and execute tests. A run is triggered from the frontend and does not need to be handled here.
|
||||||
|
@ -8,7 +8,7 @@ class RequestForCommentPolicy < ApplicationPolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
admin? || teacher_in_study_group? || author? || everyone && @record.question&.exclude?('#loesung')
|
everyone
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy?
|
def destroy?
|
||||||
|
@ -8,13 +8,7 @@ class Python20CourseWeek
|
|||||||
1
|
1
|
||||||
when /Python20 Aufgabe 2/
|
when /Python20 Aufgabe 2/
|
||||||
2
|
2
|
||||||
when /Python20 Aufgabe 3.1/
|
when /Python20 Aufgabe 3/
|
||||||
nil # Explicitly enable everything (linter + tips if available)!
|
|
||||||
when /Python20 Aufgabe 3.2/
|
|
||||||
3
|
|
||||||
when /Python20 Aufgabe 3.3/
|
|
||||||
3
|
|
||||||
when /Python20 Aufgabe 3.4/
|
|
||||||
3
|
3
|
||||||
when /Python20 Aufgabe 4/
|
when /Python20 Aufgabe 4/
|
||||||
4
|
4
|
||||||
@ -26,19 +20,10 @@ class Python20CourseWeek
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.show_tips?(exercise, user_id)
|
def self.show_linter?(exercise)
|
||||||
week = get_for(exercise)
|
week = get_for(exercise)
|
||||||
return true if week.nil? # Exercise is not part of the experiment
|
return true if week.nil? # Exercise is not part of the experiment
|
||||||
|
|
||||||
user_group = UserGroupSeparator.get_tips_group(user_id)
|
[3, 4].include?(week)
|
||||||
[1, 2].include?(week) && user_group == :show_tips
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.show_linter?(exercise, user_id)
|
|
||||||
week = get_for(exercise)
|
|
||||||
return true if week.nil? # Exercise is not part of the experiment
|
|
||||||
|
|
||||||
user_group = UserGroupSeparator.get_linter_group(user_id)
|
|
||||||
[3].include?(week) && user_group == :show_linter
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class UserGroupSeparator
|
|
||||||
|
|
||||||
# Different user groups for Python20 course based on last digit of the user_id
|
|
||||||
# 0: show_tips && no_linter
|
|
||||||
# 1: no_tips && show_linter
|
|
||||||
# 2: show_tips && show_linter
|
|
||||||
# 3: no_tips && no_linter
|
|
||||||
|
|
||||||
# separates user into 50% no tips, 50% with tips
|
|
||||||
def self.get_tips_group(user_id)
|
|
||||||
user_group = user_id % 4 # => 0, 1, 2, 3
|
|
||||||
if [0, 2].include?(user_group)
|
|
||||||
:show_tips
|
|
||||||
else # [1, 3].include?(user_group)
|
|
||||||
:no_tips
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# separates user into 50% with linter, 50% without linter
|
|
||||||
def self.get_linter_group(user_id)
|
|
||||||
user_group = user_id % 4 # => 0, 1, 2, 3
|
|
||||||
if [1, 2].include?(user_group)
|
|
||||||
:show_linter
|
|
||||||
else # [0, 3].include?(user_group)
|
|
||||||
:no_linter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Reference in New Issue
Block a user