Skip to content

Commit

Permalink
Merge pull request #5628 from galaxyproject/platypus-tailor
Browse files Browse the repository at this point in the history
code documentation
  • Loading branch information
shiltemann authored Dec 13, 2024
2 parents 370c83b + 5c0fe82 commit d68e0df
Show file tree
Hide file tree
Showing 62 changed files with 6,841 additions and 5,572 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
- name: Validate all links, enforce alt text
run: |
bundle exec htmlproofer \
--ignore-urls "/.*localhost.*/","/.*vimeo\.com.*/","/.*gitter\.im.*/","/.*drmaa\.org.*/","/.*slides.html#.*/,/#embedded_jbrowse/","/.*videos.*.mp4.png/","/krona_(all|multisample).html/","/workflows\/trs_import/" \
--ignore-files "/.*krona.*\.html/","/.*\/files\/.*/","/.*\/node_modules\/.*/","/\/tutorials\/.*\/docker\//","/.*content.html/","/.*recentrifuge.*\.html/" \
--ignore-urls "/.*localhost.*/","/.*vimeo\.com.*/","/.*gitter\.im.*/","/.*drmaa\.org.*/","/.*slides.html#.*/,/#embedded_jbrowse/","/.*videos.*.mp4.png/","/krona_(all|multisample).html/","/workflows\/trs_import/","/api/","/by-tool/" \
--ignore-files "/.*krona.*\.html/","/.*\/files\/.*/","/.*\/node_modules\/.*/","/\/tutorials\/.*\/docker\//","/.*content.html/","/.*recentrifuge.*\.html/","/short/" \
--swap-urls "github.com/galaxyproject/training-material/tree/main:github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_HEAD_REF}" \
--disable-external=true \
--enforce-https=false \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
curl -L https://edamontology.org/EDAM.csv > metadata/EDAM.csv
make rebuild-search-index ACTIVATE_ENV=pwd
cat metadata/swagger.yaml | python bin/yaml2json.py > api/swagger.json
rdoc bin _plugins/ --output gtn_rdoc
rdoc bin _plugins/ --output gtn_rdoc --template rorvswild
- name: Build Site
run: |
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ gem 'commander'

# RO-Crates
gem 'rubyzip', '~> 2.3.0'

gem 'rorvswild_theme_rdoc'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.3.9)
rorvswild_theme_rdoc (0.2)
rouge (4.1.3)
rubyzip (2.3.2)
safe_yaml (1.0.5)
Expand Down Expand Up @@ -131,6 +132,7 @@ DEPENDENCIES
kwalify
nokogiri (>= 1.10.4)
pkg-config
rorvswild_theme_rdoc
rubyzip (~> 2.3.0)
webrick

Expand Down
97 changes: 90 additions & 7 deletions _includes/quiz.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,94 @@
{% endif %}
{% endfor %}

<div markdown="1">
> <div class="box-title" aria-label="quiz box: {{ quiz.title | replace: '"', '&quot;' }}"><i class="far fa-question-circle" aria-hidden="true"></i><span class="visually-hidden"></span> Quiz: {{ quiz.title }}</div>
> Check your knowledge with a quiz!
>
> - [Self Study Mode]({% link quiz/quiz.html %}?mode=self&quiz={{ site.baseurl }}/{{ quiz.path }}) - do the quiz at your own pace, to check your understanding.
> - [Classroom Mode]({% link quiz/quiz.html %}?mode=teacher&quiz={{ site.baseurl }}/{{ quiz.path }}) - do the quiz synchronously with a classroom of students.
{: .question}
<blockquote class="comment" id="{{ quiz.id | slugify }}">
<div class="box-title comment-title">
<i class="far fa-comment-dots" aria-hidden="true"></i>
Quiz: {{ quiz.title }}
</div>


{% for question in quiz.questions %}
{% assign qnum = forloop.index %}
<form class="quiz-{{ quiz.id | slugify }} question-{{ qnum }}">
<b class="question-title"><span class="result"></span> Question {{ qnum }}: {{ question.title }}</b>

{% if question.image %}
<img src="{{ question.image }}" alt="Image for question {{ forloop.index }}" />
{% endif %}

{% unless question.type == "poll" %}
<ul>
{% for answer in question.answers %}

{%- capture is_correct -%}
{%- if question.type == "choose-1" -%}
{%- if answer == question.correct -%}correct{%- endif -%}
{%- elsif question.type == "choose-many" -%}
{%- for a in question.correct -%}{%- if answer == a -%}correct{%- endif -%}{%- endfor -%}
{%- endif -%}
{%- endcapture -%}

<li class="answer {{is_correct}}">
<span class="result"></span>
{% if question.type == "choose-1" %}
<input type="radio" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}"/>
{% elsif question.type == "choose-many" %}
<input type="checkbox" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}" />
{% elsif question.type == "free-text" %}
<input type="text" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}"/>
{% endif %}

<label for="a-{{ qnum }}-{{ forloop.index }}">{{ answer }}</label>
</li>
{% endfor %}
</ul>
{% endunless %}
</form>
{% endfor %}

