Skip to content

Commit

Permalink
lml#340: Add exercise content to feedback page.
Browse files Browse the repository at this point in the history
- Reuse exercise blurb from assignment_exercise.
- Remove redundant `if true` statements.
- Add boolean flags for showing correct answer and choices.
- Use defined check to provide defaults for boolean values.
  • Loading branch information
navilan committed May 20, 2014
1 parent 049adcb commit 1a2f137
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
4 changes: 3 additions & 1 deletion app/views/assignment_exercises/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

<% exercise = @assignment_exercise.topic_exercise.exercise %>

<%= render 'exercises/exercise_blurb', :exercise => exercise %>
<%= render 'exercises/exercise_blurb', :exercise => exercise,
:show_correct_answer => true,
:show_choices => true %>

<% all_responses = @assignment_exercise.student_exercises %>

Expand Down
20 changes: 20 additions & 0 deletions app/views/exercises/_exercise_blurb.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public
License version 3 or later. See the COPYRIGHT file for details. %>

<%#
Params:
show_correct_answer: optional. default: false
show_choices: optional. defailt: false
%>

<%
show_correct_answer = false if local_assigns[:show_correct_answer].nil?
show_choices = false if local_assigns[:show_choices].nil?

%>

<%= render :partial => 'exercises/question',
:layout => 'layouts/section',
:locals => {
Expand All @@ -11,6 +26,7 @@
} %>


<% if show_correct_answer %>
<%= render :partial => 'exercises/correct_answer',
:layout => 'layouts/section',
:locals => {
Expand All @@ -20,8 +36,11 @@
:collapsed => false,
:classes => 'first no_bar'
} %>
<% end %>



<% if show_choices %>
<%= render :partial => 'exercises/choices',
:layout => 'layouts/section',
:locals => {
Expand All @@ -30,3 +49,4 @@
:collapsed => true,
:classes => 'first no_bar'
} %>
<% end %>
8 changes: 4 additions & 4 deletions app/views/layouts/_section.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Params:
%>

<%
section_name ||= 'Section'
collapsed ||= false
collapsible ||= defined? collapsed
classes ||= ''
section_name = 'Section' if local_assigns[:section_name].nil?
collapsed = false if local_assigns[:collapsed].nil?
collapsible = defined? collapsed if local_assigns[:collapsible].nil?
classes = '' if local_assigns[:classes].nil?

%>

Expand Down
18 changes: 10 additions & 8 deletions app/views/student_exercises/feedback.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public
License version 3 or later. See the COPYRIGHT file for details. %>

<%= pageHeading("Feedback on #{@student_exercise.assignment.assignment_plan.name}, " +
"Exercise #{@student_exercise.assignment_exercise.number}",
{:sub_heading_text => @student_exercise.student_assignment.student.section.klass.name})%>
<% learning_condition = @student_exercise.learning_condition %>
<%
exercise = @student_exercise.assignment_exercise.topic_exercise.exercise
learning_condition = @student_exercise.learning_condition
%>

<% if true %>
<%= render :partial => "student_answer", :locals => { :student_exercise => @student_exercise } %>
<% end %>
<%= render 'exercises/exercise_blurb', :exercise => exercise,
:show_choices => true %>

<%= render :partial => "student_answer", :locals => { :student_exercise => @student_exercise } %>

<% if learning_condition.show_correctness_feedback?(@student_exercise) %>
<%= render :partial => "correctness_feedback", :locals => { :student_exercise => @student_exercise } %>
Expand All @@ -18,9 +22,7 @@
<%= render :partial => "correct_answer_feedback", :locals => { :student_exercise => @student_exercise } %>
<% end %>

<% if true %>
<%= render :partial => "solution_feedback", :locals => { :student_exercise => @student_exercise } %>
<% end %>
<%= render :partial => "solution_feedback", :locals => { :student_exercise => @student_exercise } %>

<%= render :partial => 'shared/response_times',
:locals => {:response_timeable => @student_exercise,
Expand Down

0 comments on commit 1a2f137

Please sign in to comment.