Skip to content

Instantly share code, notes, and snippets.

@marvindpunongbayan
Last active May 8, 2020 16:14
Show Gist options
  • Save marvindpunongbayan/179ebc5cd5aedd573b4d32016d854a91 to your computer and use it in GitHub Desktop.
Save marvindpunongbayan/179ebc5cd5aedd573b4d32016d854a91 to your computer and use it in GitHub Desktop.
- # SmallBite - Checks
- # SmallBiteSetContent - Surveys
- exam_questions = @object.exam_questions.published.sort_by_position
.row-fluid
.col-sm-12
.heading-block{class: "#{'clean-header' if clean_layout?}"}
.link-menu{class: "#{'clearfix' if clean_layout?}"}
.button-set{style: ("display: none;" if params[:q].present?)}
- if @object.is_a?(SmallBite)
- if admin? || (@object.group.present? && can_manage?(object: @object.group)
- report = SystemReport.find_by(code: "sitch_checks_report")
= render "system_reports/sitch_report_buttons", report: report, small_bite: @object
- elsif @object.is_a?(SmallBiteSetContent) && @object.small_bite.present?
- if admin? || (@object.small_bite.group.present? && can_manage?(object: @object.small_bite.group)
= link_to download_reports_exam_path(@exam), data: {no_turbolink: "data-no-turbolink"} do
%span.icon.icon-download-alt
= "Download CSV"
%h4= @object.is_a?(SmallBiteSetContent) ? @object.small_bite.name_or_title : @object.name_or_title
.clearfix.margin-top-double
.visible-xs.visible-sm
= render "guides/guide", area: "basic.scrollable_table", default_content: "Scroll to the right for more content"
- if @exam_answer_sheets.any?
.full-scroll
%table.table.table-responsive.table-clean
%thead
%tr
%th= "Name"
%th.acenter= "Status"
- if @object.is_a?(SmallBite)
%th.acenter= "Score"
- if exam_questions.any?
- exam_questions.published.sort_by_position.each_with_index do |exam_question, idx|
%th.acenter
%span.cursor-help{tip: exam_question.context}
= "Question ##{idx + 1}"
%th.acenter= "Date Completed"
%tbody
- @exam_answer_sheets.each do |exam_answer_sheet|
- user = exam_answer_sheet.user
- account_user = exam_answer_sheet.account_user
- answers = exam_answer_sheet.answers
%tr
%td.font16
= link_to account_user.name, participant_path(user), target: "_blank"
%td.acenter
= html_status(exam_answer_sheet.status, nil, nil, false)
- if @object.is_a?(SmallBite)
%td.acenter
- if exam_answer_sheet.completed?
= "#{exam_answer_sheet.score}%"
- else
= "-"
- if exam_questions.any?
- exam_questions.published.sort_by_position.each_with_index do |exam_question, idx|
%td.acenter
- if @object.is_a?(SmallBite)
- if (exam_answer = answers.find_by(exam_question_id: exam_question.id)).present?
- tip = "Answer: #{exam_answer.answer}"
- if exam_question.essay?
- if exam_answer.rating_value.nil?
%span.icon.icon-circle.font-color-gray.font20{tip: "No rating yet"}
- else
.inline.padding-right
%span.icon.icon-ok.link-green.font20{tip: tip}
= render "exam_answers/rating", exam_answer: exam_answer
- else
- if exam_answer_sheet.check_answer(exam_question, exam_answer.answer)
%span.icon.icon-ok.link-green.font20{tip: tip}
- else
- tip += "<br/>Correct Answer: #{exam_question.answers}"
%span.icon.icon-remove.link-red.font20.cursor-help{tip: tip}
- else
%span.icon.icon-remove.link-red.font20.cursor-help{tip: "No answer yet"}
- elsif @object.is_a?(SmallBiteSetContent)
- exam_answer = exam_answer_sheet.get_answer(exam_question)
%td
- if exam_answer.answer_sheet.check_answer(exam_question.id, exam_answer.answer)
%span.icon.icon-ok.link-green.font20
- else
- tip = exam_question.true_or_false? ? exam_question.answers.titleize : raw(exam_question.answers)
%span.icon.icon-remove.link-red.font20.cursor-help{tip: "Correct Answer:<br/>#{tip}"}
- if exam_question.true_or_false?
%span.font16= exam_answer.answer.titleize
- elsif exam_question.multiple_choice?
%span.font16= exam_answer.answer
- else
%span.font16= raw exam_answer.answer
%td.acenter
- if exam_answer_sheet.completed?
= pst_datetime(exam_answer_sheet.completed_at)
- else
= "Not completed yet"
.pagination_area.fix-remote-links{data: {action: reports_exams_path(@object), param_name: "page"}}
= paginate @exam_answer_sheets, param_name: "page", remote: true, window: 2, page: params[:page]
.details
= page_entries_info @exam_answer_sheets
- else
= render "shared/no_records", msg: "No records were found"
%br/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment