Skip to content

Commit

Permalink
fixes #187
Browse files Browse the repository at this point in the history
  • Loading branch information
s-edwards committed Feb 10, 2021
1 parent 16d1db1 commit a6ccf5c
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 169 deletions.
4 changes: 2 additions & 2 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ html, body { height: 100%; }
padding-left: 0px;
padding-right: 0px;
}
.content, .maincol {
padding-bottom: 40px;
.content .inner, .maincol {
padding-bottom: 60px;
}
.content {
h1.left-padded {
Expand Down
329 changes: 165 additions & 164 deletions app/views/exercises/practice.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,176 +5,177 @@
= javascript_include_tag('timeout')
= javascript_include_tag("two_column_layout")
= javascript_include_tag("practice")
.col-12
%h1
= @exercise.display_name
- if current_user.andand.can? :edit, @exercise
%small
= link_to "", edit_exercise_path(@exercise), class: 'glyphicon glyphicon-pencil'
- if @exercise_version.stem && !@exercise_version.stem.preamble.blank?
- cache @exercise_version.stem do
= markdown @exercise_version.stem.preamble
-#
This loop repeats the one below in the answer column, so that the
prompt can go up top in the full-width div. This is broken, since it
will really only work for single-part exercises and will look bad for
multi-part exercises ... but we don't have real support for multi-part
exercises yet anyway.
- @exercise_version.prompts.each do |question_prompt|
- cache question_prompt do
= markdown question_prompt.question
- prompt = question_prompt.specific
- if prompt.is_coding?
- if !prompt.hide_examples && prompt.examples.any?
%p Examples:
%pre.examples
- prompt.examples.each do |example|
= example.display_description
%br
.col-md-7#user-deadline{ data: { deadline: @user_deadline, server_now: @server_now } }
%h2 Your Answer:
= semantic_form_for @exercise_version,
url: (@workout_offering ? organization_workout_offering_exercise_evaluate_path(id: @exercise_version.exercise.id,
course_id: @workout_offering.course_offering.course.slug,
organization_id: @workout_offering.course_offering.course.organization.slug,
term_id: @workout_offering.course_offering.term.slug,
workout_offering_id: @workout_offering.id,
lti_launch: @lti_launch) : exercise_evaluate_path(@exercise_version.exercise,
exercise_version_id: @exercise_version.id,
workout_id: @workout.andand.id,
feedback_return: true, lti_launch: @lti_launch,
lis_result_sourcedid: @workout_score.andand.lis_result_sourcedid,
lis_outcome_service_url: @workout_score.andand.lis_outcome_service_url)), remote: true do |f|
= f.semantic_errors
- if @msg
#timer.alert.alert-warning
= "#{@msg}"
#attempts-left
= render 'attempts_left', attempts_left: @attempts_left
- allow_write = true
- coding_questions = false
.row
.col-md-12
%h1
= @exercise.display_name
- if current_user.andand.can? :edit, @exercise
%small
= link_to "", edit_exercise_path(@exercise), class: 'glyphicon glyphicon-pencil'
- if @exercise_version.stem && !@exercise_version.stem.preamble.blank?
- cache @exercise_version.stem do
= markdown @exercise_version.stem.preamble
-#
This loop repeats the one below in the answer column, so that the
prompt can go up top in the full-width div. This is broken, since it
will really only work for single-part exercises and will look bad for
multi-part exercises ... but we don't have real support for multi-part
exercises yet anyway.
- @exercise_version.prompts.each do |question_prompt|
- cache question_prompt do
= markdown question_prompt.question
- prompt = question_prompt.specific
- if prompt.is_mcq?
- answers = @exercise_version.serve_choice_array(question_prompt)
- answers.each do |a|
- a[:answer] = markdown(a[:answer])
- answer = Choice.new
- if prompt.allow_multiple
%h2 Choose ALL that apply:
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :check_boxes,
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
selected: false,
label: ' '
- elsif @exercise_version.prompts.count > 1
%h3 Select only one answer for each of the sub-questions:
- if prompt.is_coding?
- if !prompt.hide_examples && prompt.examples.any?
%p Examples:
%pre.examples
- prompt.examples.each do |example|
= example.display_description
%br
.col-md-7#user-deadline{ data: { deadline: @user_deadline, server_now: @server_now } }
%h2 Your Answer:
= semantic_form_for @exercise_version,
url: (@workout_offering ? organization_workout_offering_exercise_evaluate_path(id: @exercise_version.exercise.id,
course_id: @workout_offering.course_offering.course.slug,
organization_id: @workout_offering.course_offering.course.organization.slug,
term_id: @workout_offering.course_offering.term.slug,
workout_offering_id: @workout_offering.id,
lti_launch: @lti_launch) : exercise_evaluate_path(@exercise_version.exercise,
exercise_version_id: @exercise_version.id,
workout_id: @workout.andand.id,
feedback_return: true, lti_launch: @lti_launch,
lis_result_sourcedid: @workout_score.andand.lis_result_sourcedid,
lis_outcome_service_url: @workout_score.andand.lis_outcome_service_url)), remote: true do |f|
= f.semantic_errors
- if @msg
#timer.alert.alert-warning
= "#{@msg}"
#attempts-left
= render 'attempts_left', attempts_left: @attempts_left
- allow_write = true
- coding_questions = false
- @exercise_version.prompts.each do |question_prompt|
- prompt = question_prompt.specific
- if prompt.is_mcq?
- answers = @exercise_version.serve_choice_array(question_prompt)
- answers.each do |a|
- a[:answer] = markdown(a[:answer])
- answer = Choice.new
- if prompt.allow_multiple
%h2 Choose ALL that apply:
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :check_boxes,
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
selected: false,
label: ' '
- elsif @exercise_version.prompts.count > 1
%h3 Select only one answer for each of the sub-questions:
- prior_answer = @attempt && @attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer
- answer = prior_answer.specific.choices.first || answer
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :radio,
input_html: {name: "prompt-" + prompt.id.to_s},
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
label: ' '
- else
%h3 Select one answer:
- prior_answer = @attempt && @attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer
- answer = prior_answer.specific.choices.first || answer
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :radio,
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
label: ' '
- elsif prompt.is_coding?
- coding_questions = true
- prior_answer = @attempt && @attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer
- answer = prior_answer.specific.choices.first || answer
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :radio,
input_html: {name: "prompt-" + prompt.id.to_s},
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
label: ' '
- else
%h3 Select one answer:
- prior_answer = @attempt && @attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer
- answer = prior_answer.specific.choices.first || answer
.answers
= f.semantic_fields_for answer do |p|
= p.input :id,
as: :radio,
collection: answers,
member_value: :id,
member_label: Proc.new{ |p| "#{p[:answer]}".html_safe },
label: ' '
- elsif prompt.is_coding?
- coding_questions = true
- prior_answer = @attempt && @attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if !prior_answer && @workout_offering.andand.continue_from_workout
- prior_score = @workout_offering.continue_from_workout.score_for(@student_user)
- prior_attempt = prior_score.previous_attempt_for(@exercise_version.exercise)
- prior_answer = prior_attempt && prior_attempt.prompt_answers.where(prompt: prompt.acting_as).first
// Getting this user's latest attempt on the exercise in the gym
- if !prior_answer && !@workout_score
- prior_attempt = @exercise.latest_attempt_for(current_user)
- prior_answer = prior_attempt && prior_attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer && @workout_offering
- if !@workout_offering.can_be_practiced_by?(current_user)
- allow_write = false
- if allow_write && params[:review_user_id].nil?
= f.input :answer_code, as: :text, class: 'code',
input_html: { class: 'code', readonly: true, autofocus: true,
value: prior_answer ? prior_answer.specific.answer : prompt.prepare_starter_code,
data: { lang: 'text/x-' + (@exercise.language + (@exercise.language == 'C++'?'src':'')|| 'java').downcase,
starter_code: prompt.prepare_starter_code } }
- else
%pre{ data: { lang: 'text/x-java' } }
= prior_answer ? prior_answer.specific.answer : prompt.prepare_starter_code
.actions
- disabled = !current_user.andand.is_staff?(@workout_offering.andand.course_offering) && @attempts_left && @attempts_left == 0
- if @workout_offering.nil? || @workout_offering.can_be_practiced_by?(current_user)
- if @workout_offering.andand.workout_policy.andand.hide_feedback_before_finish && params[:review_user_id].nil?
= f.submit 'Save my answer!',
class: 'btn btn-primary btn-submit',
id: 'primarybtn', disabled: disabled
- elsif allow_write && params[:review_user_id].nil?
= f.submit 'Check my answer!',
class: 'btn btn-primary btn-submit',
id: 'primarybtn', disabled: disabled
- if coding_questions
%div.btn.btn-default{ data: { toggle: 'modal', target: '#confirm-reset' } } Reset
-if @exercise.tag_list.include? 'Visualizable'
-if @workout
-if @workout_offering
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: @workout.id, workout_offering: @workout_offering.id}} Visualize
- if !prior_answer && @workout_offering.andand.continue_from_workout
- prior_score = @workout_offering.continue_from_workout.score_for(@student_user)
- prior_attempt = prior_score.previous_attempt_for(@exercise_version.exercise)
- prior_answer = prior_attempt && prior_attempt.prompt_answers.where(prompt: prompt.acting_as).first
// Getting this user's latest attempt on the exercise in the gym
- if !prior_answer && !@workout_score
- prior_attempt = @exercise.latest_attempt_for(current_user)
- prior_answer = prior_attempt && prior_attempt.prompt_answers.where(prompt: prompt.acting_as).first
- if prior_answer && @workout_offering
- if !@workout_offering.can_be_practiced_by?(current_user)
- allow_write = false
- if allow_write && params[:review_user_id].nil?
= f.input :answer_code, as: :text, class: 'code',
input_html: { class: 'code', readonly: true, autofocus: true,
value: prior_answer ? prior_answer.specific.answer : prompt.prepare_starter_code,
data: { lang: 'text/x-' + (@exercise.language + (@exercise.language == 'C++'?'src':'')|| 'java').downcase,
starter_code: prompt.prepare_starter_code } }
- else
%pre{ data: { lang: 'text/x-java' } }
= prior_answer ? prior_answer.specific.answer : prompt.prepare_starter_code
.actions
- disabled = !current_user.andand.is_staff?(@workout_offering.andand.course_offering) && @attempts_left && @attempts_left == 0
- if @workout_offering.nil? || @workout_offering.can_be_practiced_by?(current_user)
- if @workout_offering.andand.workout_policy.andand.hide_feedback_before_finish && params[:review_user_id].nil?
= f.submit 'Save my answer!',
class: 'btn btn-primary btn-submit',
id: 'primarybtn', disabled: disabled
- elsif allow_write && params[:review_user_id].nil?
= f.submit 'Check my answer!',
class: 'btn btn-primary btn-submit',
id: 'primarybtn', disabled: disabled
- if coding_questions
%div.btn.btn-default{ data: { toggle: 'modal', target: '#confirm-reset' } } Reset
-if @exercise.tag_list.include? 'Visualizable'
-if @workout
-if @workout_offering
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: @workout.id, workout_offering: @workout_offering.id}} Visualize
-else
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: @workout.id, workout_offering: 'null'}} Visualize
-else
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: @workout.id, workout_offering: 'null'}} Visualize
-else
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: 'null', workout_offering: 'null'}} Visualize
%div.btn.btn-default{id: "visualize", disabled: true, data: {workout: 'null', workout_offering: 'null'}} Visualize

