All basic question types

This commit is contained in:
Charlotte Van Petegem 2025-04-27 00:13:20 +02:00
parent 3e1e5618ca
commit 4fe218166f
Signed by: chvp
SSH key fingerprint: SHA256:s9rb8jBVfdahqWHuBAcHCBP1wmj4eYQXZfqgz4H3E9E
51 changed files with 760 additions and 92 deletions

View file

@ -3,23 +3,18 @@
<head>
<title><%= content_for(:title) || "Entrance Exam" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= yield :head %>
<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag :app %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
<%= javascript_include_tag "application" %>
</head>
<body>

View file

@ -1,22 +0,0 @@
{
"name": "EntranceExam",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "EntranceExam.",
"theme_color": "red",
"background_color": "red"
}

View file

@ -1,26 +0,0 @@
// Add a service worker for processing Web Push notifications:
//
// self.addEventListener("push", async (event) => {
// const { title, options } = await event.data.json()
// event.waitUntil(self.registration.showNotification(title, options))
// })
//
// self.addEventListener("notificationclick", function(event) {
// event.notification.close()
// event.waitUntil(
// clients.matchAll({ type: "window" }).then((clientList) => {
// for (let i = 0; i < clientList.length; i++) {
// let client = clientList[i]
// let clientPath = (new URL(client.url)).pathname
//
// if (clientPath == event.notification.data.path && "focus" in client) {
// return client.focus()
// }
// }
//
// if (clients.openWindow) {
// return clients.openWindow(event.notification.data.path)
// }
// })
// )
// })

View file

@ -0,0 +1,12 @@
<div id="<%= "question_answer_#{question.id}_preview" %>">
<% if question.answer.present? %>
<%= image_tag question.answer.image %>
<% end %>
</div>
<input id="<%= "question_answer_#{question.id}" %>"
type="file"
accept=".jpg,.jpeg,.png,.webp,image/jpg,image/jpeg,image/png,image/webp"
autocomplete="off"
data-behaviour="question_image_input"
data-submit-url="<%= answer_question_url(question.id) %>"
/>

View file

@ -0,0 +1,3 @@
<div>
This one's going to be hard...
</div>

View file

@ -0,0 +1,7 @@
<input id="<%= "question_answer_#{question.id}" %>"
type="text"
value="<%= question.answer&.data || '' %>"
autocomplete="off"
data-behaviour="question_simple_input"
data-submit-url="<%= answer_question_url(question.id) %>"
/>

View file

@ -0,0 +1 @@
<%= question.text %>

View file

@ -0,0 +1 @@
<video src="<%= question.public_asset_path %>" controls preload="metadata"></video>

View file

@ -0,0 +1,5 @@
<% @sections.each do |section| %>
<p>
<%= link_to section.title, section_url(section) %>
</p>
<% end %>

View file

@ -0,0 +1,10 @@
<h4><%= @section.title %></h4>
<p><%= @section.description %></p>
<% @questions.each do |question| %>
<section>
<%= render partial: "questions/#{question.question_kind}_show", locals: { question: } %>
<%= render partial: "questions/#{question.answer_kind}_form", locals: { question: } %>
</section>
<% end %>

View file

@ -0,0 +1,5 @@
<%= form_with url: sessions_path, method: :post do |form| %>
<%= form.label :token, "Token" %>
<%= form.password_field :token %>
<%= form.submit "Start exam" %>
<% end %>