move student quiz results to top of quiz show page

Also moves the quiz results to a temporary, better looking style which
will be removed in a later patchset.

test plan:
  - create a quiz or use an existing quiz.
  - masquerading, make sure some students in the class take the quiz and some
    in the class DO NOT take the quiz.
  - Click "Show Student Quiz Results". You should accurately see
    students who have/haven't takent the quiz in both columns.
  - Now make the students who haven't taken the quiz submit the quiz.
    When you click "Show Student Quiz Results" in the cog menu again,
    you should see something to the effect of "All students have taken
    quiz" on the right and all the students listed by name on the left.
  - Before you leave the page, go to the cog menu again. "Show Student
    Quiz Results" should now be "Hide Student Quiz Results".

  - Create a new quiz and publish it
  - Click "Show Student Quiz Results"
  - You should see no students on the left, but instead a message like
    "No Students have taken the quiz". You should see all the students
    in the course on the right.

Change-Id: I720e78f10784ca1ecc5e316590804427fe7df830
Reviewed-on: https://gerrit.instructure.com/18831
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Stanley Stuart 2013-03-20 15:22:29 -06:00
parent e1a85c2f5f
commit 92de73e94c
5 changed files with 104 additions and 68 deletions

View File

@ -194,7 +194,7 @@ class QuizzesController < ApplicationController
def managed_quiz_data
if authorized_action(@quiz, @current_user, [:grade, :read_statistics])
students = @context.students_visible_to(@current_user).order_by_sortable_name.to_a
students = @context.students_visible_to(@current_user).order_by_sortable_name.to_a.uniq
@submissions = @quiz.quiz_submissions.for_user_ids(students.map(&:id)).where("workflow_state<>'settings_only'").all
submission_ids = {}
@submissions.each{|s| submission_ids[s.user_id] = s.id }

View File

@ -39,11 +39,20 @@ $questionHeaderBackground: #F5F5F5
font-size: 1.3em
#quiz_details
// display: none so jquery ui toggles correctly
display: none
clear: both
margin: 0 auto 10px auto
max-height: 500px
overflow: auto
td
vertical-align: top
.submitted_list
float: left
width: 50%
.name
display: block
padding: 4px 12px
border-top: 1px solid white
.control-group
margin-bottom: 0px
@ -825,15 +834,6 @@ ul#question_list
:font-size 1.2em
:font-weight bold
:color #444
table#quiz_details
:margin-top 10px
h3
:font-weight bold
:font-size 0.9em
ul.student_list
:max-height 300px
:overflow auto
:margin-top 5px
ul#quiz_versions
:margin-top 5px

View File