<div class="quiz-results" aria-live="polite" role="status">
</div>

<button type="submit" class="btn btn-primary" id="check-answers" onclick="checkQuiz('{{ quiz.id | slugify}}')">Check Answers</button>
</blockquote>

<script>
function checkQuiz(id){
var quiz = document.getElementById(id);
var correct = 0;
var total = document.querySelectorAll(`#${id} form`).length;
var questions = document.querySelectorAll(`#${id} form`);
for (var i = 0; i < questions.length; i++) {
var question = questions[i];
var answer = question.querySelectorAll("li.answer");
// Only grade completed questions.

var any_wrong = false;
var any_selected = [...answer].map(e => e.querySelector("input").checked).includes(true);
// Loop over the inputs for this question
if (any_selected) {
question.querySelectorAll("input").forEach((input) => {
if (input.checked != input.classList.contains('correct')) {
any_wrong = true;
}
});

answer.forEach((li) => {
li.querySelector('.result').innerHTML = li.classList.contains('correct') ? "✅" : "❌";
});

if (any_wrong) {
question.querySelector(".result").innerHTML = "❌";
} else {
question.querySelector(".result").innerHTML = "✅";
correct++;
}
} else {
question.querySelector(".result").innerHTML = "❓";
}
}
var result = correct / total * 100;
quiz.querySelector('.quiz-results').innerHTML = `<p>You got ${correct} out of ${total} correct (${parseInt(result)}%)</p>`;
}
</script>
2 changes: 2 additions & 0 deletions _layouts/tutorial_hands_on.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ <h1>{{ locale['faqs'] | default: "Frequently Asked Questions" }}</h1>
If not, please ask your question on the <a href="{{site.gitter_url}}">GTN Gitter Channel</a> or the
<a href="https://help.galaxyproject.org">Galaxy Help Forum</a>

<!--
{% if own_material.quiz %}
<h1 data-toc-skip>Quizzes</h1>
<p>Check your understanding with these quizzes</p>
Expand All @@ -338,6 +339,7 @@ <h2>{{ q.title }}</h2>
</ul>
{% endfor %}
{% endif %}
-->

{% if topic.references %}
<h1 data-toc-skip>Useful literature</h1>
Expand Down
90 changes: 46 additions & 44 deletions _plugins/abbr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,63 @@
require 'jekyll'

module Jekyll
##
# This class modifies the page contents to replace {abbr} with the associated
# abbreviation in a proper <abbr> tag. It's done as a generator because it's
# easier to operate once per page and be able to easily see if we've generated
# the abbreviation before.
#
# This could in theory operate as a simple tag, but I'm not sure how to keep
# track of "# of times seen per page" there.
class Abbreviate < Jekyll::Generator
safe true

def initialize(config) # :nodoc:
super
@config = config['abbreviate'] ||= {}
end
module Generators
##
# This class modifies the page contents to replace {abbr} with the associated
# abbreviation in a proper <abbr> tag. It's done as a generator because it's
# easier to operate once per page and be able to easily see if we've generated
# the abbreviation before.
#
# This could in theory operate as a simple tag, but I'm not sure how to keep
# track of "# of times seen per page" there.
class Abbreviate < Jekyll::Generator
safe true

def generate(site) # :nodoc:
site.pages
.reject { |page| skip_layout?(page.data['layout']) }
.each { |page| abbreviate page }
site.posts.docs
.reject { |post| skip_layout?(post.data['layout']) }
.each { |post| abbreviate post }
end
def initialize(config) # :nodoc:
super
@config = config['abbreviate'] ||= {}
end

def generate(site) # :nodoc:
site.pages
.reject { |page| skip_layout?(page.data['layout']) }
.each { |page| abbreviate page }
site.posts.docs
.reject { |post| skip_layout?(post.data['layout']) }
.each { |post| abbreviate post }
end

private
private

def abbreviate(page) # :nodoc:
return unless page.data.key?('abbreviations')
def abbreviate(page) # :nodoc:
return unless page.data.key?('abbreviations')

seen = {}
page.data['abbreviations'].each do |abbr, definition|
page.content = page.content.gsub(/\{(#{abbr})\}/) do
if seen.key?(abbr)
firstdef = false
else
firstdef = true
seen[abbr] = true
end
seen = {}
page.data['abbreviations'].each do |abbr, definition|
page.content = page.content.gsub(/\{(#{abbr})\}/) do
if seen.key?(abbr)
firstdef = false
else
firstdef = true
seen[abbr] = true
end

if firstdef
"#{definition} (#{abbr})"
else
"<abbr title=\"#{definition}\">#{abbr}</abbr>"
if firstdef
"#{definition} (#{abbr})"
else
"<abbr title=\"#{definition}\">#{abbr}</abbr>"
end
end
end
end
end

def skip_layout?(layout)
to_skip = @config['skip_layouts'] || []
def skip_layout?(layout)
to_skip = @config['skip_layouts'] || []

true if to_skip.empty?
true if to_skip.empty?

to_skip.include?(layout)
to_skip.include?(layout)
end
end
end
end
Loading

0 comments on commit d68e0df

Please sign in to comment.