Skip to content

Commit

Permalink
Teacher and Quize
Browse files Browse the repository at this point in the history
  • Loading branch information
MAMUNdevBD committed Jul 5, 2023
1 parent be0bd43 commit 58a885d
Show file tree
Hide file tree
Showing 14 changed files with 383 additions and 241 deletions.
183 changes: 4 additions & 179 deletions components/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,10 @@ const Header = () => {
" horizontal-logo flex items-center justify-between ltr:mr-2 rtl:ml-2 mr-2"
}
>
<Link href="/" className="main-logo flex shrink-0 items-center">
<img
className="inline w-8 ltr:-ml-1 rtl:-mr-1"
src="/assets/images/logo.svg"
alt="logo"
/>
<Link
href="/admin"
className="main-logo flex shrink-0 items-center"
>
<span className="hidden align-middle text-2xl font-semibold transition-all duration-300 ltr:ml-1.5 rtl:mr-1.5 dark:text-white-light md:inline">
Studera Koranen
</span>
Expand Down Expand Up @@ -330,179 +328,6 @@ const Header = () => {
</button>
)}
</div>
<div className="dropdown flex shrink-0">
<Dropdown
offset={[0, 8]}
placement={`${isRtl ? "bottom-start" : "bottom-end"}`}
btnClassName="relative group block"
button={
<img
className="h-9 w-9 rounded-full object-cover saturate-50 group-hover:saturate-100"
src="/assets/images/user-profile.jpeg"
alt="userProfile"
/>
}
>
<ul className="w-[230px] !py-0 font-semibold text-dark dark:text-white-dark dark:text-white-light/90">
<li>
<div className="flex items-center px-4 py-4">
<img
className="h-10 w-10 rounded-md object-cover"
src="/assets/images/user-profile.jpeg"
alt="userProfile"
/>
<div className="ltr:pl-4 rtl:pr-4">
<h4 className="text-base">
John Doe
<span className="rounded bg-success-light px-1 text-xs text-success ltr:ml-2 rtl:ml-2">
Pro
</span>
</h4>
<button
type="button"
className="text-black/60 hover:text-primary dark:text-dark-light/60 dark:hover:text-white"
>
[email protected]
</button>
</div>
</div>
</li>
<li>
<Link
href="/users/profile"
className="dark:hover:text-white"
>
<svg
className="ltr:mr-2 rtl:ml-2"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle
cx="12"
cy="6"
r="4"
stroke="currentColor"
strokeWidth="1.5"
/>
<path
opacity="0.5"
d="M20 17.5C20 19.9853 20 22 12 22C4 22 4 19.9853 4 17.5C4 15.0147 7.58172 13 12 13C16.4183 13 20 15.0147 20 17.5Z"
stroke="currentColor"
strokeWidth="1.5"
/>
</svg>
Profile
</Link>
</li>
<li>
<Link
href="/apps/mailbox"
className="dark:hover:text-white"
>
<svg
className="ltr:mr-2 rtl:ml-2"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
opacity="0.5"
d="M2 12C2 8.22876 2 6.34315 3.17157 5.17157C4.34315 4 6.22876 4 10 4H14C17.7712 4 19.6569 4 20.8284 5.17157C22 6.34315 22 8.22876 22 12C22 15.7712 22 17.6569 20.8284 18.8284C19.6569 20 17.7712 20 14 20H10C6.22876 20 4.34315 20 3.17157 18.8284C2 17.6569 2 15.7712 2 12Z"
stroke="currentColor"
strokeWidth="1.5"
/>
<path
d="M6 8L8.1589 9.79908C9.99553 11.3296 10.9139 12.0949 12 12.0949C13.0861 12.0949 14.0045 11.3296 15.8411 9.79908L18 8"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
/>
</svg>
Inbox
</Link>
</li>
<li>
<Link
href="/auth/boxed-lockscreen"
className="dark:hover:text-white"
>
<svg
className="ltr:mr-2 rtl:ml-2"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M2 16C2 13.1716 2 11.7574 2.87868 10.8787C3.75736 10 5.17157 10 8 10H16C18.8284 10 20.2426 10 21.1213 10.8787C22 11.7574 22 13.1716 22 16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H8C5.17157 22 3.75736 22 2.87868 21.1213C2 20.2426 2 18.8284 2 16Z"
stroke="currentColor"
strokeWidth="1.5"
/>
<path
opacity="0.5"
d="M6 10V8C6 4.68629 8.68629 2 12 2C15.3137 2 18 4.68629 18 8V10"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
/>
<g opacity="0.5">
<path
d="M9 16C9 16.5523 8.55228 17 8 17C7.44772 17 7 16.5523 7 16C7 15.4477 7.44772 15 8 15C8.55228 15 9 15.4477 9 16Z"
fill="currentColor"
/>
<path
d="M13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15C12.5523 15 13 15.4477 13 16Z"
fill="currentColor"
/>
<path
d="M17 16C17 16.5523 16.5523 17 16 17C15.4477 17 15 16.5523 15 16C15 15.4477 15.4477 15 16 15C16.5523 15 17 15.4477 17 16Z"
fill="currentColor"
/>
</g>
</svg>
Lock Screen
</Link>
</li>
<li className="border-t border-white-light dark:border-white-light/10">
<Link
href="/auth/boxed-signin"
className="!py-3 text-danger"
>
<svg
className="rotate-90 ltr:mr-2 rtl:ml-2"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
opacity="0.5"
d="M17 9.00195C19.175 9.01406 20.3529 9.11051 21.1213 9.8789C22 10.7576 22 12.1718 22 15.0002V16.0002C22 18.8286 22 20.2429 21.1213 21.1215C20.2426 22.0002 18.8284 22.0002 16 22.0002H8C5.17157 22.0002 3.75736 22.0002 2.87868 21.1215C2 20.2429 2 18.8286 2 16.0002L2 15.0002C2 12.1718 2 10.7576 2.87868 9.87889C3.64706 9.11051 4.82497 9.01406 7 9.00195"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
/>
<path
d="M12 15L12 2M12 2L15 5.5M12 2L9 5.5"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
Sign Out
</Link>
</li>
</ul>
</Dropdown>
</div>
</div>
</div>

