This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/exercises #348
Merged
Merged
Feature/exercises #348
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
334c629
Document installation guide for rbenv.
navilan 049adcb
lml/ost#341: Add assignment exercise view.
navilan 1a2f137
lml/ost#340: Add exercise content to feedback page.
navilan 437adeb
lml/ost#340: Show free responses in student feedback.
navilan b75051b
lml/ost#341: Fix multiple choice styles.
navilan 31283a5
lml/ost#341: Add sidebar nav for assignment exercises.
navilan 98b2966
lml/ost#341: Sort and group responsese by student status.
navilan 321d55d
lml/ost#341: Add multiple cohort support.
navilan 499da19
lml/ost#341: Add prev/next method to ActAsNumberable.
navilan 46b55f0
lml/ost#341: Rewrite the query to actually sort the students.
navilan a7f63c8
lml/ost#341: Fix redundant joins.
navilan ee8cff9
lml/ost#341: Fix code style and formatting.
navilan c8ea5a1
lml/ost#341: Fix prev/next navigation query and some UI issues.
navilan 0eddeeb
lml/ost#341: Remove hardcoded SQL.
navilan 42508d9
lib/ost#341: Use sifters for better encapsulation.
navilan 85a7325
lml/ost#341: Ensure prev/next methods are available for all instances.
navilan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ db/.data.yml.gz | |
brakeman.html | ||
cucumber_rerun.txt | ||
rspec.failures | ||
vendor/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.9.3-p194 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
# License version 3 or later. See the COPYRIGHT file for details. | ||
|
||
|
||
class AssignmentExercisesController < ApplicationController | ||
|
||
def show | ||
@assignment_exercises = AssignmentExercise.find(params[:id]).topic_exercise.assignment_exercises | ||
raise SecurityTransgression unless present_user.can_read?(@assignment_exercises.first) | ||
@include_mathjax = true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
License version 3 or later. See the COPYRIGHT file for details. %> | ||
|
||
<%# | ||
|
||
Params: | ||
responses: required. | ||
|
||
%> | ||
<table class="list" width="90%"> | ||
<thead> | ||
<tr> | ||
<th width="8%">Student</th> | ||
<th width="60%">Response</th> | ||
<th width="8%">Choice</th> | ||
<th width="8%">Score</th> | ||
<th width="8%">Times</th> | ||
</tr> | ||
<thead> | ||
<tbody> | ||
<% responses.each_with_index do |se, ii| %> | ||
<% student = se.student_assignment.student %> | ||
<tr> | ||
<td> | ||
<%= link_to student.full_name(present_user), se.student_assignment %> | ||
</td> | ||
<td> | ||
<div class='free_response'> | ||
<%= '(blank)' if se.free_responses.none? %> | ||
<% se.free_responses.each do |free_response| %> | ||
<%= render :partial => 'free_responses/show', | ||
:locals => { :free_response => free_response } %> | ||
<% end %> | ||
</div> | ||
<% if se.requires_follow_up_question? %> | ||
<div class='follow_up_question'> | ||
<%= se.follow_up_answer || '(blank)' %> | ||
</div> | ||
<% end %> | ||
</td> | ||
<td><%= se.selected_answer.nil? ? "--" : "(#{choice_letter(se.selected_answer)})" %></td> | ||
<td><%= link_to se.score, student_exercise_score_detail_path(se), :remote => true %></td> | ||
<td> | ||
<%= link_to_function "Show", "$('#se_#{ii}_rts').show(); $(this).hide(); $(this).next().show(); " %> | ||
<%= link_to_function "Hide", "$('#se_#{ii}_rts').hide(); $(this).hide(); $(this).prev().show(); ", :style => "display:none" %> | ||
</td> | ||
</tr> | ||
<tr id="se_<%= ii %>_rts" style="display:none"> | ||
<td></td> | ||
<td colspan="4"> | ||
<%= render :partial => 'response_times/list', | ||
:locals => {:response_times => se.response_times, :show_page => true} %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
License version 3 or later. See the COPYRIGHT file for details. %> | ||
|
||
<% | ||
assignment_exercise = @assignment_exercises.first | ||
exercise = assignment_exercise.topic_exercise.exercise | ||
%> | ||
<%= pageHeading("Student responses for | ||
Assignment: #{assignment_exercise.assignment.assignment_plan.name}, | ||
Exercise: #{assignment_exercise.number}", | ||
{:sub_heading_text => full_class_name(assignment_exercise.assignment)}) %> | ||
|
||
|
||
<%= render 'exercises/exercise_blurb', :exercise => exercise, | ||
:show_correct_answer => true, | ||
:show_choices => true %> | ||
|
||
<%= section "Responses", :classes => 'section-exercise-responses no_bar' do %> | ||
|
||
NOTE: In the 'Response' column, free responses are always shown. If | ||
required by the learning conditions, follow-up answers appear in | ||
gray below the free responses. In both cases, a missing response | ||
will be depicted by the string '(blank)'. | ||
|
||
<% @assignment_exercises.each do |ae| %> | ||
<%= section "Cohort: #{ae.assignment.cohort.name}" do %> | ||
<% exercises = ae.student_exercises_by_student_status(present_user) %> | ||
<% exercises.each do |status, lst| %> | ||
<% if !lst.nil? && lst.count > 0 %> | ||
<% message = "From #{status} students" %> | ||
<%= render :partial => 'response_list', | ||
:layout => 'layouts/section', | ||
:locals => {:responses => lst, | ||
:classes => 'no_bar', | ||
:section_name => message } %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% end %> | ||
|
||
<% prev_ae = assignment_exercise.prev %> | ||
<% next_ae = assignment_exercise.next %> | ||
<% | ||
navitem { link_to "Class", klass_path(assignment_exercise.assignment.klass) } | ||
navitem { link_to "Assignment", assignment_path(assignment_exercise.assignment) } | ||
if !prev_ae.nil? | ||
navitem { link_to "Previous Exercise", assignment_exercise_path(prev_ae) } | ||
end | ||
if !next_ae.nil? | ||
navitem { link_to "Next Exercise", assignment_exercise_path(next_ae) } | ||
end | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
License version 3 or later. See the COPYRIGHT file for details. %> | ||
|
||
<%# | ||
|
||
Params: | ||
|
||
exercise: required | ||
mark_correct: optional. Marks the correct answer with a class. default: false. | ||
%> | ||
|
||
<% | ||
exercise_data = exercise.content | ||
solution = exercise.correct_choice_index | ||
mark_correct = false if local_assigns[:mark_correct].nil? | ||
%> | ||
|
||
<div class:="question multiple-choice"> | ||
<ul class="unstyled"> | ||
<% exercise_data["simple_question"]["answer_choices"].each_with_index do |answer_choice, ii| %> | ||
<li class="row <% if mark_correct && solution == ii %>correct-answer<% end %>"> | ||
<div class="choice-letter span1"><%= choice_letter(ii) %>)</div> | ||
<div class="answer-choice span6 text-left"><%= answer_choice["html"].html_safe %></div> | ||
<li> | ||
<% end %> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
License version 3 or later. See the COPYRIGHT file for details. %> | ||
|
||
<%# | ||
|
||
Params: | ||
|
||
exercise: required. | ||
phrase: required. | ||
|
||
%> | ||
|
||
<% | ||
solution = exercise.correct_choice_index | ||
%> | ||
|
||
<div class="exercise-answer"> | ||
<p><%= phrase %> <b>(<%= choice_letter(solution) %>)</b></p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<%# 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 => { | ||
:exercise => exercise, | ||
:section_name => "Exercise", | ||
:collapsed => false, | ||
:classes => 'first no_bar' | ||
} %> | ||
|
||
|
||
<% if show_correct_answer %> | ||
<%= render :partial => 'exercises/correct_answer', | ||
:layout => 'layouts/section', | ||
:locals => { | ||
:phrase => 'The correct answer is:', | ||
:exercise => exercise, | ||
:section_name => "Correct Answer", | ||
:collapsed => false, | ||
:classes => 'first no_bar' | ||
} %> | ||
<% end %> | ||
|
||
|
||
|
||
<% if show_choices %> | ||
<%= render :partial => 'exercises/choices', | ||
:layout => 'layouts/section', | ||
:locals => { | ||
:exercise => exercise, | ||
:section_name => "Answer Choices", | ||
:collapsed => true, | ||
:classes => 'first no_bar' | ||
} %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<%# Copyright 2011-2014 Rice University. Licensed under the Affero General Public | ||
License version 3 or later. See the COPYRIGHT file for details. %> | ||
|
||
<%# Clients must supply: | ||
exercise | ||
%> | ||
|
||
<% | ||
question = exercise.content["simple_question"] | ||
%> | ||
|
||
<div class="exercise-question"> | ||
<div class="question question-box"> | ||
<div class="question intro"> | ||
<% if !question["introduction"].nil? %> | ||
<%= question["introduction"]["html"].html_safe %> | ||
<% end %> | ||
</div> | ||
|
||
<div class="question question-text"> | ||
<%= question["content"]["html"].html_safe %> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just replace merge with a subquery using IN and you don't need all this handcoded SQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dantemss - I need to order the resulting student exercises by the student last name and student status - so, having the students in the subquery won't be sufficient. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid any hand-coded SQL. Even if we need to break the query up into steps, I'd rather keep the queries only using the abstracted query syntax provided by Rails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the query I get from the above:
This is exactly the query that's needed. I can understand the avoid handcoded sql argument. But don't you guys think in this scenario (where rails is unable to produce the optimal sql output) - judicious sprinkling of handcoded sql makes for a performant page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the one for researchers:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - makes sense. I will try the
:visible
route. Since we are bringing the consent logic here - it seems like good idea.On that note, @jpslav / @Dantemss - good idea to think about AcsAsConsentable or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean making a new gem? Probably not for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something in the lib dir (like ActsAsNumberable). But yeah - there are just two occurrences, I guess we can wait until there is one more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree we should hold off on library-ifying the consenting infrastructure. The only user at this point is Tutor. Maybe when we redo Tutor it'll make sense to abstract the consent stuff into a gem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a whole mess of consenting infrastructure around, so a gem is the right idea just don't know if we're at the point where we want to spend time consolidating and generalizing it.