From f7fe45c20cb4a946956599b82ecb3c1c539d59b6 Mon Sep 17 00:00:00 2001 From: lakshmivyas Date: Thu, 12 Jun 2014 20:28:51 +0530 Subject: [PATCH] lml/ost#346: Make feedback penalty configurable. - Add feedback penalty field to the settings store. - Add feedback penalty to show and edit views. - Add JS to show / hide penalty based on feedback required. - Add help file for @kjdav with some help text. - Ensure score detail page does not need any updates. --- .../javascripts/learning_conditions.js.coffee | 11 +++++++++++ app/models/feedback_condition.rb | 18 +++++++++++++++--- .../feedback_conditions/_form_fields.html.erb | 13 +++++++++++-- app/views/feedback_conditions/_show.html.erb | 1 + .../blurbs/_feedback_viewing_penalty.html.erb | 10 ++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 app/views/help/blurbs/_feedback_viewing_penalty.html.erb diff --git a/app/assets/javascripts/learning_conditions.js.coffee b/app/assets/javascripts/learning_conditions.js.coffee index 38fbfc95..97bc1419 100644 --- a/app/assets/javascripts/learning_conditions.js.coffee +++ b/app/assets/javascripts/learning_conditions.js.coffee @@ -4,3 +4,14 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ +$ () -> + feedbackRequired = $(".field.feedback-required input") + feedbackRequired.click () -> + feedbackPenalty = $ ".field.feedback-viewing-penalty" + feedbackPenaltyValue = feedbackPenalty.find "input" + if feedbackRequired.is ':checked' + feedbackPenaltyValue.val("100"); + feedbackPenalty.show() + else + feedbackPenaltyValue.val("0"); + feedbackPenalty.hide() diff --git a/app/models/feedback_condition.rb b/app/models/feedback_condition.rb index a4f384b7..a1b9712f 100644 --- a/app/models/feedback_condition.rb +++ b/app/models/feedback_condition.rb @@ -9,6 +9,7 @@ class FeedbackCondition < ActiveRecord::Base store_accessor :settings, :label_regex store_typed_accessor :settings, :integer, :exercise_correctness_option store_typed_accessor :settings, :boolean, :is_feedback_required_for_credit + store_typed_accessor :settings, :integer, :feedback_viewing_penalty store_typed_accessor :settings, :boolean, :can_automatically_show_feedback store_typed_accessor :settings, :integer, :availability_opens_option store_typed_accessor :settings, :float, :availability_opens_delay_days @@ -30,11 +31,18 @@ class FeedbackCondition < ActiveRecord::Base :credit_closes_option, :credit_closes_delay_days, :can_automatically_show_feedback, :show_correctness_feedback, :show_correct_answer_feedback, - :show_high_level_feedback, :show_detailed_feedback + :show_high_level_feedback, :show_detailed_feedback, + :feedback_viewing_penalty after_initialize :supply_missing_values before_validation :strip_regex, :nil_out_blank_regex + validates :feedback_viewing_penalty, allow_nil: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 100 + } + validates :availability_opens_delay_days, allow_nil: true, numericality: { greater_than: 0 } @@ -49,7 +57,7 @@ class FeedbackCondition < ActiveRecord::Base validate :not_applicable_event_only_for_never validate :feedback_cannot_close_if_never_opened validate :feedback_must_open_if_needed_for_credit - + class AvailabilityOpensOption < Enum NEVER = 0 IMMEDIATELY_AFTER_EVENT = 1 @@ -83,6 +91,7 @@ def self.standard_practice_feedback_condition FeedbackCondition.new(:label_regex => 'standard practice', :exercise_correctness_option => ExerciseCorrectnessOption::ANY_CORRECTNESS.to_s, :is_feedback_required_for_credit => false.to_s, + :feedback_viewing_penalty => 0.to_s, :availability_opens_option => AvailabilityOpensOption::IMMEDIATELY_AFTER_EVENT.to_s, :availability_closes_option => AvailabilityClosesOption::NEVER.to_s, :availability_event => AvailabilityEvent::EXERCISE_COMPLETE.to_s, @@ -97,6 +106,7 @@ def self.new_feedback_condition FeedbackCondition.new(:label_regex => 'NewFeedback', :exercise_correctness_option => ExerciseCorrectnessOption::ANY_CORRECTNESS.to_s, :is_feedback_required_for_credit => false.to_s, + :feedback_viewing_penalty => 0.to_s, :availability_opens_option => AvailabilityOpensOption::IMMEDIATELY_AFTER_EVENT.to_s, :availability_closes_option => AvailabilityClosesOption::NEVER.to_s, :availability_event => AvailabilityEvent::EXERCISE_COMPLETE.to_s, @@ -111,6 +121,7 @@ def self.default_feedback_condition FeedbackCondition.new(:label_regex => 'DefaultFeedback', :exercise_correctness_option => ExerciseCorrectnessOption::ANY_CORRECTNESS.to_s, :is_feedback_required_for_credit => false.to_s, + :feedback_viewing_penalty => 0.to_s, :availability_opens_option => AvailabilityOpensOption::IMMEDIATELY_AFTER_EVENT.to_s, :availability_closes_option => AvailabilityClosesOption::NEVER.to_s, :availability_event => AvailabilityEvent::EXERCISE_COMPLETE.to_s, @@ -261,6 +272,7 @@ def supply_missing_values self.label_regex ||= '.*' self.exercise_correctness_option ||= ExerciseCorrectnessOption::ANY_CORRECTNESS self.is_feedback_required_for_credit ||= false + self.feedback_viewing_penalty ||= 0 self.availability_opens_option ||= AvailabilityOpensOption::NEVER self.availability_closes_option ||= AvailabilityClosesOption::NEVER self.availability_event ||= AvailabilityEvent::NOT_APPLICABLE @@ -303,7 +315,7 @@ def schedule_feedback_availability_notification(student_exercise, event) def adjust_credit(student_exercise, event) if StudentExercise::Event::COMPLETE == event - student_exercise.update_feedback_credit_multiplier!(is_feedback_required_for_credit ? 0 : 1) + student_exercise.update_feedback_credit_multiplier!(is_feedback_required_for_credit ? feedback_viewing_penalty/100 : 0) end if StudentExercise::Event::FEEDBACK_VIEWED == event diff --git a/app/views/feedback_conditions/_form_fields.html.erb b/app/views/feedback_conditions/_form_fields.html.erb index 2205d912..97eeb501 100644 --- a/app/views/feedback_conditions/_form_fields.html.erb +++ b/app/views/feedback_conditions/_form_fields.html.erb @@ -19,10 +19,19 @@ The assignment event to use when determining feedback availability: <%= form.select :exercise_correctness_option, exercise_correctness_options %> -
+ +
<%= form.check_box :can_automatically_show_feedback %> The site can automatically present students with feedback if other conditions are met. <%#<%= link_to_help 'auto_feedback' %> @@ -96,4 +105,4 @@ FeedbackCondition::AvailabilityClosesOption, :DELAY_AFTER_OPEN %> of <%= form.text_field :availability_closes_delay_days, :size => 4 %> days