- if @workout_offering && params[:review_user_id].nil? && @workout_offering.workout.exercise_workouts.size > 1
= button_link 'Next exercise',
organization_workout_offering_practice_path(exercise_id: @workout.next_exercise(@exercise),
organization_id: @workout_offering.course_offering.course.organization.slug,
course_id: @workout_offering.course_offering.course.slug,
term_id: @workout_offering.course_offering.term.slug,
id: @workout_offering.id,
lti_launch: @lti_launch),
class: 'btn btn-default btn-next', id: 'nextbtn'
- elsif @workout && params[:review_user_id].nil? && @workout.exercise_workouts.size > 1
= button_link 'Next exercise',
exercise_practice_path(@workout.next_exercise(@exercise),
workout_id: @workout.id, workout_score_id: @workout_score.andand.id,
lti_launch: @lti_launch),
class: 'btn btn-info btn-next', id: 'nextbtn'
- if @workout_offering && params[:review_user_id].nil? && @workout_offering.workout.exercise_workouts.size > 1
= button_link 'Next exercise',
organization_workout_offering_practice_path(exercise_id: @workout.next_exercise(@exercise),
organization_id: @workout_offering.course_offering.course.organization.slug,
course_id: @workout_offering.course_offering.course.slug,
term_id: @workout_offering.course_offering.term.slug,
id: @workout_offering.id,
lti_launch: @lti_launch),
class: 'btn btn-default btn-next', id: 'nextbtn'
- elsif @workout && params[:review_user_id].nil? && @workout.exercise_workouts.size > 1
= button_link 'Next exercise',
exercise_practice_path(@workout.next_exercise(@exercise),
workout_id: @workout.id, workout_score_id: @workout_score.andand.id,
lti_launch: @lti_launch),
class: 'btn btn-info btn-next', id: 'nextbtn'

