class GithubToCanvasQuiz::Model::Quiz
Attributes
course_id[RW]
description[RW]
id[RW]
repo[RW]
title[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 8 def initialize(options) options.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end
Public Instance Methods
frontmatter_hash()
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 36 def frontmatter_hash { 'id' => id, 'course_id' => course_id, 'repo' => repo } end
to_h()
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 22 def to_h { 'title' => title, 'description' => description_with_header, 'quiz_type' => 'assignment', 'shuffle_answers' => true, 'hide_results' => nil, 'show_correct_answers_last_attempt' => true, 'allowed_attempts' => 3, 'scoring_policy' => 'keep_highest', 'one_question_at_a_time' => true } end
to_markdown()
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 14 def to_markdown MarkdownBuilder.build do |md| md.frontmatter(frontmatter_hash) md.h1(title) md.md(md.html_to_markdown(description)) end end
Private Instance Methods
description_with_header()
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 46 def description_with_header [git_links_header, description].reject(&:nil?).join("\n") end
git_links_header()
click to toggle source
# File lib/github_to_canvas_quiz/model/quiz.rb, line 50 def git_links_header return unless repo <<~HTML <div id='git-data-element' data-org='learn-co-curriculum' data-repo='#{repo}'></div> <header class='fis-header'> <a class='fis-git-link' href='https://github.com/learn-co-curriculum/#{repo}/issues/new' target='_blank' rel='noopener'><img id='issue-img' title='Create New Issue' alt='Create New Issue' /></a> </header> HTML end