-
\ No newline at end of file + diff --git a/app/views/feedback_conditions/_show.html.erb b/app/views/feedback_conditions/_show.html.erb index d530eee6..eb9f83f2 100644 --- a/app/views/feedback_conditions/_show.html.erb +++ b/app/views/feedback_conditions/_show.html.erb @@ -7,6 +7,7 @@
  • Matches labels against: <%= feedback_condition.label_regex || "[Not set]" %>
  • Matches correctness against: <%= FeedbackCondition::ExerciseCorrectnessOption[feedback_condition.exercise_correctness_option].to_s.humanize %>
  • Feedback viewing is required?: <%= tf_to_yn(feedback_condition.is_feedback_required_for_credit) %>
  • +
  • Feedback viewing penalty: <%= feedback_condition.feedback_viewing_penalty || 0 %>%
  • Can automatically show feedback?: <%= tf_to_yn(feedback_condition.can_automatically_show_feedback) %>
  • Feedback becomes available: <%= diff --git a/app/views/help/blurbs/_feedback_viewing_penalty.html.erb b/app/views/help/blurbs/_feedback_viewing_penalty.html.erb new file mode 100644 index 00000000..fc7456f7 --- /dev/null +++ b/app/views/help/blurbs/_feedback_viewing_penalty.html.erb @@ -0,0 +1,10 @@ +<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public + License version 3 or later. See the COPYRIGHT file for details. %> + +<%# TODO: @Kim %> + +

    + This field allows you to configure the credit penalty in percentage. For example, if + you set a value of 25%, then students lose 25% of their credit if they fail to view + their feedback on time. +