vault backup: 2025-12-22 22:49:13
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m8s
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m8s
This commit is contained in:
BIN
quiz/db.sqlite3
BIN
quiz/db.sqlite3
Binary file not shown.
Binary file not shown.
Binary file not shown.
15
quiz/parse-markdown.py
Normal file
15
quiz/parse-markdown.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import pathlib
|
||||
|
||||
import mistune
|
||||
markdown = mistune.create_markdown(renderer=None)
|
||||
|
||||
root = pathlib.Path(__file__).parent.parent
|
||||
exams = root / "content" / "Anatomi & Histologi 2" / "Gamla tentor"
|
||||
print(exams.absolute())
|
||||
for file in sorted(exams.glob("*/*.md")):
|
||||
if len(file.stem) > 2:
|
||||
continue
|
||||
print(f"Parsing {file}")
|
||||
tokens = markdown(file.read_text(encoding="utf-8"))
|
||||
import pprint
|
||||
pprint.pprint(tokens)
|
||||
@@ -13,6 +13,11 @@ def close_quiz(request, session_id):
|
||||
session = get_object_or_404(QuizSession, id=session_id, user=request.quiz_user)
|
||||
session.is_active = False
|
||||
session.save()
|
||||
|
||||
# If it's an HTMX request, return empty response (card will be removed)
|
||||
if request.headers.get('HX-Request'):
|
||||
return HttpResponse('')
|
||||
|
||||
return redirect('index')
|
||||
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
</div>
|
||||
|
||||
{% for session in active_sessions %}
|
||||
<div class="active-session-card">
|
||||
<div class="active-session-card" id="session-{{ session.id }}">
|
||||
<div style="display: flex; justify-content: space-between; align-items: start; margin-bottom: 1rem;">
|
||||
<div>
|
||||
<span class="session-badge">
|
||||
@@ -214,7 +214,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<form action="{% url 'close_quiz' session.id %}" method="post" hx-post="{% url 'close_quiz' session.id %}"
|
||||
hx-target=".active-session-card" hx-swap="outerHTML">
|
||||
hx-target="#session-{{ session.id }}" hx-swap="outerHTML">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-secondary" style="padding: 0.5rem 1rem; font-size: 0.875rem;">
|
||||
✕ Stäng
|
||||
|
||||
@@ -53,6 +53,13 @@
|
||||
.matching-table .radio-cell {
|
||||
width: 60px;
|
||||
background: white;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.matching-table .radio-cell:hover:not(.diagonal-block) {
|
||||
background: #f0f4ff;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.matching-table .diagonal-block {
|
||||
@@ -114,11 +121,12 @@
|
||||
<strong>{{ forloop.counter }}.</strong> {{ left_item }}
|
||||
</td>
|
||||
{% for top_item in question.matching_data.top_items %}
|
||||
<td class="radio-cell">
|
||||
<td class="radio-cell" data-left="{{ forloop.parentloop.counter0 }}" data-top="{{ forloop.counter0 }}">
|
||||
{% if forloop.parentloop.counter0 != forloop.counter0 %}
|
||||
<input type="radio" name="match-{{ forloop.parentloop.counter0 }}" value="{{ forloop.counter0 }}"
|
||||
data-left="{{ forloop.parentloop.counter0 }}" data-top="{{ forloop.counter0 }}"
|
||||
id="radio-{{ forloop.parentloop.counter0 }}-{{ forloop.counter0 }}">
|
||||
id="radio-{{ forloop.parentloop.counter0 }}-{{ forloop.counter0 }}"
|
||||
style="pointer-events: none;">
|
||||
{% else %}
|
||||
<!-- Diagonal - no radio button -->
|
||||
<span class="diagonal-block">—</span>
|
||||
@@ -129,15 +137,6 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="top-items-legend">
|
||||
<h4>Kolumnalternativ:</h4>
|
||||
{% for top_item in question.matching_data.top_items %}
|
||||
<div class="top-item-label">
|
||||
<strong>{{ forloop.counter }}.</strong> {{ top_item }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -146,6 +145,26 @@
|
||||
const quizContent = document.getElementById('quiz-content');
|
||||
if (!quizContent) return;
|
||||
|
||||
// Handle clicks on table cells to select radio buttons
|
||||
quizContent.addEventListener('click', (e) => {
|
||||
const cell = e.target.closest('.radio-cell');
|
||||
if (!cell) return;
|
||||
|
||||
// Don't do anything for diagonal cells
|
||||
if (cell.querySelector('.diagonal-block')) return;
|
||||
|
||||
const leftIdx = cell.dataset.left;
|
||||
const topIdx = cell.dataset.top;
|
||||
|
||||
if (leftIdx !== undefined && topIdx !== undefined) {
|
||||
const radio = document.getElementById('radio-' + leftIdx + '-' + topIdx);
|
||||
if (radio) {
|
||||
radio.checked = true;
|
||||
saveMatchingAnswer();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
quizContent.addEventListener('change', (e) => {
|
||||
if (e.target.type === 'radio' && e.target.dataset.left) {
|
||||
saveMatchingAnswer();
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
<div class="options-container">
|
||||
{% for option in question.options.all %}
|
||||
<div class="option-item" id="option-{{ option.letter }}" data-letter="{{ option.letter }}">
|
||||
<div class="option-item" id="option-{{ option.letter }}" data-letter="{{ option.letter }}" style="cursor: pointer;">
|
||||
<input type="checkbox" id="checkbox-{{ option.letter }}" value="{{ option.letter }}"
|
||||
data-letter="{{ option.letter }}"
|
||||
style="margin-right: 0.5rem; width: 1.2rem; height: 1.2rem; cursor: pointer;">
|
||||
<span class="option-letter">{{ option.letter }}</span>
|
||||
<span>{{ option.text }}</span>
|
||||
style="margin-right: 0.5rem; width: 1.2rem; height: 1.2rem; cursor: pointer; pointer-events: auto;">
|
||||
<span class="option-letter" style="pointer-events: none;">{{ option.letter }}</span>
|
||||
<span style="pointer-events: none;">{{ option.text }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -39,7 +39,7 @@
|
||||
// Handle checkbox changes (direct checkbox clicks or programmatic changes)
|
||||
container?.addEventListener('change', (e) => {
|
||||
if (e.target.type === 'checkbox') {
|
||||
const letter = e.target.dataset.letter;
|
||||
const { letter } = e.target.dataset;
|
||||
if (letter) updateSelection(letter);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user