Expand Down
63 changes: 5 additions & 58 deletions components/Layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ const Sidebar = () => {
>
<div className="h-full bg-white dark:bg-black">
<div className="flex items-center justify-between px-4 py-3">
<Link href="/" className="main-logo flex shrink-0 items-center">
<img
className="ml-[5px] w-8 flex-none"
src="/assets/images/logo.svg"
alt="logo"
/>
<Link
href="/admin"
className="main-logo flex shrink-0 items-center"
>
<span className="align-middle text-2xl font-semibold ltr:ml-1.5 rtl:mr-1.5 dark:text-white-light lg:inline">
{t("VRISTO")}
{t("Studera Koranen")}
</span>
</Link>

Expand Down Expand Up @@ -351,57 +349,6 @@ const Sidebar = () => {
</li>
</ul>
</li>

<h2 className="-mx-4 mb-1 flex items-center bg-white-light/30 py-3 px-7 font-extrabold uppercase dark:bg-dark dark:bg-opacity-[0.08]">
<svg
className="hidden h-5 w-4 flex-none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth="1.5"
fill="none"
strokeLinecap="round"
strokeLinejoin="round"
>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
<span>{t("Sites")}</span>
</h2>

<li className="menu nav-item">
<Link href="/tables" className="group">
<div className="flex items-center">
<svg
className="group-hover:!text-primary"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
opacity="0.5"
d="M12 22C7.28595 22 4.92893 22 3.46447 20.5355C2 19.0711 2 16.714 2 12C2 7.28595 2 4.92893 3.46447 3.46447C4.92893 2 7.28595 2 12 2C16.714 2 19.0711 2 20.5355 3.46447C22 4.92893 22 7.28595 22 12C22 16.714 22 19.0711 20.5355 20.5355C19.0711 22 16.714 22 12 22Z"
fill="currentColor"
/>
<path
d="M18.75 8C18.75 8.41421 18.4142 8.75 18 8.75H6C5.58579 8.75 5.25 8.41421 5.25 8C5.25 7.58579 5.58579 7.25 6 7.25H18C18.4142 7.25 18.75 7.58579 18.75 8Z"
fill="currentColor"
/>
<path
d="M18.75 12C18.75 12.4142 18.4142 12.75 18 12.75H6C5.58579 12.75 5.25 12.4142 5.25 12C5.25 11.5858 5.58579 11.25 6 11.25H18C18.4142 11.25 18.75 11.5858 18.75 12Z"
fill="currentColor"
/>
<path
d="M18.75 16C18.75 16.4142 18.4142 16.75 18 16.75H6C5.58579 16.75 5.25 16.4142 5.25 16C5.25 15.5858 5.58579 15.25 6 15.25H18C18.4142 15.25 18.75 15.5858 18.75 16Z"
fill="currentColor"
/>
</svg>
<span className="text-black ltr:pl-3 rtl:pr-3 dark:text-[#506690] dark:group-hover:text-white-dark">
{t("tables")}
</span>
</div>
</Link>
</li>
</ul>
</PerfectScrollbar>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/admin/Forms/CourseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CourseForm = ({ course }: Props) => {
}
formdata.append("description", e.target.description.value);
if (course) {
fetch("/api/v1/course/update?id=1", {
fetch("/api/v1/course/update?id=" + course.id, {
method: "POST",
body: formdata,
redirect: "follow",
Expand Down
106 changes: 106 additions & 0 deletions components/admin/Forms/QuizeForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { GetServerSideProps } from "next";
import FileInput from "../Fields/FileInput";
import InputField from "../Fields/InputField";
import TextField from "../Fields/TextField";
import { useForm } from "react-hook-form";
import { useRouter } from "next/router";
import Swal from "sweetalert2";
import PanelSelectField from "../Fields/PanelSelectField";

type Props = {
quize?: any;
lessons?: any;
};

const QuizeForm = ({ quize, lessons }: Props) => {
const router = useRouter();
const handleSubmit = (e: any) => {
e.preventDefault();
var formdata = new FormData();
formdata.append("lesson_id", e.target.lesson_id.value);
formdata.append("question", e.target.question.value);
formdata.append("o1", e.target.o1.value);
formdata.append("o2", e.target.o2.value);
formdata.append("o3", e.target.o3.value);
formdata.append("o4", e.target.o4.value);
formdata.append("answer", e.target.answer.value);
if (quize) {
fetch("/api/v1/quize/update?id=" + quize.id, {
method: "POST",
body: formdata,
redirect: "follow",
})
.then((response) => response.json())
.then(({ success, msg, result }) => {
Swal.fire({
icon: success ? "success" : "error",
title: success ? "Success" : "Error",
text: msg,
padding: "2em",
customClass: "sweet-alerts",
});
})
.catch((error) => console.log("error", error));
} else {
fetch("/api/v1/quize/add", {
method: "POST",
body: formdata,
redirect: "follow",
})
.then((response) => response.json())
.then(({ success, msg, result }) => {
if (success) {
router.push("/admin/quize/list");
}
})
.catch((error) => console.log("error", error));
}
};
return (
<form onSubmit={handleSubmit} className="flex flex-col gap-5">
<PanelSelectField
label="Lesson"
name="lesson_id"
options={lessons}
defaultValue={quize?.lesson_id}
/>
<InputField
name="question"
label="Question"
required
defaultValue={quize?.question}
/>
<div className="grid md:grid-cols-2 xl:grid-cols-4 gap-5">
<InputField
name="o1"
label="Option 1"
required
defaultValue={quize?.o1}
/>
<InputField
name="o2"
label="Option 2"
required
defaultValue={quize?.o2}
/>
<InputField
name="o3"
label="Option 3"
required
defaultValue={quize?.o3}
/>
<InputField
name="o4"
label="Option 4"
required
defaultValue={quize?.o4}
/>
</div>
<button type="submit" className="btn btn-primary w-max px-10">
Submit
</button>
</form>
);
};

export default QuizeForm;
Loading

0 comments on commit 58a885d

Please sign in to comment.