- if @workout.nil? && !@lti_launch
%br
= link_to "Practice a different #{@exercise.language} exercise", |
(@exercise.language ? |
random_exercise_path(language: @exercise.language) : |
random_exercise_path) |
.col-md-5
%h2 Feedback
#saved_assurance
#previous_answer.previous_answer
- if @attempt
#exercisefeedback
= render partial: 'sse/ajax_feedback'
- else
#exercisefeedback
%p Your feedback will appear here when you check your answer.
- if @workout.nil? && !@lti_launch
%br
= link_to "Practice a different #{@exercise.language} exercise", |
(@exercise.language ? |
random_exercise_path(language: @exercise.language) : |
random_exercise_path) |
.col-md-5
%h2 Feedback
#saved_assurance
#previous_answer.previous_answer
- if @attempt
#exercisefeedback
= render partial: 'sse/ajax_feedback'
- else
#exercisefeedback
%p Your feedback will appear here when you check your answer.

.modal.fade#confirm-reset{ tabindex: '-1', role: 'dialog', aria_labelledby: 'resetModalLabel', aria_hidden: true }
.modal-dialog
Expand Down
6 changes: 3 additions & 3 deletions app/views/layouts/two_columns.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
- main_content_width = ['col-md-12']
- if !@hide_sidebar # if this flag is not set, show the sidebar by default
- main_content_width = ['col-md-9']
.col-md-3.scrollable.max-height.sidebar
.inner.max-height
.col-md-3.scrollable.full-height.sidebar
.inner.full-height
.below-nav#sidebar
= render partial: 'layouts/sidebar', locals: { user: @student_user ? @student_user : current_user }
- main_content = main_content + main_content_width
%div{ class: main_content }
%button.btn-primary.toggle-slider{ style: 'display: none', data: { is_open: false } }
%i.fa.fa-bars
Exercises
.inner.max-height
.inner.full-height
.below-nav
= render partial: 'layouts/flash'
= yield

0 comments on commit a6ccf5c

Please sign in to comment.