Skip to content

Commit c57ef4e

Browse files
committed
chore: update common files
1 parent a2f0698 commit c57ef4e

21 files changed

Lines changed: 1301 additions & 1388 deletions

_static/assessment.js

Lines changed: 223 additions & 230 deletions
Large diffs are not rendered by default.

_static/carousel.js

Lines changed: 72 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,78 @@
1-
document.addEventListener('DOMContentLoaded', function() {
2-
// Wait a bit for sphinx-design to initialize
3-
setTimeout(() => {
4-
initializeCarousels();
5-
}, 500);
1+
document.addEventListener("DOMContentLoaded", function () {
2+
// Wait a bit for sphinx-design to initialize
3+
setTimeout(() => {
4+
initializeCarousels();
5+
}, 500);
66
});
77

88
function initializeCarousels() {
9-
const carousels = document.querySelectorAll('.sd-cards-carousel');
9+
const carousels = document.querySelectorAll(".sd-cards-carousel");
1010

11-
carousels.forEach((carousel, index) => {
12-
// Ensure carousel is wrapped
13-
if (!carousel.parentElement.classList.contains('sd-cards-carousel-wrapper')) {
14-
const wrapper = document.createElement('div');
15-
wrapper.className = 'sd-cards-carousel-wrapper';
16-
carousel.parentNode.insertBefore(wrapper, carousel);
17-
wrapper.appendChild(carousel);
18-
}
19-
20-
// Create navigation buttons
21-
const prevButton = document.createElement('button');
22-
prevButton.innerHTML = '<i class="fas fa-chevron-left"></i>';
23-
prevButton.className = 'carousel-nav-button carousel-prev';
24-
25-
const nextButton = document.createElement('button');
26-
nextButton.innerHTML = '<i class="fas fa-chevron-right"></i>';
27-
nextButton.className = 'carousel-nav-button carousel-next';
28-
29-
// Add buttons to carousel
30-
carousel.parentElement.appendChild(prevButton);
31-
carousel.parentElement.appendChild(nextButton);
32-
33-
// Navigation logic
34-
prevButton.addEventListener('click', () => {
35-
const cardWidth = carousel.offsetWidth;
36-
carousel.scrollBy({
37-
left: -cardWidth,
38-
behavior: 'smooth'
39-
});
40-
});
41-
42-
nextButton.addEventListener('click', () => {
43-
const cardWidth = carousel.offsetWidth;
44-
carousel.scrollBy({
45-
left: cardWidth,
46-
behavior: 'smooth'
47-
});
48-
});
49-
50-
// Update button states
51-
const updateButtons = () => {
52-
prevButton.classList.toggle('disabled', carousel.scrollLeft <= 0);
53-
nextButton.classList.toggle('disabled',
54-
carousel.scrollLeft >= carousel.scrollWidth - carousel.clientWidth - 5); // 5px buffer
55-
};
56-
57-
// Add event listeners
58-
carousel.addEventListener('scroll', updateButtons);
59-
window.addEventListener('resize', () => {
60-
updateButtons();
61-
// Ensure proper scroll position on resize
62-
const currentIndex = Math.round(carousel.scrollLeft / carousel.offsetWidth);
63-
carousel.scrollTo({
64-
left: currentIndex * carousel.offsetWidth,
65-
behavior: 'auto'
66-
});
67-
});
68-
69-
// Initialize button states
70-
updateButtons();
11+
carousels.forEach((carousel, index) => {
12+
// Ensure carousel is wrapped
13+
if (
14+
!carousel.parentElement.classList.contains("sd-cards-carousel-wrapper")
15+
) {
16+
const wrapper = document.createElement("div");
17+
wrapper.className = "sd-cards-carousel-wrapper";
18+
carousel.parentNode.insertBefore(wrapper, carousel);
19+
wrapper.appendChild(carousel);
20+
}
21+
22+
// Create navigation buttons
23+
const prevButton = document.createElement("button");
24+
prevButton.innerHTML = '<i class="fas fa-chevron-left"></i>';
25+
prevButton.className = "carousel-nav-button carousel-prev";
26+
27+
const nextButton = document.createElement("button");
28+
nextButton.innerHTML = '<i class="fas fa-chevron-right"></i>';
29+
nextButton.className = "carousel-nav-button carousel-next";
30+
31+
// Add buttons to carousel
32+
carousel.parentElement.appendChild(prevButton);
33+
carousel.parentElement.appendChild(nextButton);
34+
35+
// Navigation logic
36+
prevButton.addEventListener("click", () => {
37+
const cardWidth = carousel.offsetWidth;
38+
carousel.scrollBy({
39+
left: -cardWidth,
40+
behavior: "smooth",
41+
});
42+
});
43+
44+
nextButton.addEventListener("click", () => {
45+
const cardWidth = carousel.offsetWidth;
46+
carousel.scrollBy({
47+
left: cardWidth,
48+
behavior: "smooth",
49+
});
7150
});
51+
52+
// Update button states
53+
const updateButtons = () => {
54+
prevButton.classList.toggle("disabled", carousel.scrollLeft <= 0);
55+
nextButton.classList.toggle(
56+
"disabled",
57+
carousel.scrollLeft >= carousel.scrollWidth - carousel.clientWidth - 5,
58+
); // 5px buffer
59+
};
60+
61+
// Add event listeners
62+
carousel.addEventListener("scroll", updateButtons);
63+
window.addEventListener("resize", () => {
64+
updateButtons();
65+
// Ensure proper scroll position on resize
66+
const currentIndex = Math.round(
67+
carousel.scrollLeft / carousel.offsetWidth,
68+
);
69+
carousel.scrollTo({
70+
left: currentIndex * carousel.offsetWidth,
71+
behavior: "auto",
72+
});
73+
});
74+
75+
// Initialize button states
76+
updateButtons();
77+
});
7278
}

_static/custom-table.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ div.cell_output table {
77
}
88

99

10-
div.cell_output table tbody tr,
11-
div.cell_output table tbody tr th,
10+
div.cell_output table tbody tr,
11+
div.cell_output table tbody tr th,
1212
div.cell_output table tbody tr td {
1313
text-align: left !important;
1414
position: relative;
@@ -85,7 +85,7 @@ div.cell_output tbody tr:hover{
8585
min-width: 100px;
8686
font-size: 14px;
8787
}
88-
88+
8989
div.cell_output table tbody tr:hover td {
9090
font-size: 13px;
9191
padding: 10px 6px;

_static/drag_drop.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ html[data-theme='dark'] .reset-button {
187187

188188
.drop-area.incorrect-answer {
189189
background-color: #f8d7da;
190-
}
190+
}

_static/quadriga.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ html[data-theme='dark'] div.story > .admonition-title::after {
337337
color: #b876d1
338338
}
339339

340-
/* Fix bibliography URL overflow */
340+
/* Fix bibliography URL overflow — targets actual rendered HTML */
341341
div.citation {
342342
display: flex;
343343
flex-wrap: wrap;
@@ -354,4 +354,4 @@ div.citation .docutils {
354354
word-wrap: break-word;
355355
min-width: 0;
356356
flex: 1;
357-
}
357+
}

quadriga/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
__version__ = "0.1.0"
99

1010
# Import important modules to make them available at the top level
11-
from . import colors
11+
from . import colors as colors
1212

1313
# Metadata submodule is not imported directly as it's intended to be used as a standalone CLI tool

quadriga/assessment.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
from IPython.display import HTML
21
import json
32
import uuid
43

4+
from IPython.display import HTML
5+
56

67
def create_answer_box(question_id, rows=4):
7-
"""Create an answer box with a submit button."""
8+
"""Create an answer box with an info popup button."""
89
return HTML(f"""
910
<div style="padding: 5px; border-radius: 5px; margin: 10px 0;">
1011
<textarea id="answer-{question_id}" rows="{rows}" style="width: 100%; margin-top: 10px; padding: 10px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Ihre Antwort"></textarea>
11-
<button id="btn-answer-{question_id}" onclick="lockAnswer('answer-{question_id}')" style="margin-top: 5px; padding: 5px 12px; background-color: #00305e; color: white; border: none; border-radius: 4px; cursor: pointer;">Bestätigen</button>
12+
<button id="btn-answer-{question_id}" onclick="alert('Ihre Eingabe wird nicht überprüft oder gespeichert. Dieses Textfeld dient lediglich Ihrer eigenen Reflexion und der aktiven Wiedergabe der Lerninhalte.')" style="margin-top: 5px; padding: 5px 12px; background-color: #00305e; color: white; border: none; border-radius: 4px; cursor: pointer;">OK</button>
1213
</div>
1314
""")
1415

1516

1617
class DragDropQuiz:
1718
"""
1819
A simple drag-and-drop quiz generator for Jupyter Books.
19-
20+
2021
Usage:
2122
quiz = DragDropQuiz()
2223
quiz.create_matching_quiz(
@@ -26,14 +27,16 @@ class DragDropQuiz:
2627
correct_mapping={"Description 1": "Option A", "Description 2": "Option B", "Description 3": "Option C"}
2728
)
2829
"""
29-
30+
3031
def __init__(self):
3132
self.quiz_counter = 0
32-
33-
def create_matching_quiz(self, title, descriptions, options, correct_mapping, show_feedback=True, feedback_messages=None):
33+
34+
def create_matching_quiz(
35+
self, title, descriptions, options, correct_mapping, show_feedback=True, feedback_messages=None
36+
):
3437
"""
3538
Create a drag-and-drop matching quiz.
36-
39+
3740
Parameters:
3841
- title (str): The quiz title/question
3942
- descriptions (list): List of items to be matched (static labels)
@@ -44,33 +47,33 @@ def create_matching_quiz(self, title, descriptions, options, correct_mapping, sh
4447
"""
4548
self.quiz_counter += 1
4649
quiz_id = f"drag_drop_quiz_{self.quiz_counter}_{uuid.uuid4().hex[:8]}"
47-
50+
4851
# Set default feedback messages if none provided
4952
if feedback_messages is None:
5053
feedback_messages = {
5154
"correct": "Perfekt! Alle {total} Zuordnungen sind korrekt!",
5255
"incorrect": "Leider sind keine Zuordnungen korrekt. Versuchen Sie es noch einmal!",
53-
"partial": "Teilweise richtig: {correct} von {total} Zuordnungen sind korrekt."
56+
"partial": "Teilweise richtig: {correct} von {total} Zuordnungen sind korrekt.",
5457
}
55-
56-
# Convert correct mapping to use indices for earlier elements, but map option texts directly
58+
59+
# Convert correct mapping to use indices for easier JavaScript handling
5760
desc_to_idx = {desc: i for i, desc in enumerate(descriptions)}
58-
61+
opt_to_idx = {opt: i for i, opt in enumerate(options)}
62+
5963
correct_pairs = []
6064
for desc, opt in correct_mapping.items():
61-
if desc in desc_to_idx:
62-
# We store the string `opt` instead of the index so duplicate texts work
63-
correct_pairs.append([desc_to_idx[desc], opt])
64-
65+
if desc in desc_to_idx and opt in opt_to_idx:
66+
correct_pairs.append([desc_to_idx[desc], opt_to_idx[opt]])
67+
6568
html_content = self._generate_html(
6669
quiz_id, title, descriptions, options, correct_pairs, show_feedback, feedback_messages
6770
)
68-
71+
6972
return HTML(html_content)
70-
73+
7174
def _generate_html(self, quiz_id, title, descriptions, options, correct_pairs, show_feedback, feedback_messages):
7275
"""Generate the complete HTML for the drag-and-drop quiz."""
73-
76+
7477
# Generate static description labels with drop zones
7578
description_zones = ""
7679
for i, desc in enumerate(descriptions):
@@ -82,7 +85,7 @@ def _generate_html(self, quiz_id, title, descriptions, options, correct_pairs, s
8285
</div>
8386
</div>
8487
'''
85-
88+
8689
# Generate draggable options
8790
draggable_options = ""
8891
for i, option in enumerate(options):
@@ -91,29 +94,29 @@ def _generate_html(self, quiz_id, title, descriptions, options, correct_pairs, s
9194
{option}
9295
</div>
9396
'''
94-
97+
9598
return f'''
9699
<div class="drag-drop-quiz" id="{quiz_id}">
97100
<div class="quiz-title">{title}</div>
98-
101+
99102
<div class="quiz-main">
100103
<div class="descriptions-container">
101104
{description_zones}
102105
</div>
103106
</div>
104-
107+
105108
<div class="options-container">
106109
<div class="options-title">Ziehen Sie diese zu den passenden Beschreibungen</div>
107110
<div class="options-list" id="{quiz_id}_options">
108111
{draggable_options}
109112
</div>
110113
</div>
111-
114+
112115
<div class="quiz-controls">
113116
<button class="quiz-button" onclick="checkAnswer_{quiz_id}()">Antwort prüfen</button>
114117
<button class="quiz-button reset-button" onclick="resetQuiz_{quiz_id}()">Zurücksetzen</button>
115118
</div>
116-
119+
117120
<div id="{quiz_id}_feedback"></div>
118121
</div>
119122
<script>
@@ -131,5 +134,3 @@ def _generate_html(self, quiz_id, title, descriptions, options, correct_pairs, s
131134
}});
132135
</script>
133136
'''
134-
135-

quadriga/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This submodule contains all QUADRIGA color presets for the various libraries used."""
1+
"""QUADRIGA color presets for various libraries used."""
22

33
jupyterquiz = {
44
"--jq-multiple-choice-bg": "#00305e",

quadriga/metadata/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
__all__ = [
99
"create_bibtex",
10+
"create_citation_cff",
1011
"extract_from_book_config",
11-
"update_citation_cff",
1212
"update_version_from_tag",
1313
"utils",
1414
]
1515

1616
# Import the modules to make their functions available
1717
from . import (
1818
create_bibtex,
19+
create_citation_cff,
1920
extract_from_book_config,
20-
update_citation_cff,
2121
update_version_from_tag,
2222
utils,
2323
)

0 commit comments

Comments
 (0)