@ -1,58 +1,72 @@
<table id="quiz_details">
<tr>
<td>
<h3><%= @quiz.survey? ? t('headers.submitted_students_survey', "Students who have taken the survey") : t('headers.submitted_students_quiz', "Students who have taken the quiz") %></h3>
<ul class="student_list submitted">
<% if @submitted_students.empty? %>
<li><%= @quiz.survey? ? t(:survey_no_submissions, "No Students have taken the survey yet") : t(:quiz_no_submissions, "No Students have taken the quiz yet") %></li>
<% end %>
<% @submitted_students.each_with_index do |s, idx| %>
<% submission = @submissions.find{|qs| qs.user_id == s.id} %>
<li class="student" data-id="<%= s.id %>">
<% if submission.pending_review? %>
<i class="icon-warning" title="<%= t('titles.submission_needs_review', "This submission needs review") %>"></i>
<% end %>
<a href="<%= context_url(@context, :context_quiz_history_url, @quiz, :quiz_submission_id => submission.id) %>" class="name">
<% if @quiz.survey? && @quiz.anonymous_submissions %>
<%= t(:anonymous_student, "Student %{n}", :n => idx + 1) %>
<% else %>
<%= s.name %>
<% end %>
</a>
</li>
<% end %>
</ul>
</td>
<td style="padding-left: 20px;">
<% if @quiz.survey? && @quiz.anonymous_submissions %>
<h3>
<%= render_unsubmitted_students(@unsubmitted_students.length) %>
</h3>
<% else %>
<h3>
<% if @quiz.survey? %>
<%= t('headers.survey_unsubmitted_students', "Students who haven't taken the survey") %>
<% else %>
<%= t('headers.quiz_unsubmitted_students', "Students who haven't taken the quiz") %>
<% end %>
</h3>
<ul class="student_list">
<% if @unsubmitted_students.empty? && !@submitted_students.empty? %>
<li>
<div id="quiz_details" class="clearfix">
<div class="student_list">
<div class="list-view border border-trbl submitted_list">
<header>
<% if @quiz.survey? %>
<%= t(:survey_all_students_submitted, "All Students have taken the survey") %>
<%= t('headers.submitted_students_survey', "Students who have taken the survey") %>
<% else %>
<%= t(:quiz_all_students_submitted, "All Students have taken the quiz") %>
<%= t('headers.submitted_students_quiz', "Students who have taken the quiz") %>
<% end %>
</li>
</header>
<ul class="quiz_results_list">
<% if @submitted_students.empty? %>
<li>
<span class="name">
<%= @quiz.survey? ?
t(:survey_no_submissions, "No Students have taken the survey yet") :
t(:quiz_no_submissions, "No Students have taken the quiz yet")
%>
</span>
</li>
<% end %>
<% @submitted_students.each_with_index do |s, idx| %>
<% submission = @submissions.find{|qs| qs.user_id == s.id} %>
<li class="student" data-id="<%= s.id %>">
<a href="<%= context_url(@context, :context_quiz_history_url, @quiz, :quiz_submission_id => submission.id) %>" class="name">
<% if submission.pending_review? %>
<i class="icon-warning" title="<%= t('titles.submission_needs_review', "This submission needs review") %>"></i>
<% end %>
<% if @quiz.survey? && @quiz.anonymous_submissions %>
<%= t(:anonymous_student, "Student %{n}", :n => idx + 1) %>
<% else %>
<%= s.name %>
<% end %>
</a>
</li>
<% end %>
<% @unsubmitted_students.each do |s| %>
<li class="student" data-id="<%= s.id %>">
<span class="name"><%= s.name %></span>
</li>
<% end %>
</ul>
</ul>
</div>
<div class="list-view border border-trbl">
<% if @quiz.survey? && @quiz.anonymous_submissions %>
<header>
<%= render_unsubmitted_students(@unsubmitted_students.length) %>
</header>
<% else %>
<header>
<% if @quiz.survey? %>
<%= t('headers.survey_unsubmitted_students', "Students who haven't taken the survey") %>
<% else %>
<%= t('headers.quiz_unsubmitted_students', "Students who haven't taken the quiz") %>
<% end %>
</header>
<ul class="student_list">
<% if @unsubmitted_students.empty? && !@submitted_students.empty? %>
<li><span class="name">
<% if @quiz.survey? %>
<%= t(:survey_all_students_submitted, "All Students have taken the survey") %>
<% else %>
<%= t(:quiz_all_students_submitted, "All Students have taken the quiz") %>
<% end %>
</span></li>
<% end %>
<% @unsubmitted_students.each do |s| %>
<li class="student" data-id="<%= s.id %>">
<span class="name"><%= s.name %></span>
</li>
<% end %>
</ul>
<% end %>
</td>
</tr>
</table>
</div>
</div>
</div>

View File

@ -221,6 +221,9 @@
</h3>
<% end %>
<% if @quiz.available? %>
<div id="quiz_details_wrapper" data-url="<%= course_quiz_managed_quiz_data_url(@context.id, @quiz.id) %>" data-submitted-count="<%= @submitted_student_count %>"></div>
<% end %>
<% if can_do(@quiz, @current_user, :update) || can_do(@quiz, @current_user, :manage) %>
<%= render :partial => 'quiz_show_teacher' %>
<% else %>
@ -228,7 +231,6 @@
<% end %>
<% if @quiz.available? %>
<div id="quiz_details_wrapper" data-url="<%= course_quiz_managed_quiz_data_url(@context.id, @quiz.id) %>" data-submitted-count="<%= @submitted_student_count %>"></div>
<% if !@submission || !@submission.completed? || @quiz.unlimited_attempts? || (@submission.completed? && @submission.attempts_left > 0) %>
<% if @locked && !can_do(@quiz, @current_user, :update) %>

View File

@ -101,11 +101,31 @@ $(document).ready(function () {
}
});
});
var hasOpenedQuizDetails = false;
$(".quiz_details_link").click(function(event) {
event.preventDefault();
$(this).disableWhileLoading(
$("#quiz_details_wrapper").disableWhileLoading(
ensureStudentsLoaded(function() {
var $quizResultsText = $('#quiz_results_text');
$("#quiz_details").slideToggle();
if (hasOpenedQuizDetails) {
if (ENV.IS_SURVEY) {
$quizResultsText.text(I18n.t('links.show_student_survey_results',
'Show Student Survey Results'));
} else {
$quizResultsText.text(I18n.t('links.show_student_quiz_results',
'Show Student Quiz Results'));
}
} else {
if (ENV.IS_SURVEY) {
$quizResultsText.text(I18n.t('links.hide_student_survey_results',
'Hide Student Survey Results'));
} else {
$quizResultsText.text(I18n.t('links.hide_student_quiz_results',
'Hide Student Quiz Results'));
}
}
hasOpenedQuizDetails = !hasOpenedQuizDetails;
})
);
});