introduce nuxt-prawo-jazdy
This commit is contained in:
commit
6f87d74c34
47 changed files with 14602 additions and 0 deletions
2
.env.example
Normal file
2
.env.example
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
DATABASE_URL="file:./db/database.db"
|
||||
CDN_URL="http://DOMAIN.TLD/FOLDER"
|
||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Nuxt dev/build outputs
|
||||
.output
|
||||
.data
|
||||
.nuxt
|
||||
.nitro
|
||||
.cache
|
||||
dist
|
||||
|
||||
# Node dependencies
|
||||
node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
40
Dockerfile
Normal file
40
Dockerfile
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Build Stage 1
|
||||
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
# Copy package.json and your lockfile, here we add pnpm-lock.yaml for illustration
|
||||
#COPY package.json pnpm-lock.yaml .npmrc ./
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm i
|
||||
|
||||
# Copy the entire project
|
||||
COPY . ./
|
||||
|
||||
# Build the project
|
||||
RUN pnpm run build
|
||||
|
||||
# Build Stage 2
|
||||
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable
|
||||
|
||||
# Only `.output` folder is needed from the build stage
|
||||
COPY --from=build /app/.output/ ./
|
||||
RUN mkdir -p /app/server/db/
|
||||
COPY --from=build /app/db/database.db /app/server/db/
|
||||
WORKDIR /app/server
|
||||
RUN pnpm i
|
||||
# Change the port and host
|
||||
ENV PORT=33550
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
EXPOSE 33550
|
||||
|
||||
CMD ["node", "/app/server/index.mjs"]
|
||||
660
LICENSE
Normal file
660
LICENSE
Normal file
|
|
@ -0,0 +1,660 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
nuxt-prawo-jazdy: Polish driver's license theoritical exam nuxt web app
|
||||
Copyright (C) 2025 NetMan
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, AGPL-3.0-only.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
102
README.md
Normal file
102
README.md
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
# nuxt-prawo-jazdy
|
||||
|
||||
## Required
|
||||
|
||||
The [db-prawo-jazdy](https://git.mandarynki.eu/netman/db-prawo-jazdy) project is designed for this one in mind, so use it in conjunction with this - visit it for more details
|
||||
|
||||
^^ Above is kind of outdated, project moved from PostgreSQL to SQLite - I included a `database.db` file in the `db/` folder, although it has older dataset of questions from the Ministry - foreshadowing...
|
||||
|
||||
You also need the exam media files from the (Ministry of Infrasture)[https://www.gov.pl/web/infrastruktura/prawo-jazdy] - the latest files should be there
|
||||
|
||||
The newest at the moment of me writing this (December 16th 2025) are the (visualisations for questions from November 2025)[https://www.gov.pl/pliki/mi/pytania_egzaminacyjne_na_prawo_jazdy_11_2025.zip]
|
||||
|
||||
# To-do:
|
||||
|
||||
- [x] re-forge database structure (good for now)
|
||||
- [x] choose category (good for now)
|
||||
- [x] come up with how to show results appropriately
|
||||
- [x] better answer click recognition
|
||||
- [x] beautify website (good for now)
|
||||
- [x] <b>Fixed?</b> Needs testing, but should be fine question-mark? - fix pinia middleware between pages, MAJOR ISSUE - finishing exam sometimes redirects to homepage instead of results
|
||||
- [x] question timers
|
||||
- [x] exam (& results?) warning leave message on exit and timer end (and definitely on refresh)
|
||||
- [x] add keybinds:
|
||||
- S - start
|
||||
- D - nast.pyt
|
||||
- X - koniec egzaminu (na pewno chcesz zakonczyc egzamin?)
|
||||
- T - Tak
|
||||
- N - Nie
|
||||
- A - A
|
||||
- B - B
|
||||
- C - C
|
||||
- [ ] i18n - pl, en, de, ua (not all questions are available in ua, api handle)
|
||||
- [ ] UI i18n
|
||||
- [x] pl
|
||||
- [x] en
|
||||
- [ ] de
|
||||
- [ ] ua
|
||||
- [ ] db: examstore add language field, api handle languages
|
||||
- [ ] db: (revise) script for processing, (revise and) share appropriate files
|
||||
- [ ] clean up js code in exam.vue and result.vue (currently a little bit of a mess)
|
||||
|
||||
## Some information about the project
|
||||
|
||||
My intention is, to share access to test exams free of charge, you don't have to pay me - although you can, I greatly appreciate if you donate!
|
||||
|
||||
In the future I will host this project publicly `aaS`, and will probably put non-invasive, privacy friendly ads if it gains enough traction
|
||||
|
||||
All data used by this software is public information by definition provided in the Polish Constitution - (article 61.)[https://www.sejm.gov.pl/prawo/konst/polski/kon1.htm], and can be acquired by either checking above links on the gov website, or by writing to the Ministry ((if something happened to be missing))[placeholder_for_post_about_missing_points_column]
|
||||
|
||||
This project is a website mimicking an official driver's license theoritical exam (for different license categories) with a seperate media server, connected using drizzle ORM to a SQLite database
|
||||
|
||||
## Setup
|
||||
|
||||
This project utilizes `pnpm`, thus it is recommended
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Start the development server on `http://localhost:3000`:
|
||||
|
||||
```bash
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
Build the application for production:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
Locally preview production build:
|
||||
|
||||
```bash
|
||||
pnpm preview
|
||||
```
|
||||
|
||||
Check out the [Nuxt documentation](https://nuxt.com/docs) for more information.
|
||||
|
||||
### [Licensing](./LICENSE) (AGPL-3.0-only)
|
||||
|
||||
```
|
||||
nuxt-prawo-jazdy: Polish driver's license theoritical exam nuxt web app
|
||||
|
||||
Copyright (C) 2025 NetMan
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, AGPL-3.0-only.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
```
|
||||
20
app.vue
Normal file
20
app.vue
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
const examStore = useExamStore();
|
||||
const { setLocale } = useI18n();
|
||||
|
||||
setLocale(examStore.lang as 'pl' | 'en' | 'de' | 'ua');
|
||||
|
||||
const themeStore = useThemeStore();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :data-theme="themeStore.theme" class="min-h-dvh">
|
||||
<NuxtPage />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.outline-set-solid {
|
||||
outline-style: solid;
|
||||
}
|
||||
</style>
|
||||
12
assets/main.css
Normal file
12
assets/main.css
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
.btn {
|
||||
height: initial !important;
|
||||
min-height: var(--size);
|
||||
}
|
||||
.set-translate {
|
||||
@apply absolute top-[50%] left-[50%];
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.info-little-box {
|
||||
@apply inline-block px-[15px] py-[8px] bg-blue-500 text-white font-bold rounded-md;
|
||||
}
|
||||
14
categories.ts
Normal file
14
categories.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export default [
|
||||
'A',
|
||||
'B',
|
||||
'C',
|
||||
'D',
|
||||
'T',
|
||||
'AM',
|
||||
'A1',
|
||||
'A2',
|
||||
'B1',
|
||||
'C1',
|
||||
'D1',
|
||||
'PT',
|
||||
];
|
||||
10
components/CurrentQuestionCount.vue
Normal file
10
components/CurrentQuestionCount.vue
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<script lang="ts" setup></script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-lg"><slot name="title" /></span>
|
||||
<div class="info-little-box w-full text-center">
|
||||
<slot name="count" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
33
components/EndModal.vue
Normal file
33
components/EndModal.vue
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<script setup lang="ts">
|
||||
const props = defineProps<{ showModal: boolean }>();
|
||||
const endModal = useTemplateRef('endModal');
|
||||
|
||||
const emit = defineEmits(['hideEndModal', 'endExam']);
|
||||
|
||||
watchEffect(() => {
|
||||
if (props.showModal && endModal.value?.open == false) {
|
||||
endModal.value?.showModal();
|
||||
emit('hideEndModal');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dialog
|
||||
ref="endModal"
|
||||
class="flex justify-center items-center backdrop-blur-sm modal"
|
||||
>
|
||||
<div class="flex flex-col p-3 bg-base rounded-md gap-3 modal-box min-w-fit">
|
||||
<h1 class="text-[1.5rem]">{{ $t('examEnd') }}</h1>
|
||||
<div class="*:inline">{{ $t('doYouReallyWantToEndExam') }}</div>
|
||||
<div class="flex flex-row gap-2 justify-around">
|
||||
<div class="btn btn-lg btn-success" @click="emit('endExam')">
|
||||
{{ $t('yes') }}
|
||||
</div>
|
||||
<div class="btn btn-lg btn-error" @click="endModal?.close()">
|
||||
{{ $t('no') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</template>
|
||||
8
components/LoadingScreen.vue
Normal file
8
components/LoadingScreen.vue
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<template>
|
||||
<div
|
||||
class="flex min-h-dvh justify-center items-center text-5xl flex-col gap-10"
|
||||
>
|
||||
<span class="loading loading-spinner loading-xl scale-[2.5] block" />
|
||||
<span class="block">{{ $t('loading') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
80
components/MediaBox.vue
Normal file
80
components/MediaBox.vue
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<script setup lang="ts">
|
||||
import { joinURL } from 'ufo';
|
||||
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const cdnUrl = runtimeConfig.public.cdn_url;
|
||||
|
||||
const emit = defineEmits(['mediaload']);
|
||||
|
||||
const props = defineProps<{
|
||||
mediaPath: string | null | undefined;
|
||||
phase: string;
|
||||
}>();
|
||||
|
||||
const media = computed(() => {
|
||||
const dotSplit = props.mediaPath?.split('.');
|
||||
const extension = dotSplit?.pop()?.toLowerCase();
|
||||
let type = null;
|
||||
if (extension === 'jpg') {
|
||||
type = 'image';
|
||||
} else if (extension === 'wmv') {
|
||||
type = 'video';
|
||||
}
|
||||
return { name: dotSplit?.join('.'), type };
|
||||
});
|
||||
|
||||
const video = useTemplateRef('video');
|
||||
|
||||
function onVideoLoad() {
|
||||
if (props.phase != 'result') {
|
||||
const videoPlayInterval = setInterval(() => {
|
||||
if (video.value) {
|
||||
video.value.play();
|
||||
let duration = video.value.duration;
|
||||
if (isNaN(duration) || duration == Infinity) {
|
||||
duration = 0;
|
||||
}
|
||||
setTimeout(
|
||||
() => {
|
||||
emit('mediaload');
|
||||
},
|
||||
duration * 1000 + 1500,
|
||||
);
|
||||
clearInterval(videoPlayInterval);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="select-none flex-auto w-full *:object-contain *:w-full *:h-full *:max-h-full relative *:absolute"
|
||||
>
|
||||
<div
|
||||
class="w-full h-full opacity-0"
|
||||
:class="phase != 'result' ? 'z-10' : 'z-[-10]'"
|
||||
></div>
|
||||
<img v-if="phase == 'set-basic'" src="/placeholder.svg" alt="placeholder" />
|
||||
<NuxtImg
|
||||
v-else-if="media.type === 'image'"
|
||||
:key="`${mediaPath}-image`"
|
||||
provider="selfhost"
|
||||
:src="'/' + mediaPath"
|
||||
:alt="mediaPath ?? ''"
|
||||
@load="emit('mediaload')"
|
||||
/>
|
||||
<video
|
||||
v-else-if="media.type === 'video'"
|
||||
:key="`${mediaPath}-video`"
|
||||
ref="video"
|
||||
:controls="phase == 'result'"
|
||||
@canplaythrough="onVideoLoad()"
|
||||
>
|
||||
<source :src="joinURL(cdnUrl, media.name + '.mp4')" type="video/mp4" />
|
||||
</video>
|
||||
<span v-else class="text-5xl font-bold flex items-center justify-center">{{
|
||||
$t('questionWithoutVisual')
|
||||
}}</span>
|
||||
</div>
|
||||
</template>
|
||||
42
components/ResultModal.vue
Normal file
42
components/ResultModal.vue
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<script setup lang="ts">
|
||||
const myModal = useTemplateRef('myModal');
|
||||
|
||||
onMounted(() => {
|
||||
myModal.value?.showModal();
|
||||
});
|
||||
|
||||
defineEmits(['again', 'home']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dialog
|
||||
ref="myModal"
|
||||
class="flex justify-center items-center backdrop-blur-sm modal"
|
||||
>
|
||||
<div class="flex flex-col p-3 bg-base rounded-md gap-3 modal-box min-w-fit">
|
||||
<h1 class="text-[1.5rem]">
|
||||
<slot name="title" />
|
||||
</h1>
|
||||
<div class="*:inline">
|
||||
{{ $t('categoryWord') }}: <slot name="category" />
|
||||
</div>
|
||||
<div class="*:inline">
|
||||
{{ $t('points') }}: <slot name="points" /> / 74
|
||||
</div>
|
||||
<div class="*:inline">
|
||||
{{ $t('result') }}: <slot name="resultTrueFalse" />
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
<div class="btn btn-soft" @click="$emit('home')">
|
||||
{{ $t('goBackToHomePage') }}
|
||||
</div>
|
||||
<div class="btn btn-outline" @click="$emit('again')">
|
||||
{{ $t('startAgain') }}
|
||||
</div>
|
||||
<button class="btn btn-neutral" @click="myModal?.close()">
|
||||
{{ $t('viewAnswers') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</template>
|
||||
44
components/bar/Top.vue
Normal file
44
components/bar/Top.vue
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<script setup lang="ts">
|
||||
import type { Duration } from 'date-fns';
|
||||
|
||||
const props = defineProps<{
|
||||
points: number | null | undefined;
|
||||
category: string | undefined;
|
||||
timeRemaining?: Duration | undefined;
|
||||
}>();
|
||||
|
||||
const timeRemainingFriendly = computed(() => {
|
||||
if (typeof props.timeRemaining !== 'undefined') {
|
||||
const seconds = props.timeRemaining.seconds ?? 0;
|
||||
return `${props.timeRemaining.minutes ?? 0}:${
|
||||
seconds >= 0 && seconds < 10 ? 0 : ''
|
||||
}${seconds ?? 0}`;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-none flex-row gap-4 *:flex *:items-center *:gap-3 border-b p-4 border-base-300 bg-base-100"
|
||||
>
|
||||
<div>
|
||||
<span class="block">{{ $t('pointValue') }}</span>
|
||||
<div class="info-little-box">
|
||||
{{ points }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span class="block">{{ $t('currentCategory') }}</span>
|
||||
<div class="info-little-box">
|
||||
{{ category }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="typeof timeRemaining !== 'undefined'">
|
||||
<span class="block">{{ $t('timeToExamEnd') }}</span>
|
||||
<div class="info-little-box w-20 text-center">
|
||||
{{ timeRemainingFriendly }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
161
components/bar/right/Exam.vue
Normal file
161
components/bar/right/Exam.vue
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<script setup lang="ts">
|
||||
import { onKeyStroke } from '@vueuse/core';
|
||||
|
||||
const props = defineProps<{
|
||||
countBasic: number;
|
||||
countAdvanced: number;
|
||||
now: string | null | undefined;
|
||||
ending: boolean;
|
||||
setBasic: boolean;
|
||||
time: number;
|
||||
phase: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
endExam: [];
|
||||
nextQuestion: [];
|
||||
nextTime: [];
|
||||
showEndModal: [];
|
||||
}>();
|
||||
|
||||
function tryEndExam() {
|
||||
if (props.ending == false) {
|
||||
emit('showEndModal');
|
||||
} else {
|
||||
emit('endExam');
|
||||
}
|
||||
}
|
||||
|
||||
const startButton = useTemplateRef('start-button');
|
||||
|
||||
onKeyStroke(['S', 's'], () => {
|
||||
startButton.value?.click();
|
||||
});
|
||||
|
||||
const nextButton = useTemplateRef('next-button');
|
||||
|
||||
onKeyStroke(['D', 'd'], () => {
|
||||
nextButton.value?.click();
|
||||
});
|
||||
|
||||
const endButton = useTemplateRef('end-button');
|
||||
|
||||
onKeyStroke(['X', 'x'], () => {
|
||||
endButton.value?.click();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col items-stretch p-4 gap-10 border-l border-base-300 bg-base-100"
|
||||
>
|
||||
<button
|
||||
ref="end-button"
|
||||
class="btn btn-warning btn-xl"
|
||||
@click="tryEndExam()"
|
||||
>
|
||||
{{ $t('endExam') }}
|
||||
</button>
|
||||
|
||||
<div class="flex flex-row gap-6 *:flex-1 w-full">
|
||||
<CurrentQuestionCount
|
||||
:class="now === 'basic' ? 'font-semibold' : 'opacity-45'"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('basicQuestions') }}
|
||||
</template>
|
||||
<template #count> {{ countBasic + 1 }} / 20 </template>
|
||||
</CurrentQuestionCount>
|
||||
|
||||
<CurrentQuestionCount
|
||||
:class="now === 'advanced' ? 'font-semibold' : 'opacity-45'"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('advancedQuestions') }}
|
||||
</template>
|
||||
<template #count> {{ countAdvanced + 1 }} / 12 </template>
|
||||
</CurrentQuestionCount>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="phase == 'set-basic'"
|
||||
class="text-center text-xl flex flex-col gap-2"
|
||||
>
|
||||
<span>
|
||||
{{ $t('timeToGetAcquaintedWithTheQuestion') }}
|
||||
</span>
|
||||
<div class="flex flex-row items-stretch gap-2">
|
||||
<div
|
||||
ref="start-button"
|
||||
class="btn btn-primary"
|
||||
@click="emit('nextTime')"
|
||||
>
|
||||
{{ $t('startBtn') }}
|
||||
</div>
|
||||
<div class="h-full flex-1 relative">
|
||||
<progress
|
||||
class="progress progress-warning w-full h-full"
|
||||
:value="time"
|
||||
max="20"
|
||||
></progress>
|
||||
<span class="block set-translate z-10 text-black text-2xl">
|
||||
{{ time >= 0 ? time : 0 }} {{ $t('second') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="text-center text-xl flex flex-col gap-2">
|
||||
<span>
|
||||
{{ $t('timeForAnswer') }}
|
||||
</span>
|
||||
<div class="h-9 relative">
|
||||
<progress
|
||||
class="progress progress-warning w-full h-full"
|
||||
:value="time"
|
||||
:max="phase == 'start-basic' ? 15 : 45"
|
||||
></progress>
|
||||
<span class="block set-translate z-10 text-black text-2xl">
|
||||
{{ time >= 0 ? time : 0 }} {{ $t('second') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1">
|
||||
<span class="text-xl">
|
||||
{{ $t('keybinds') }}
|
||||
</span>
|
||||
<table class="table table-sm">
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="key in ['S', 'D', 'X', 'T / Y', 'N', 'A', 'B', 'C']"
|
||||
:key="`keybind${key}`"
|
||||
>
|
||||
<td>{{ key }}</td>
|
||||
<td>{{ $t(`bindedKeys.${key}`) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button
|
||||
ref="next-button"
|
||||
class="btn btn-warning btn-xl"
|
||||
:disabled="ending || setBasic"
|
||||
@click="emit('nextQuestion')"
|
||||
>
|
||||
{{ $t('nextQuestion') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.progressive {
|
||||
width: calc(100% / v-bind('time'));
|
||||
transition: all 1s linear;
|
||||
}
|
||||
|
||||
progress[value]::-webkit-progress-value {
|
||||
transition: width 0.5s;
|
||||
}
|
||||
</style>
|
||||
98
components/bar/right/Result.vue
Normal file
98
components/bar/right/Result.vue
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<script setup lang="ts">
|
||||
import { range } from 'lodash';
|
||||
|
||||
defineProps<{
|
||||
result: ResultEndType;
|
||||
countBasic: number;
|
||||
countAdvanced: number;
|
||||
now: string | null | undefined;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
changeNow: [value: string];
|
||||
changeCount: [num: number];
|
||||
again: [];
|
||||
home: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col items-stretch p-4 gap-6 border-l border-base-300 bg-base-100"
|
||||
>
|
||||
<div class="btn btn-warning btn-xl" @click="$emit('home')">
|
||||
{{ $t('goBackToHomePage') }}
|
||||
</div>
|
||||
|
||||
<button class="btn btn-info btn-lg" @click="emit('changeNow', 'basic')">
|
||||
{{ $t('basicQuestions') }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="grid grid-cols-[repeat(auto-fit,50px)] gap-2 justify-around w-full"
|
||||
>
|
||||
<input
|
||||
v-for="num in range(0, 20)"
|
||||
:key="`choose-${num}-basic`"
|
||||
type="radio"
|
||||
:aria-label="(num + 1).toString()"
|
||||
class="btn btn-md"
|
||||
name="chooser"
|
||||
:class="`${
|
||||
result.basic[num].chosen_answer == ''
|
||||
? 'btn-warning'
|
||||
: result.basic[num].question?.correct_answer ===
|
||||
result.basic[num].chosen_answer
|
||||
? 'btn-success'
|
||||
: 'btn-error'
|
||||
} ${now === 'basic' && countBasic === num ? 'outline-set-solid outline-2' : ''}`"
|
||||
:checked="now === 'basic' ? countBasic === num : false"
|
||||
@click="
|
||||
emit('changeNow', 'basic');
|
||||
emit('changeCount', num);
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-info btn-lg" @click="emit('changeNow', 'advanced')">
|
||||
{{ $t('advancedQuestions') }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="grid grid-cols-[repeat(auto-fit,50px)] gap-2 justify-around w-full"
|
||||
>
|
||||
<input
|
||||
v-for="num in range(0, 12)"
|
||||
:key="`choose-${num}-advanced`"
|
||||
type="radio"
|
||||
:aria-label="`${num + 1}`"
|
||||
class="btn btn-md"
|
||||
name="chooser"
|
||||
:class="`${
|
||||
result.advanced[num].chosen_answer == ''
|
||||
? 'btn-warning'
|
||||
: result.advanced[num].question?.correct_answer ===
|
||||
result.advanced[num].chosen_answer
|
||||
? 'btn-success'
|
||||
: 'btn-error'
|
||||
} ${now === 'advanced' && countAdvanced === num ? 'outline-set-solid outline-2' : ''}`"
|
||||
:checked="now === 'advanced' ? countAdvanced === num : false"
|
||||
@click="
|
||||
emit('changeNow', 'advanced');
|
||||
emit('changeCount', num);
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<div class="*:inline">
|
||||
{{ $t('points') }}: <slot name="points" /> / 74
|
||||
</div>
|
||||
<div class="*:inline">
|
||||
{{ $t('result') }}: <slot name="resultTrueFalse" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-warning btn-xl" @click="$emit('again')">
|
||||
{{ $t('startAgain') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
91
components/question/Advanced.vue
Normal file
91
components/question/Advanced.vue
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<script lang="ts" setup>
|
||||
import { onKeyStroke } from '@vueuse/core';
|
||||
|
||||
const props = defineProps<{
|
||||
question: Question;
|
||||
phase: string;
|
||||
}>();
|
||||
|
||||
const answer = defineModel<string | null | undefined>();
|
||||
|
||||
const aButton = useTemplateRef('A-button');
|
||||
|
||||
onKeyStroke(['A', 'a'], () => {
|
||||
if (props.phase != 'result') {
|
||||
aButton.value[0].click();
|
||||
}
|
||||
});
|
||||
|
||||
const bButton = useTemplateRef('B-button');
|
||||
|
||||
onKeyStroke(['B', 'b'], () => {
|
||||
if (props.phase != 'result') {
|
||||
bButton.value[0].click();
|
||||
}
|
||||
});
|
||||
|
||||
const cButton = useTemplateRef('C-button');
|
||||
|
||||
onKeyStroke(['C', 'c'], () => {
|
||||
if (props.phase != 'result') {
|
||||
cButton.value[0].click();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col gap-5 border-t px-4 py-5 border-base-300 bg-base-100"
|
||||
>
|
||||
<div class="text-xl">
|
||||
{{ question?.text }}
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div
|
||||
v-for="[element, value] of Object.entries({
|
||||
A: (question as AdvancedQuestion)?.answer_a,
|
||||
B: (question as AdvancedQuestion)?.answer_b,
|
||||
C: (question as AdvancedQuestion)?.answer_c,
|
||||
})"
|
||||
:key="`btn_answer_${element}_${value}`"
|
||||
>
|
||||
<input
|
||||
:id="`odp_${element}`"
|
||||
:ref="`${element}-button`"
|
||||
v-model="answer"
|
||||
type="radio"
|
||||
name="abc"
|
||||
:value="element"
|
||||
class="hidden"
|
||||
/>
|
||||
<label :for="`odp_${element}`">
|
||||
<div
|
||||
:class="
|
||||
phase == 'exam'
|
||||
? answer === element
|
||||
? ' !btn-secondary'
|
||||
: ''
|
||||
: `${answer === element ? 'outline-set-solid outline-2' : ''} ${element == question?.correct_answer ? 'btn-success' : 'btn-error'}`
|
||||
"
|
||||
class="btn btn-primary btn-lg"
|
||||
>
|
||||
{{ element }}
|
||||
</div>
|
||||
<span class="block">{{ value }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
label {
|
||||
@apply cursor-pointer flex flex-row gap-2 items-center;
|
||||
&:hover {
|
||||
@apply bg-base-200;
|
||||
}
|
||||
}
|
||||
span {
|
||||
@apply text-lg;
|
||||
}
|
||||
</style>
|
||||
70
components/question/Basic.vue
Normal file
70
components/question/Basic.vue
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<script lang="ts" setup>
|
||||
import { onKeyStroke } from '@vueuse/core';
|
||||
|
||||
const props = defineProps<{
|
||||
question: Question;
|
||||
phase: string;
|
||||
}>();
|
||||
|
||||
const answer = defineModel<string | null | undefined>();
|
||||
|
||||
const yesButton = useTemplateRef('true-button');
|
||||
|
||||
onKeyStroke(['T', 't', 'Y', 'y'], () => {
|
||||
if (props.phase != 'result') {
|
||||
yesButton.value[0].click();
|
||||
}
|
||||
});
|
||||
|
||||
const noButton = useTemplateRef('false-button');
|
||||
|
||||
onKeyStroke(['N', 'n'], () => {
|
||||
if (props.phase != 'result') {
|
||||
noButton.value[0].click();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-none flex-col gap-6 border-t px-4 py-5 border-base-300 bg-base-100"
|
||||
>
|
||||
<div class="text-xl">
|
||||
{{ question?.text }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex flex-row justify-around">
|
||||
<input
|
||||
v-for="[element, value] of Object.entries({ yes: true, no: false })"
|
||||
:id="`odp_${element}`"
|
||||
:ref="`${value}-button`"
|
||||
:key="`btn_answer_${element}`"
|
||||
v-model="answer"
|
||||
type="radio"
|
||||
name="tak_nie"
|
||||
:value="value.toString()"
|
||||
class="btn btn-primary btn-xl"
|
||||
:aria-label="$t(element).toLocaleUpperCase()"
|
||||
:class="
|
||||
phase == 'exam'
|
||||
? answer == null
|
||||
? false
|
||||
: answer === value.toString()
|
||||
? '!btn-secondary'
|
||||
: ''
|
||||
: `${
|
||||
answer === value.toString()
|
||||
? 'outline-set-solid outline-2'
|
||||
: ''
|
||||
} ${
|
||||
question?.correct_answer?.toString() == value.toString()
|
||||
? ' btn-success'
|
||||
: ' btn-error'
|
||||
}`
|
||||
"
|
||||
:checked="answer == null ? false : answer === value.toString()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
BIN
db/database.db
Normal file
BIN
db/database.db
Normal file
Binary file not shown.
36
db/schema.ts
Normal file
36
db/schema.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { sqliteTable, text, int } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
|
||||
export const tasks = sqliteTable('tasks', {
|
||||
id: int().notNull(),
|
||||
correct_answer: text(),
|
||||
media_url: text(),
|
||||
weight: int(),
|
||||
});
|
||||
|
||||
export const questions = sqliteTable('questions', {
|
||||
task_id: int(),
|
||||
lang: text(),
|
||||
text: text(),
|
||||
});
|
||||
|
||||
export const tasks_advanced = sqliteTable('tasks_advanced', {
|
||||
id: int().notNull(),
|
||||
correct_answer: text(),
|
||||
media_url: text(),
|
||||
weight: int(),
|
||||
});
|
||||
|
||||
export const questions_advanced = sqliteTable('questions_advanced', {
|
||||
task_id: int(),
|
||||
lang: text(),
|
||||
text: text(),
|
||||
answer_a: text(),
|
||||
answer_b: text(),
|
||||
answer_c: text(),
|
||||
});
|
||||
|
||||
export const categories_db = sqliteTable('categories', {
|
||||
name: text(),
|
||||
task_id: int(),
|
||||
});
|
||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
prawojazdy:
|
||||
container_name: prawojazdy
|
||||
build: .
|
||||
ports:
|
||||
- 33550:33550
|
||||
env_file: '.env'
|
||||
11
drizzle.config.ts
Normal file
11
drizzle.config.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import 'dotenv/config';
|
||||
import { defineConfig } from 'drizzle-kit';
|
||||
|
||||
export default defineConfig({
|
||||
out: './drizzle',
|
||||
schema: './db/schema.ts',
|
||||
dialect: 'sqlite',
|
||||
dbCredentials: {
|
||||
url: process.env.DATABASE_URL!,
|
||||
},
|
||||
});
|
||||
8
eslint.config.mjs
Normal file
8
eslint.config.mjs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// @ts-check
|
||||
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||
import withNuxt from './.nuxt/eslint.config.mjs';
|
||||
|
||||
export default withNuxt(
|
||||
// Your custom configs here
|
||||
eslintConfigPrettier,
|
||||
);
|
||||
79
i18n/locales/de.json
Normal file
79
i18n/locales/de.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"mainTitle": "Test na prawo jazdy",
|
||||
"loading": "Ładowanie",
|
||||
"keybinds": "Skróty klawiszowe",
|
||||
"bindedKeys": {
|
||||
"S": "niebieski przycisk start",
|
||||
"D": "następne pytanie",
|
||||
"X": "zakończ egzamin",
|
||||
"T / Y": "Tak",
|
||||
"N": "Nie",
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C"
|
||||
},
|
||||
"yes": "Tak",
|
||||
"no": "Nie",
|
||||
"theme": "Motyw",
|
||||
"light": "Jasny",
|
||||
"dark": "Ciemny",
|
||||
"auto": "Automatyczny",
|
||||
"endExam": "Zakończ egzamin",
|
||||
"examEnd": "Koniec egzaminu",
|
||||
"basicQuestions": "Pytania podstawowe",
|
||||
"advancedQuestions": "Pytania specjalistyczne",
|
||||
"timeToGetAcquaintedWithTheQuestion": "Czas na zapoznanie się z pytaniem",
|
||||
"timeForAnswer": "Czas na udzielenie odpowiedzi",
|
||||
"startBtn": "START",
|
||||
"second": "s",
|
||||
"nextQuestion": "Następne pytanie",
|
||||
"goBackToHomePage": "Wróć na stronę główną",
|
||||
"points": "Punkty",
|
||||
"pointValue": "Wartość punktowa",
|
||||
"currentCategory": "Aktualna kategoria",
|
||||
"timeToExamEnd": "Czas do końca egzaminu",
|
||||
"result": "Wynik",
|
||||
"startAgain": "Rozpocznij jeszcze raz",
|
||||
"viewAnswers": "Przejrzyj odpowiedzi",
|
||||
"doYouReallyWantToEndExam": "Czy na pewno chcesz zakończyć egzamin?",
|
||||
"questionWithoutVisual": "Pytanie bez wizualizacji",
|
||||
"categoryWord": "Kategoria",
|
||||
"anAnomalyHasOccured": "Nastąpiła anomalia",
|
||||
"redirectFrom": "Przekierowanie z",
|
||||
"end": "Koniec",
|
||||
"question": "Pytanie",
|
||||
"anAPIErrorOccured": "Wystąpił błąd z API",
|
||||
"positive": "pozytywny",
|
||||
"negative": "negatywny",
|
||||
"theoreticalExam": "Egzamin teorytyczny",
|
||||
"category": {
|
||||
"description": {
|
||||
"A": "motocykle bez ograniczeń mocy",
|
||||
"B": "⭐ samochody osobowe do 3,5 t",
|
||||
"C": "pojazdy ciężarowe powyżej 3,5 t",
|
||||
"D": "autobusy",
|
||||
"T": "ciągniki rolnicze i pojazdy wolnobieżne",
|
||||
"AM": "motorowery i lekkie czterokołowce",
|
||||
"A1": "motocykle do 125 cm³ i 11 kW",
|
||||
"A2": "motocykle do 35 kW",
|
||||
"B1": "czterokołowce (np. quady)",
|
||||
"C1": "pojazdy od 3,5 t do 7,5 t",
|
||||
"D1": "autobusy do 16 pasażerów",
|
||||
"PT": "tramwaje"
|
||||
},
|
||||
"age": {
|
||||
"A": "(24 lata; lub 20 lat jeśli masz kat. A2 min. 2 lata)",
|
||||
"B": "(18 lat)",
|
||||
"C": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"D": "(24 lata; lub 21 lat z kwalifikacją wstępną)",
|
||||
"T": "(16 lat)",
|
||||
"AM": "(14 lat)",
|
||||
"A1": "(16 lat)",
|
||||
"A2": "(18 lat)",
|
||||
"B1": "(16 lat)",
|
||||
"C1": "(18 lat)",
|
||||
"D1": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"PT": "(21 lat)"
|
||||
}
|
||||
}
|
||||
}
|
||||
79
i18n/locales/en.json
Normal file
79
i18n/locales/en.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"mainTitle": "Driving exam",
|
||||
"loading": "Loading",
|
||||
"keybinds": "Keybinds",
|
||||
"bindedKeys": {
|
||||
"S": "blue \"start\" button",
|
||||
"D": "next question",
|
||||
"X": "finish exam",
|
||||
"T / Y": "Yes",
|
||||
"N": "No",
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C"
|
||||
},
|
||||
"yes": "Yes",
|
||||
"no": "No",
|
||||
"theme": "Theme",
|
||||
"light": "Light",
|
||||
"dark": "Dark",
|
||||
"auto": "Auto",
|
||||
"endExam": "Finish exam",
|
||||
"examEnd": "Exam finished",
|
||||
"basicQuestions": "Basic questions",
|
||||
"advancedQuestions": "Advanced questions",
|
||||
"timeToGetAcquaintedWithTheQuestion": "Time to get acquainted with the question",
|
||||
"timeForAnswer": "Time to answer",
|
||||
"startBtn": "START",
|
||||
"second": "s",
|
||||
"nextQuestion": "Next question",
|
||||
"goBackToHomePage": "Back to homepage",
|
||||
"points": "Points",
|
||||
"pointValue": "Point value",
|
||||
"currentCategory": "Current category",
|
||||
"timeToExamEnd": "Time until the exam's finished",
|
||||
"result": "Result",
|
||||
"startAgain": "Start again",
|
||||
"viewAnswers": "View answers",
|
||||
"doYouReallyWantToEndExam": "Are you sure you want to finish the exam?",
|
||||
"questionWithoutVisual": "Question without visualization",
|
||||
"categoryWord": "Category",
|
||||
"anAnomalyHasOccured": "An anomaly has occured",
|
||||
"redirectFrom": "Redirecting from",
|
||||
"end": "End",
|
||||
"question": "Question",
|
||||
"anAPIErrorOccured": "An API error has occured",
|
||||
"positive": "positive",
|
||||
"negative": "negative",
|
||||
"theoreticalExam": "Theoretical exam",
|
||||
"category": {
|
||||
"description": {
|
||||
"A": "motorcycle without limited power",
|
||||
"B": "⭐ passenger cars up to 3,5 t",
|
||||
"C": "trucks above 3,5 t",
|
||||
"D": "buses",
|
||||
"T": "agricultural tractor and low-speed vehicles",
|
||||
"AM": "motobikes and light quadricycles",
|
||||
"A1": "motorcycles up to 125 cm³ and 11 kW",
|
||||
"A2": "motorcycles up to 35 kW",
|
||||
"B1": "quadricycles (e.g quads)",
|
||||
"C1": "vehicles from 3,5 t to 7,5 t",
|
||||
"D1": "buses up to 16 passengers",
|
||||
"PT": "trams"
|
||||
},
|
||||
"age": {
|
||||
"A": "(24 years; or 20 years if you've had category A2 for at least 2 years)",
|
||||
"B": "(18 years)",
|
||||
"C": "(21 years; or 18 years with preliminary qualification)",
|
||||
"D": "(24 years; or 21 years with preliminary qualification)",
|
||||
"T": "(16 years)",
|
||||
"AM": "(14 years)",
|
||||
"A1": "(16 years)",
|
||||
"A2": "(18 years)",
|
||||
"B1": "(16 years)",
|
||||
"C1": "(18 years)",
|
||||
"D1": "(21 years; or 18 years with preliminary qualification)",
|
||||
"PT": "(21 years)"
|
||||
}
|
||||
}
|
||||
}
|
||||
79
i18n/locales/pl.json
Normal file
79
i18n/locales/pl.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"mainTitle": "Test na prawo jazdy",
|
||||
"loading": "Ładowanie",
|
||||
"keybinds": "Skróty klawiszowe",
|
||||
"bindedKeys": {
|
||||
"S": "niebieski przycisk start",
|
||||
"D": "następne pytanie",
|
||||
"X": "zakończ egzamin",
|
||||
"T / Y": "Tak",
|
||||
"N": "Nie",
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C"
|
||||
},
|
||||
"yes": "Tak",
|
||||
"no": "Nie",
|
||||
"theme": "Motyw",
|
||||
"light": "Jasny",
|
||||
"dark": "Ciemny",
|
||||
"auto": "Automatyczny",
|
||||
"endExam": "Zakończ egzamin",
|
||||
"examEnd": "Koniec egzaminu",
|
||||
"basicQuestions": "Pytania podstawowe",
|
||||
"advancedQuestions": "Pytania specjalistyczne",
|
||||
"timeToGetAcquaintedWithTheQuestion": "Czas na zapoznanie się z pytaniem",
|
||||
"timeForAnswer": "Czas na udzielenie odpowiedzi",
|
||||
"startBtn": "START",
|
||||
"second": "s",
|
||||
"nextQuestion": "Następne pytanie",
|
||||
"goBackToHomePage": "Wróć na stronę główną",
|
||||
"points": "Punkty",
|
||||
"pointValue": "Wartość punktowa",
|
||||
"currentCategory": "Aktualna kategoria",
|
||||
"timeToExamEnd": "Czas do końca egzaminu",
|
||||
"result": "Wynik",
|
||||
"startAgain": "Rozpocznij jeszcze raz",
|
||||
"viewAnswers": "Przejrzyj odpowiedzi",
|
||||
"doYouReallyWantToEndExam": "Czy na pewno chcesz zakończyć egzamin?",
|
||||
"questionWithoutVisual": "Pytanie bez wizualizacji",
|
||||
"categoryWord": "Kategoria",
|
||||
"anAnomalyHasOccured": "Nastąpiła anomalia",
|
||||
"redirectFrom": "Przekierowanie z",
|
||||
"end": "Koniec",
|
||||
"question": "Pytanie",
|
||||
"anAPIErrorOccured": "Wystąpił błąd z API",
|
||||
"positive": "pozytywny",
|
||||
"negative": "negatywny",
|
||||
"theoreticalExam": "Egzamin teorytyczny",
|
||||
"category": {
|
||||
"description": {
|
||||
"A": "motocykle bez ograniczeń mocy",
|
||||
"B": "⭐ samochody osobowe do 3,5 t",
|
||||
"C": "pojazdy ciężarowe powyżej 3,5 t",
|
||||
"D": "autobusy",
|
||||
"T": "ciągniki rolnicze i pojazdy wolnobieżne",
|
||||
"AM": "motorowery i lekkie czterokołowce",
|
||||
"A1": "motocykle do 125 cm³ i 11 kW",
|
||||
"A2": "motocykle do 35 kW",
|
||||
"B1": "czterokołowce (np. quady)",
|
||||
"C1": "pojazdy od 3,5 t do 7,5 t",
|
||||
"D1": "autobusy do 16 pasażerów",
|
||||
"PT": "tramwaje"
|
||||
},
|
||||
"age": {
|
||||
"A": "(24 lata; lub 20 lat jeśli masz kat. A2 min. 2 lata)",
|
||||
"B": "(18 lat)",
|
||||
"C": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"D": "(24 lata; lub 21 lat z kwalifikacją wstępną)",
|
||||
"T": "(16 lat)",
|
||||
"AM": "(14 lat)",
|
||||
"A1": "(16 lat)",
|
||||
"A2": "(18 lat)",
|
||||
"B1": "(16 lat)",
|
||||
"C1": "(18 lat)",
|
||||
"D1": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"PT": "(21 lat)"
|
||||
}
|
||||
}
|
||||
}
|
||||
79
i18n/locales/ua.json
Normal file
79
i18n/locales/ua.json
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"mainTitle": "Test na prawo jazdy",
|
||||
"loading": "Ładowanie",
|
||||
"keybinds": "Skróty klawiszowe",
|
||||
"bindedKeys": {
|
||||
"S": "niebieski przycisk start",
|
||||
"D": "następne pytanie",
|
||||
"X": "zakończ egzamin",
|
||||
"T / Y": "Tak",
|
||||
"N": "Nie",
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C"
|
||||
},
|
||||
"yes": "Tak",
|
||||
"no": "Nie",
|
||||
"theme": "Motyw",
|
||||
"light": "Jasny",
|
||||
"dark": "Ciemny",
|
||||
"auto": "Automatyczny",
|
||||
"endExam": "Zakończ egzamin",
|
||||
"examEnd": "Koniec egzaminu",
|
||||
"basicQuestions": "Pytania podstawowe",
|
||||
"advancedQuestions": "Pytania specjalistyczne",
|
||||
"timeToGetAcquaintedWithTheQuestion": "Czas na zapoznanie się z pytaniem",
|
||||
"timeForAnswer": "Czas na udzielenie odpowiedzi",
|
||||
"startBtn": "START",
|
||||
"second": "s",
|
||||
"nextQuestion": "Następne pytanie",
|
||||
"goBackToHomePage": "Wróć na stronę główną",
|
||||
"points": "Punkty",
|
||||
"pointValue": "Wartość punktowa",
|
||||
"currentCategory": "Aktualna kategoria",
|
||||
"timeToExamEnd": "Czas do końca egzaminu",
|
||||
"result": "Wynik",
|
||||
"startAgain": "Rozpocznij jeszcze raz",
|
||||
"viewAnswers": "Przejrzyj odpowiedzi",
|
||||
"doYouReallyWantToEndExam": "Czy na pewno chcesz zakończyć egzamin?",
|
||||
"questionWithoutVisual": "Pytanie bez wizualizacji",
|
||||
"categoryWord": "Kategoria",
|
||||
"anAnomalyHasOccured": "Nastąpiła anomalia",
|
||||
"redirectFrom": "Przekierowanie z",
|
||||
"end": "Koniec",
|
||||
"question": "Pytanie",
|
||||
"anAPIErrorOccured": "Wystąpił błąd z API",
|
||||
"positive": "pozytywny",
|
||||
"negative": "negatywny",
|
||||
"theoreticalExam": "Egzamin teorytyczny",
|
||||
"category": {
|
||||
"description": {
|
||||
"A": "motocykle bez ograniczeń mocy",
|
||||
"B": "⭐ samochody osobowe do 3,5 t",
|
||||
"C": "pojazdy ciężarowe powyżej 3,5 t",
|
||||
"D": "autobusy",
|
||||
"T": "ciągniki rolnicze i pojazdy wolnobieżne",
|
||||
"AM": "motorowery i lekkie czterokołowce",
|
||||
"A1": "motocykle do 125 cm³ i 11 kW",
|
||||
"A2": "motocykle do 35 kW",
|
||||
"B1": "czterokołowce (np. quady)",
|
||||
"C1": "pojazdy od 3,5 t do 7,5 t",
|
||||
"D1": "autobusy do 16 pasażerów",
|
||||
"PT": "tramwaje"
|
||||
},
|
||||
"age": {
|
||||
"A": "(24 lata; lub 20 lat jeśli masz kat. A2 min. 2 lata)",
|
||||
"B": "(18 lat)",
|
||||
"C": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"D": "(24 lata; lub 21 lat z kwalifikacją wstępną)",
|
||||
"T": "(16 lat)",
|
||||
"AM": "(14 lat)",
|
||||
"A1": "(16 lat)",
|
||||
"A2": "(18 lat)",
|
||||
"B1": "(16 lat)",
|
||||
"C1": "(18 lat)",
|
||||
"D1": "(21 lat; lub 18 lat z kwalifikacją wstępną)",
|
||||
"PT": "(21 lat)"
|
||||
}
|
||||
}
|
||||
}
|
||||
11
middleware/exam.ts
Normal file
11
middleware/exam.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const examStore = useExamStore();
|
||||
const localePath = useLocalePath();
|
||||
|
||||
if (examStore.end) {
|
||||
return localePath('result');
|
||||
}
|
||||
if (examStore.category === '') {
|
||||
return localePath('anomaly');
|
||||
}
|
||||
});
|
||||
7
middleware/result.ts
Normal file
7
middleware/result.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const examStore = useExamStore();
|
||||
const localePath = useLocalePath();
|
||||
if (!examStore.end || examStore.category === '') {
|
||||
return localePath('anomaly');
|
||||
}
|
||||
});
|
||||
63
nuxt.config.ts
Normal file
63
nuxt.config.ts
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
import 'dotenv/config';
|
||||
|
||||
export default defineNuxtConfig({
|
||||
modules: [
|
||||
'@nuxtjs/tailwindcss',
|
||||
'@nuxt/fonts',
|
||||
'@pinia/nuxt',
|
||||
'pinia-plugin-persistedstate/nuxt',
|
||||
'@nuxt/eslint',
|
||||
'@nuxt/image',
|
||||
'@nuxtjs/i18n',
|
||||
],
|
||||
ssr: false,
|
||||
imports: {
|
||||
dirs: ['types/*.ts', 'store/*.ts', 'types/**/*.ts'],
|
||||
},
|
||||
devtools: { enabled: true },
|
||||
css: ['~/assets/main.css'],
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
cdn_url: process.env.CDN_URL,
|
||||
},
|
||||
},
|
||||
routeRules: {
|
||||
'/': { prerender: true },
|
||||
},
|
||||
compatibilityDate: '2024-11-01',
|
||||
eslint: {
|
||||
config: {
|
||||
stylistic: {
|
||||
indent: 2,
|
||||
semi: true,
|
||||
quotes: 'single',
|
||||
jsx: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
i18n: {
|
||||
locales: [
|
||||
{ code: 'pl', language: 'pl-PL', file: 'pl.json' },
|
||||
{ code: 'en', language: 'en-GB', file: 'en.json' },
|
||||
{ code: 'de', language: 'de-DE', file: 'de.json' },
|
||||
{ code: 'ua', language: 'uk-UK', file: 'ua.json' },
|
||||
],
|
||||
defaultLocale: 'pl',
|
||||
},
|
||||
image: {
|
||||
providers: {
|
||||
selfhost: {
|
||||
name: 'selfhost',
|
||||
provider: '~/providers/selfhost.ts',
|
||||
options: {
|
||||
baseUrl: process.env.CDN_URL,
|
||||
},
|
||||
},
|
||||
},
|
||||
provider: 'selfhost',
|
||||
},
|
||||
pinia: {
|
||||
storesDirs: ['./store/**'],
|
||||
},
|
||||
});
|
||||
50
package.json
Normal file
50
package.json
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "nuxt-app",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"pretty": "prettier --write \"./**/*.{js,mjs,ts,vue,json}\"",
|
||||
"tsc": "nuxi typecheck"
|
||||
},
|
||||
"dependencies": {
|
||||
"@libsql/client": "^0.15.15",
|
||||
"@nuxt/fonts": "0.11.1",
|
||||
"@nuxt/image": "1.10.0",
|
||||
"@nuxtjs/i18n": "10.2.1",
|
||||
"@nuxtjs/tailwindcss": "6.13.2",
|
||||
"@pinia/nuxt": "0.11.0",
|
||||
"@vueuse/core": "^14.1.0",
|
||||
"array-shuffle": "^3.0.0",
|
||||
"daisyui": "^5.0.27",
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"drizzle-kit": "^0.31.0",
|
||||
"drizzle-orm": "^0.42.0",
|
||||
"eslint": "^9.24.0",
|
||||
"lodash": "^4.17.21",
|
||||
"nuxt": "~3.16.2",
|
||||
"pinia": "^3.0.2",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"ufo": "^1.6.1",
|
||||
"vue": "latest",
|
||||
"vue-country-flag-next": "^2.3.2",
|
||||
"vue-router": "latest"
|
||||
},
|
||||
"packageManager": "pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af",
|
||||
"devDependencies": {
|
||||
"@nuxt/eslint": "1.3.0",
|
||||
"@types/lodash": "^4.17.16",
|
||||
"eslint-config-prettier": "^10.1.2",
|
||||
"prettier": "^3.5.3",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.8.3",
|
||||
"vite-plugin-eslint2": "^5.0.3"
|
||||
}
|
||||
}
|
||||
25
pages/anomaly.vue
Normal file
25
pages/anomaly.vue
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<script setup lang="ts">
|
||||
const examStore = useExamStore();
|
||||
const basicStore = useBasicStore();
|
||||
const advancedStore = useAdvancedStore();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2 items-start m-2">
|
||||
<h1 class="text-2xl">{{ $t('anAnomalyHasOccured') }}</h1>
|
||||
<br />
|
||||
{{ $t('redirectFrom') }}: {{ useRoute().redirectedFrom ?? '""' }} <br />
|
||||
{{ $t('categoryWord') }}:
|
||||
{{ examStore.category != '' ? examStore.category : '""' }}
|
||||
<br />
|
||||
{{ $t('end') }}: {{ examStore.end }} <br />
|
||||
{{ $t('basicQuestions') }}:
|
||||
<code class="text-xs">{{ basicStore.basic }}</code>
|
||||
<br />
|
||||
{{ $t('advancedQuestions') }}:
|
||||
<code class="text-xs">{{ advancedStore.advanced }}</code> <br />
|
||||
<NuxtLink :to="$localePath('index')" class="btn btn-primary">
|
||||
{{ $t('goBackToHomePage') }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
274
pages/exam.vue
Normal file
274
pages/exam.vue
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
<script lang="ts" setup>
|
||||
import { intervalToDuration, addMinutes, addSeconds, isAfter } from 'date-fns';
|
||||
import { useNow } from '@vueuse/core';
|
||||
import { useExamStore } from '~/store/examStore';
|
||||
|
||||
definePageMeta({ middleware: 'exam' });
|
||||
|
||||
const examStore = useExamStore();
|
||||
const basicStore = useBasicStore();
|
||||
const advancedStore = useAdvancedStore();
|
||||
await callOnce(() => examStore.mildReset(), { mode: 'navigation' });
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function preventRefresh(e: any) {
|
||||
e.preventDefault();
|
||||
e.returnValue = ''; // polyfill for older chrome
|
||||
}
|
||||
|
||||
const now = ref('basic');
|
||||
|
||||
const nowTime = useNow();
|
||||
const timeEnd = addMinutes(new Date(), 25);
|
||||
|
||||
const questionEnd = ref(addSeconds(new Date(), 20));
|
||||
|
||||
const mediaLoaded = ref(false);
|
||||
|
||||
const time = ref({
|
||||
total: computed(() =>
|
||||
intervalToDuration({
|
||||
start: nowTime.value,
|
||||
end: timeEnd,
|
||||
}),
|
||||
),
|
||||
question: computed(() => {
|
||||
const interval = intervalToDuration({
|
||||
start: nowTime.value,
|
||||
end: questionEnd.value,
|
||||
});
|
||||
if (Object.hasOwn(interval, 'seconds') && interval.seconds != undefined) {
|
||||
return interval.seconds;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}),
|
||||
phase: 'set-basic',
|
||||
});
|
||||
|
||||
function changeQuestionTimeAfterNext() {
|
||||
if (time.value.phase == 'set-basic') {
|
||||
time.value.phase = 'start-basic';
|
||||
questionEnd.value = addSeconds(new Date(), 15);
|
||||
} else if (time.value.phase == 'start-basic') {
|
||||
if (now.value == 'basic') {
|
||||
time.value.phase = 'set-basic';
|
||||
mediaLoaded.value = false;
|
||||
questionEnd.value = addSeconds(new Date(), 20);
|
||||
} else {
|
||||
time.value.phase = 'set-advanced';
|
||||
questionEnd.value = addSeconds(new Date(), 50);
|
||||
}
|
||||
} else if (time.value.phase == 'set-advanced') {
|
||||
questionEnd.value = addSeconds(new Date(), 50);
|
||||
}
|
||||
}
|
||||
|
||||
function onMediaLoad() {
|
||||
mediaLoaded.value = true;
|
||||
}
|
||||
|
||||
function clickNext() {
|
||||
if (ending.value) {
|
||||
endExam();
|
||||
}
|
||||
if (time.value.phase != 'set-basic') {
|
||||
next();
|
||||
}
|
||||
changeQuestionTimeAfterNext();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
useHead({
|
||||
title: `${$t('question')} 1/20`,
|
||||
});
|
||||
window.addEventListener('beforeunload', preventRefresh);
|
||||
|
||||
watchEffect(() => {
|
||||
if (isAfter(nowTime.value, timeEnd)) endExam();
|
||||
});
|
||||
|
||||
watchEffect(() => {
|
||||
if (now.value === 'basic')
|
||||
useHead({ title: `${$t('question')} ${countBasic.value + 1}/20` });
|
||||
if (now.value === 'advanced')
|
||||
useHead({ title: `${$t('question')} ${countAdvanced.value + 1}/12` });
|
||||
});
|
||||
|
||||
watchEffect(() => {
|
||||
if (mediaLoaded.value == false && time.value.phase == 'start-basic') {
|
||||
questionEnd.value = addSeconds(new Date(), 15);
|
||||
}
|
||||
if (time.value.question < 0 && ending.value == false) {
|
||||
clickNext();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('beforeunload', preventRefresh);
|
||||
});
|
||||
|
||||
const {
|
||||
data: dataBasic,
|
||||
error: errorBasic,
|
||||
status: statusBasic,
|
||||
} = await useLazyFetch<BasicQuestion[]>(`/api/basic`, {
|
||||
query: {
|
||||
category: examStore.category,
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
data: dataAdvanced,
|
||||
error: errorAdvanced,
|
||||
status: statusAdvanced,
|
||||
} = await useLazyFetch<AdvancedQuestion[]>(`/api/advanced`, {
|
||||
query: {
|
||||
category: examStore.category,
|
||||
},
|
||||
});
|
||||
|
||||
const countBasic = ref(0);
|
||||
const countAdvanced = ref(-1);
|
||||
|
||||
const answer = ref<string>('');
|
||||
|
||||
const ending = ref(false);
|
||||
|
||||
const questionBasic = computed<BasicQuestion | undefined>(() =>
|
||||
dataBasic.value?.at(countBasic.value),
|
||||
);
|
||||
const questionAdvanced = computed<AdvancedQuestion | undefined>(() =>
|
||||
dataAdvanced.value?.at(countAdvanced.value),
|
||||
);
|
||||
|
||||
const question = computed(() => {
|
||||
if (now.value === 'basic') return questionBasic.value;
|
||||
if (now.value === 'advanced') return questionAdvanced.value;
|
||||
return null;
|
||||
});
|
||||
|
||||
const result: Ref<ResultEndType> = ref({
|
||||
basic: [],
|
||||
advanced: [],
|
||||
});
|
||||
|
||||
function next() {
|
||||
if (examStore.end == false) {
|
||||
result.value[now.value as keyof ResultEndType].push({
|
||||
question: question.value,
|
||||
chosen_answer: answer.value,
|
||||
correct_answer: question.value?.correct_answer ?? null,
|
||||
chosen_is_correct: answer.value == question.value?.correct_answer,
|
||||
});
|
||||
answer.value = '';
|
||||
} else {
|
||||
console.error('next() incorrectly executed - exam has already ended.');
|
||||
}
|
||||
if (now.value === 'basic') {
|
||||
if (countBasic.value + 1 <= 19) {
|
||||
countBasic.value++;
|
||||
} else {
|
||||
now.value = 'advanced';
|
||||
countAdvanced.value++;
|
||||
}
|
||||
} else if (now.value === 'advanced') {
|
||||
if (countAdvanced.value + 1 <= 11) {
|
||||
countAdvanced.value++;
|
||||
}
|
||||
if (countAdvanced.value + 1 >= 12) {
|
||||
ending.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const localePath = useLocalePath();
|
||||
|
||||
function endExam() {
|
||||
loading.value = true;
|
||||
while (ending.value == false) {
|
||||
if (time.value.phase != 'set-basic') {
|
||||
next();
|
||||
}
|
||||
changeQuestionTimeAfterNext();
|
||||
}
|
||||
next();
|
||||
basicStore.set(result.value.basic);
|
||||
advancedStore.set(result.value.advanced);
|
||||
examStore.setEnd(true);
|
||||
if (
|
||||
basicStore.basic == result.value.basic &&
|
||||
advancedStore.advanced == result.value.advanced &&
|
||||
examStore.end
|
||||
) {
|
||||
return navigateTo(localePath(`result`), { replace: true });
|
||||
} else {
|
||||
return navigateTo(localePath(`anomaly`));
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const showEndModal = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- as in to transition to the next page -->
|
||||
<LoadingScreen v-if="loading" />
|
||||
<div v-if="statusBasic === 'success' && statusAdvanced === 'success'">
|
||||
<div class="grid grid-cols-4 min-h-dvh">
|
||||
<div class="col-span-3 flex flex-col">
|
||||
<BarTop
|
||||
:points="question?.weight"
|
||||
:category="examStore.category"
|
||||
:time-remaining="time.total"
|
||||
/>
|
||||
<MediaBox
|
||||
:media-path="question?.media_url"
|
||||
:phase="time.phase"
|
||||
@mediaload="onMediaLoad()"
|
||||
/>
|
||||
<QuestionBasic
|
||||
v-if="now === 'basic'"
|
||||
v-model="answer"
|
||||
phase="exam"
|
||||
:question="questionBasic"
|
||||
/>
|
||||
<QuestionAdvanced
|
||||
v-else-if="now === 'advanced'"
|
||||
v-model="answer"
|
||||
phase="exam"
|
||||
:question="questionAdvanced"
|
||||
/>
|
||||
</div>
|
||||
<BarRightExam
|
||||
:count-basic="countBasic"
|
||||
:count-advanced="countAdvanced"
|
||||
:now="now"
|
||||
:ending="ending"
|
||||
:set-basic="time.phase == 'set-basic'"
|
||||
:time="time.question"
|
||||
:phase="time.phase"
|
||||
@show-end-modal="showEndModal = true"
|
||||
@next-question="clickNext()"
|
||||
@end-exam="endExam()"
|
||||
@next-time="changeQuestionTimeAfterNext()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="statusBasic === 'error' || statusAdvanced === 'error'">
|
||||
{{ $t('anAPIErrorOccured') }}:<br />
|
||||
<code class="text-sm">{{ errorBasic }}</code>
|
||||
<br />
|
||||
<code class="text-sm">{{ errorAdvanced }}</code>
|
||||
</div>
|
||||
<LoadingScreen v-else />
|
||||
<EndModal
|
||||
:show-modal="showEndModal"
|
||||
@hide-end-modal="showEndModal = false"
|
||||
@end-exam="endExam()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
112
pages/index.vue
Normal file
112
pages/index.vue
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<script setup lang="ts">
|
||||
import CountryFlag from 'vue-country-flag-next';
|
||||
import categories from '~/categories';
|
||||
|
||||
onMounted(() => {
|
||||
useHead({
|
||||
title: $t('mainTitle'),
|
||||
});
|
||||
});
|
||||
|
||||
const { setLocale } = useI18n();
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const examStore = useExamStore();
|
||||
await callOnce(() => examStore.resetExam(), { mode: 'navigation' });
|
||||
|
||||
const localePath = useLocalePath();
|
||||
|
||||
function setAndGo(category: string) {
|
||||
loading.value = true;
|
||||
examStore.setCategory(category);
|
||||
while (true) {
|
||||
if (examStore.category === category) {
|
||||
return navigateTo(localePath('exam'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const langSelect = ref(examStore.lang);
|
||||
|
||||
function changeLanguage() {
|
||||
examStore.setLang(langSelect.value);
|
||||
setLocale(langSelect.value as 'pl' | 'en' | 'de' | 'ua');
|
||||
}
|
||||
|
||||
const dark = ref(false);
|
||||
|
||||
function getTheme() {
|
||||
if (
|
||||
window.matchMedia &&
|
||||
window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
) {
|
||||
dark.value = true;
|
||||
} else {
|
||||
dark.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watchEffect(getTheme);
|
||||
|
||||
const themeStore = useThemeStore();
|
||||
|
||||
function themeAuto() {
|
||||
themeStore.set('');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!loading" class="text-3xl m-2 flex flex-col gap-2">
|
||||
<span>{{ $t('mainTitle') }}</span>
|
||||
<div class="flex gap-2">
|
||||
<CountryFlag
|
||||
class="block border border-1 border-black"
|
||||
:country="langSelect != 'en' ? langSelect : 'gb'"
|
||||
size="big"
|
||||
/>
|
||||
<select v-model="langSelect" class="select" @change="changeLanguage">
|
||||
<option value="pl">Polish (Polski)</option>
|
||||
<option value="en">English</option>
|
||||
<option value="de">German (Deutsch)</option>
|
||||
<option value="ua">Ukrainian (Українська)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<label class="flex cursor-pointer gap-2 text-lg items-center">
|
||||
{{ $t('theme') }}: {{ $t('light') }}
|
||||
<input
|
||||
v-model="dark"
|
||||
type="checkbox"
|
||||
value="dark"
|
||||
class="toggle theme-controller"
|
||||
@change="themeStore.set(dark ? 'dark' : 'light')"
|
||||
/>
|
||||
{{ $t('dark') }}
|
||||
</label>
|
||||
<div class="btn btn-soft btn-sm" @click="themeAuto()">
|
||||
{{ $t('auto') }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col flex-wrap gap-2 items-start p-4 bg-base-300 border-1 border-slate-500 rounded-xl w-fit"
|
||||
>
|
||||
<div
|
||||
v-for="category in categories"
|
||||
:key="`btn-${category}`"
|
||||
class="flex flex-row gap-3 items-center"
|
||||
>
|
||||
<button class="btn btn-xl btn-secondary" @click="setAndGo(category)">
|
||||
{{ category }}
|
||||
</button>
|
||||
<div class="flex flex-col text-sm">
|
||||
<div>{{ $t(`category.description.${category}`) }}</div>
|
||||
<div>{{ $t(`category.age.${category}`) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<LoadingScreen v-else />
|
||||
</div>
|
||||
</template>
|
||||
159
pages/result.vue
Normal file
159
pages/result.vue
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<script setup lang="ts">
|
||||
import ResultModal from '~/components/ResultModal.vue';
|
||||
|
||||
definePageMeta({ middleware: ['result'] });
|
||||
|
||||
const examStore = useExamStore();
|
||||
|
||||
const basicStore = useBasicStore();
|
||||
const advancedStore = useAdvancedStore();
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
const points = ref<number>(0);
|
||||
|
||||
basicStore.basic.forEach((answer) => {
|
||||
if (answer.chosen_is_correct) {
|
||||
points.value += answer.question?.weight ?? 0;
|
||||
}
|
||||
});
|
||||
advancedStore.advanced.forEach((answer) => {
|
||||
if (answer.chosen_is_correct) {
|
||||
points.value += answer.question?.weight ?? 0;
|
||||
}
|
||||
});
|
||||
|
||||
const resultTrueFalse = ref(
|
||||
points.value >= 68 ? $t('positive') : $t('negative'),
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
useHead({
|
||||
title: `${
|
||||
String(resultTrueFalse.value[0]).toUpperCase() +
|
||||
String(resultTrueFalse.value).slice(1)
|
||||
} (${points.value}/74)`,
|
||||
});
|
||||
});
|
||||
|
||||
const countBasic = ref(0);
|
||||
const countAdvanced = ref(0);
|
||||
|
||||
const resultQuestionBasic = computed<ResultType | undefined>(() =>
|
||||
basicStore.basic.at(countBasic.value),
|
||||
);
|
||||
const resultQuestionAdvanced = computed<ResultType | undefined>(() =>
|
||||
advancedStore.advanced.at(countAdvanced.value),
|
||||
);
|
||||
|
||||
const questionBasic = computed<Question>(
|
||||
() => resultQuestionBasic.value?.question,
|
||||
);
|
||||
const questionAdvanced = computed<Question>(
|
||||
() => resultQuestionAdvanced.value?.question,
|
||||
);
|
||||
|
||||
const now = ref('basic');
|
||||
|
||||
const question = computed(() => {
|
||||
if (now.value === 'basic') {
|
||||
return questionBasic.value;
|
||||
} else if (now.value === 'advanced') {
|
||||
return questionAdvanced.value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const resultQuestion = computed(() => {
|
||||
if (now.value === 'basic') {
|
||||
return resultQuestionBasic.value;
|
||||
} else if (now.value === 'advanced') {
|
||||
return resultQuestionAdvanced.value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
const answer = computed(() => resultQuestion.value?.chosen_answer);
|
||||
|
||||
function changeNow(to: string) {
|
||||
now.value = to;
|
||||
}
|
||||
|
||||
function changeCount(num: number) {
|
||||
if (now.value === 'basic') {
|
||||
countBasic.value = num;
|
||||
} else if (now.value === 'advanced') {
|
||||
countAdvanced.value = num;
|
||||
}
|
||||
}
|
||||
|
||||
const localePath = useLocalePath();
|
||||
|
||||
async function again() {
|
||||
loading.value = true;
|
||||
await examStore.mildReset();
|
||||
return await navigateTo(localePath('exam'));
|
||||
}
|
||||
|
||||
async function home() {
|
||||
loading.value = true;
|
||||
await examStore.resetExam();
|
||||
return await navigateTo(localePath('index'));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<LoadingScreen v-if="loading" />
|
||||
<div v-else>
|
||||
<ResultModal @again="again" @home="home">
|
||||
<template #title>{{ $t('theoreticalExam') }}</template>
|
||||
<template #category>{{ examStore.category }}</template>
|
||||
<template #points>{{ points }}</template>
|
||||
<template #resultTrueFalse>{{ resultTrueFalse }} </template>
|
||||
</ResultModal>
|
||||
<div>
|
||||
<div class="grid grid-cols-4 min-h-dvh">
|
||||
<div class="col-span-3 flex flex-col">
|
||||
<BarTop :points="question?.weight" :category="examStore.category" />
|
||||
<MediaBox :media-path="question?.media_url" phase="" />
|
||||
<div>
|
||||
<QuestionBasic
|
||||
v-if="now === 'basic'"
|
||||
v-model="answer"
|
||||
:question="questionBasic"
|
||||
phase="result"
|
||||
class="select-none z-[-1]"
|
||||
/>
|
||||
<QuestionAdvanced
|
||||
v-else-if="now === 'advanced'"
|
||||
v-model="answer"
|
||||
:question="questionAdvanced"
|
||||
phase="result"
|
||||
class="select-none z-[-1]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<BarRightResult
|
||||
:result="{
|
||||
basic: basicStore.basic,
|
||||
advanced: advancedStore.advanced,
|
||||
}"
|
||||
:count-basic="countBasic"
|
||||
:count-advanced="countAdvanced"
|
||||
:now="now"
|
||||
@change-now="changeNow"
|
||||
@change-count="changeCount"
|
||||
@home="home"
|
||||
@again="again"
|
||||
>
|
||||
<template #points>{{ points }}</template>
|
||||
<template #resultTrueFalse>{{ resultTrueFalse }}</template>
|
||||
</BarRightResult>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
11748
pnpm-lock.yaml
generated
Normal file
11748
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
12
prettier.config.mjs
Normal file
12
prettier.config.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @see https://prettier.io/docs/configuration
|
||||
* @type {import("prettier").Config}
|
||||
*/
|
||||
const config = {
|
||||
trailingComma: 'all',
|
||||
tabWidth: 2,
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
};
|
||||
|
||||
export default config;
|
||||
18
providers/selfhost.ts
Normal file
18
providers/selfhost.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { joinURL } from 'ufo';
|
||||
import type { ProviderGetImage } from '@nuxt/image';
|
||||
import { createOperationsGenerator } from '#image';
|
||||
|
||||
const operationsGenerator = createOperationsGenerator();
|
||||
|
||||
export const getImage: ProviderGetImage = (
|
||||
src,
|
||||
{ modifiers = {}, baseUrl } = {},
|
||||
) => {
|
||||
baseUrl ??= '';
|
||||
|
||||
const operations = operationsGenerator(modifiers);
|
||||
|
||||
return {
|
||||
url: joinURL(baseUrl, src + (operations ? '?' + operations : '')),
|
||||
};
|
||||
};
|
||||
1
public/placeholder.svg
Normal file
1
public/placeholder.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="680.764" height="528.354" viewBox="0 0 180.119 139.794"><g transform="translate(-13.59 -66.639)" paint-order="fill markers stroke"><path fill="#d0d0d0" d="M13.591 66.639H193.71v139.794H13.591z"/><path d="m118.507 133.514-34.249 34.249-15.968-15.968-41.938 41.937H178.726z" opacity=".675" fill="#fff"/><circle cx="58.217" cy="108.555" r="11.773" opacity=".675" fill="#fff"/><path fill="none" d="M26.111 77.634h152.614v116.099H26.111z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 492 B |
63
server/api/advanced.get.ts
Normal file
63
server/api/advanced.get.ts
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import 'dotenv/config';
|
||||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
import { sql, eq, and } from 'drizzle-orm';
|
||||
import arrayShuffle from 'array-shuffle';
|
||||
import { tasks_advanced, questions_advanced, categories_db } from '~/db/schema';
|
||||
import type { AdvancedQuestion } from '~/types';
|
||||
import categories from '~/categories';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event);
|
||||
const category = query.category;
|
||||
|
||||
if (category === '' || typeof category !== 'string') {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage:
|
||||
'category argument has to be string (or not to be defined at all)',
|
||||
});
|
||||
}
|
||||
if (!categories.includes(`${category.toUpperCase()}`)) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: `category argument has to be equal to either: ${categories}`,
|
||||
});
|
||||
}
|
||||
|
||||
async function getFromDb(points: number, limit: number, category: string) {
|
||||
return await db
|
||||
.select({
|
||||
id: tasks_advanced.id,
|
||||
correct_answer: tasks_advanced.correct_answer,
|
||||
media_url: tasks_advanced.media_url,
|
||||
weight: tasks_advanced.weight,
|
||||
text: questions_advanced.text,
|
||||
answer_a: questions_advanced.answer_a,
|
||||
answer_b: questions_advanced.answer_b,
|
||||
answer_c: questions_advanced.answer_c,
|
||||
})
|
||||
.from(tasks_advanced)
|
||||
.leftJoin(
|
||||
questions_advanced,
|
||||
eq(questions_advanced.task_id, tasks_advanced.id),
|
||||
)
|
||||
.leftJoin(categories_db, eq(categories_db.task_id, tasks_advanced.id))
|
||||
.where(
|
||||
and(
|
||||
eq(categories_db.name, category.toUpperCase()),
|
||||
eq(questions_advanced.lang, 'PL'),
|
||||
eq(tasks_advanced.weight, points),
|
||||
),
|
||||
)
|
||||
.orderBy(sql`RANDOM()`)
|
||||
.limit(limit);
|
||||
}
|
||||
const db = drizzle(process.env.DATABASE_URL!);
|
||||
|
||||
const randomizedQuestions: AdvancedQuestion[] = [];
|
||||
|
||||
for (const [key, value] of Object.entries({ 1: 2, 2: 4, 3: 6 })) {
|
||||
randomizedQuestions.push(...(await getFromDb(+key, value, category)));
|
||||
}
|
||||
return arrayShuffle(randomizedQuestions);
|
||||
});
|
||||
57
server/api/basic.get.ts
Normal file
57
server/api/basic.get.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import 'dotenv/config';
|
||||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
import { sql, eq, and } from 'drizzle-orm';
|
||||
import arrayShuffle from 'array-shuffle';
|
||||
import { tasks, questions, categories_db } from '~/db/schema';
|
||||
import type { BasicQuestion } from '~/types';
|
||||
import categories from '~/categories';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event);
|
||||
const category = query.category;
|
||||
|
||||
if (category === '' || typeof category !== 'string') {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage:
|
||||
'category argument has to be string (or not to be defined at all)',
|
||||
});
|
||||
}
|
||||
if (!categories.includes(`${category.toUpperCase()}`)) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: `category argument has to be equal to either: ${categories}`,
|
||||
});
|
||||
}
|
||||
|
||||
async function getFromDb(points: number, limit: number, category: string) {
|
||||
return await db
|
||||
.select({
|
||||
id: tasks.id,
|
||||
correct_answer: tasks.correct_answer,
|
||||
media_url: tasks.media_url,
|
||||
weight: tasks.weight,
|
||||
text: questions.text,
|
||||
})
|
||||
.from(tasks)
|
||||
.leftJoin(questions, eq(questions.task_id, tasks.id))
|
||||
.leftJoin(categories_db, eq(categories_db.task_id, tasks.id))
|
||||
.where(
|
||||
and(
|
||||
eq(categories_db.name, category.toUpperCase()),
|
||||
eq(questions.lang, 'PL'),
|
||||
eq(tasks.weight, points),
|
||||
),
|
||||
)
|
||||
.orderBy(sql`RANDOM()`)
|
||||
.limit(limit);
|
||||
}
|
||||
const db = drizzle(process.env.DATABASE_URL!);
|
||||
|
||||
const randomizedQuestions: BasicQuestion[] = [];
|
||||
|
||||
for (const [key, value] of Object.entries({ 1: 4, 2: 6, 3: 10 })) {
|
||||
randomizedQuestions.push(...(await getFromDb(+key, value, category)));
|
||||
}
|
||||
return arrayShuffle(randomizedQuestions);
|
||||
});
|
||||
3
server/tsconfig.json
Normal file
3
server/tsconfig.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "../.nuxt/tsconfig.server.json"
|
||||
}
|
||||
58
store/examStore.ts
Normal file
58
store/examStore.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
export const useBasicStore = defineStore('basicStore', {
|
||||
state: () => ({
|
||||
basic: [] as ResultType[],
|
||||
}),
|
||||
actions: {
|
||||
async set(basic: ResultType[]) {
|
||||
this.basic = basic;
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
storage: piniaPluginPersistedstate.localStorage(),
|
||||
},
|
||||
});
|
||||
|
||||
export const useAdvancedStore = defineStore('advancedStore', {
|
||||
state: () => ({
|
||||
advanced: [] as ResultType[],
|
||||
}),
|
||||
actions: {
|
||||
async set(advanced: ResultType[]) {
|
||||
this.advanced = advanced;
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
storage: piniaPluginPersistedstate.localStorage(),
|
||||
},
|
||||
});
|
||||
|
||||
export const useExamStore = defineStore('examStore', {
|
||||
state: () => ({
|
||||
category: '',
|
||||
end: false,
|
||||
lang: 'pl',
|
||||
}),
|
||||
actions: {
|
||||
async setCategory(category: string) {
|
||||
this.category = category;
|
||||
},
|
||||
async setEnd(end: boolean) {
|
||||
this.end = end;
|
||||
},
|
||||
async setLang(lang: string) {
|
||||
this.lang = lang;
|
||||
},
|
||||
async mildReset() {
|
||||
this.end = false;
|
||||
useBasicStore().set([]);
|
||||
useAdvancedStore().set([]);
|
||||
},
|
||||
async resetExam() {
|
||||
this.category = '';
|
||||
this.mildReset();
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
storage: piniaPluginPersistedstate.cookies(),
|
||||
},
|
||||
});
|
||||
13
store/themeStore.ts
Normal file
13
store/themeStore.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export const useThemeStore = defineStore('themeStore', {
|
||||
state: () => ({
|
||||
theme: '',
|
||||
}),
|
||||
actions: {
|
||||
async set(theme: string) {
|
||||
this.theme = theme;
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
storage: piniaPluginPersistedstate.localStorage(),
|
||||
},
|
||||
});
|
||||
8
tailwind.config.js
Normal file
8
tailwind.config.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/** @type {import('tailwindcss').Config} */
|
||||
|
||||
module.exports = {
|
||||
plugins: [require('daisyui')],
|
||||
daisyui: {
|
||||
themes: ['light', 'dark'],
|
||||
},
|
||||
};
|
||||
4
tsconfig.json
Normal file
4
tsconfig.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
// https://nuxt.com/docs/guide/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
}
|
||||
27
types/index.ts
Normal file
27
types/index.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
export interface BasicQuestion {
|
||||
id: number | null;
|
||||
correct_answer: string | null;
|
||||
media_url: string | null;
|
||||
weight: number | null;
|
||||
text: string | null;
|
||||
}
|
||||
|
||||
export interface AdvancedQuestion extends BasicQuestion {
|
||||
answer_a: string | null;
|
||||
answer_b: string | null;
|
||||
answer_c: string | null;
|
||||
}
|
||||
|
||||
export type Question = BasicQuestion | AdvancedQuestion | null | undefined;
|
||||
|
||||
export interface ResultType {
|
||||
question: Question;
|
||||
chosen_answer: string;
|
||||
correct_answer: string | null;
|
||||
chosen_is_correct: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface ResultEndType {
|
||||
basic: ResultType[];
|
||||
advanced: ResultType[];
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue