Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #349 from lakshmivyas/feature/linkqb
Browse files Browse the repository at this point in the history
#345: Add questions with links to exercises section.
  • Loading branch information
jpslav committed Jun 29, 2014
2 parents a23d924 + e100b40 commit 4bc409d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 16 deletions.
14 changes: 13 additions & 1 deletion app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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.


Expand All @@ -19,6 +19,8 @@ def show
if !student.nil?
@student_assignment = StudentAssignment.for_student(student).for_assignment(@assignment).first
end

@include_mathjax = self.authority?
end

def grades
Expand All @@ -28,5 +30,15 @@ def grades
format.xls
end
end

protected

def authority?
@assignment.cohort.klass.is_educator?(present_user) ||
Researcher.is_one?(present_user) ||
present_user.is_administrator?
end



end
3 changes: 1 addition & 2 deletions app/helpers/assignments_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 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.

module AssignmentsHelper
end
4 changes: 2 additions & 2 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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.

class Assignment < ActiveRecord::Base
Expand All @@ -21,7 +21,7 @@ class Assignment < ActiveRecord::Base
before_destroy :destroyable?, prepend: true

attr_accessor :dry_run

def klass
cohort.klass
end
Expand Down
21 changes: 21 additions & 0 deletions app/views/assignments/_questions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +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:
assignment
%>
<% assignment.assignment_plan.assignments.each do |thissignment| %>
<%= sub_section "Cohort: #{thissignment.cohort.name}" do %>
<ol class="cohort-questions">
<% thissignment.assignment_exercises.each do |ae| %>
<% exercise = ae.topic_exercise.exercise %>
<li>
<%= render 'exercises/question', :exercise => exercise, :show_url => true %>
</li>
<% end %>
</ol>
<% end %>
<% end %>
25 changes: 16 additions & 9 deletions app/views/assignments/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# 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. %>
<% addTestMeta {{:page_type => "show"}} %>
Expand All @@ -8,6 +8,9 @@
<%
assignment_plan = @assignment.assignment_plan
klass = @assignment.cohort.klass
authority = @assignment.cohort.klass.is_educator?(present_user) ||
Researcher.is_one?(present_user) ||
present_user.is_administrator?
%>
Expand Down Expand Up @@ -82,20 +85,22 @@
<% end %>
<% end %>
<%= section "Exercises", {:classes => 'no_bar exercises'} do %>
<% if @student_assignment.blank? %>
<p>This assignment has <%= pluralize(@assignment.assignment_exercises.count, "exercise") %>.</p>
<p>You cannot see or work the exercises because they were not assigned to you.</p>
<% else %>
<% if !@student_assignment.blank? %>
<%= section "Your Exercises", {:classes => 'no_bar exercises'} do %>
<%= render :partial => 'student_exercises/list',
:locals => { :student_assignment => @student_assignment,
:show_feedback_status => true } %>
:show_feedback_status => true } %>
<% end %>
<% end %>
<% if authority %>
<%= section "Exercises", {:classes => 'no_bar exercises', :collapsible => true, :collapsed => true} do %>
<p>This assignment has <%= pluralize(@assignment.assignment_exercises.count, "exercise") %>.</p>
<%= render 'questions', :assignment => @assignment %>
<% end %>
<% end %>
<% if klass.is_educator?(present_user) || Researcher.is_one?(present_user) || present_user.is_administrator? %>
<% if authority %>
<%= render 'results', :assignment_plan => assignment_plan %>
<% end %>
Expand All @@ -104,3 +109,5 @@
navitem(:can_read_children?, @assignment, :grades) { link_to "Grades", grades_assignment_path(@assignment, :format => :xls) }
%>



14 changes: 12 additions & 2 deletions app/views/exercises/_question.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<%# 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
<%#
Params:
exercise
show_url: optional. default: false.
%>
<%
question = exercise.content["simple_question"]
show_url = false if local_assigns[:show_url].nil?
%>

<div class="exercise-question">
Expand All @@ -20,5 +25,10 @@
<div class="question question-text">
<%= question["content"]["html"].html_safe %>
</div>
<% if show_url %>
<div class="question question-link">
<a href="<%= exercise['url'] %>" class="question-url"><%= exercise["url"] %></a>
</div>
<% end %>
</div>
</div>

0 comments on commit 4bc409d

Please sign in to comment.