Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/subjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const subjectCodes: Record<string, string> = {
};

// Available subjects
const available = ["ep", "c", "em1", "em2", "oops","os", "ml"];
const available = ["ep", "c", "em1", "em2", "oops", "dsc", "os", "ml"];

export default function SubjectsSection() {
return (
Expand Down
109 changes: 109 additions & 0 deletions app/sem2/dsc/[chapter]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import Link from "next/link";
import { Righteous } from "next/font/google";

import { Ch0Content } from "../content/chapter0";
import { Ch1Content } from "../content/chapter1";

import { ArrowBigLeft, ArrowBigRight } from "lucide-react";

const righteous = Righteous({
subsets: ["latin"],
weight: "400",
variable: "--font-righteous",
});

const chapters = [
{ id: "ch0", title: "Course Outline", component: Ch0Content },
{ id: "ch1", title: "Arrays", component: Ch1Content },
];

type ChapterProps = {
params: { chapter: string };
};

export default function ChapterPage({ params }: ChapterProps) {
const currentIndex = chapters.findIndex((c) => c.id === params.chapter);
const chapter = chapters[currentIndex];

if (!chapter) {
return <h1 className="text-2xl font-bold">Chapter not found</h1>;
}

const ChapterComponent = chapter.component;
const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null;
const nextChapter =
currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null;

return (
<div className="flex flex-col bg-[#1B0D00] min-h-full p-2 pt-6 text-[#e2d1c1]">

<div className="flex-1">
<h1 className={`text-4xl font-bold ${righteous.className} mb-2`}>
Data Structures using C
</h1>

<p className={`text-2xl mt-[-8px] ${righteous.className}`}>
{chapter.title}
</p>

{/* Navigation */}
<div className="flex justify-between mt-3">
{prevChapter ? (
<Link
href={`/sem2/dsc/${prevChapter.id}`}
className="px-4 py-1 text-2xl flex items-center justify-center bg-[#e2d1c1] text-[#1b0d00] rounded hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
<ArrowBigLeft className="inline-block mr-1" /> Previous
</Link>
) : (
<div />
)}

{nextChapter ? (
<Link
href={`/sem2/dsc/${nextChapter.id}`}
className="px-4 py-1 text-2xl flex items-center justify-center bg-[#e2d1c1] text-[#1b0d00] rounded hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
Next <ArrowBigRight className="inline-block ml-1" />
</Link>
) : (
<div />
)}
</div>

<hr className="my-6 border-t-3" />
<ChapterComponent />
</div>

{/* Bottom Navigation */}
<div className="flex justify-between my-8">
{prevChapter ? (
<Link
href={`/sem2/dsc/${prevChapter.id}`}
className="px-4 py-2 bg-[#e2d1c1] text-xl flex items-center justify-center text-[#1b0d00] rounded hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
<ArrowBigLeft className="inline-block mr-1" /> {prevChapter.title}
</Link>
) : (
<div />
)}

{nextChapter ? (
<Link
href={`/sem2/dsc/${nextChapter.id}`}
className="px-4 py-2 bg-[#e2d1c1] text-xl flex items-center justify-center text-[#1b0d00] rounded hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
{nextChapter.title}{" "}
<ArrowBigRight className="inline-block ml-1" />
</Link>
) : (
<div />
)}
</div>
</div>
);
}
112 changes: 112 additions & 0 deletions app/sem2/dsc/components/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"use client";
import { Righteous } from "next/font/google";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState } from "react";

const righteous = Righteous({
subsets: ["latin"],
weight: "400",
variable: "--font-righteous",
});

export default function Sidebar() {
const pathname = usePathname();
const [open, setOpen] = useState(true);

const chapters = [
{ id: "ch0", title: "Course Outline" },
{ id: "ch1", title: "Arrays" },
];

const quizSlugMap: Record<string, string> = {
c: "c-programming",
em1: "em1",
ep: "ep",
em2: "em2",
oops: "oops",
};

const subjectKey = pathname.split("/")[2] ?? "";
const quizSlug = quizSlugMap[subjectKey];
const quizHref = quizSlug ? `/quiz/${quizSlug}` : "/quiz";
const quizActive = pathname.startsWith("/quiz");

return (
<div className="flex relative">

{/* Sidebar */}
<aside
className={`h-[100vh] sticky top-0 bg-[#fae8d7] text-[#1B0D00] p-0 flex flex-col transition-all duration-300 ${
open ? "w-64" : "w-0 overflow-hidden"
}`}
>
<h2
className="flex items-center text-2xl font-normal pt-3 pl-3 mb-2 bg-[#cebb9c] text-[#1B0D00] pb-2 border-b-4 border-[#1B0D00]"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
Chapters
</h2>

<ul className="flex-1 overflow-y-auto space-y-0">
{chapters.map((ch) => {
const active = pathname === `/sem2/dsc/${ch.id}`;
return (
<li key={ch.id}>
<Link
href={`/sem2/dsc/${ch.id}`}
className={`block px-3 py-2 text-xl transition ${
active ? "bg-[#fccc7e]" : "hover:bg-[#ffdda7af]"
} ${righteous.className}`}
>
{ch.title}
</Link>
</li>
);
})}
</ul>

<div className="border-t-4 border-[#1B0D00]">
<h2
className="flex items-center text-2xl font-normal pt-3 pl-3 mb-2 bg-[#cebb9c] text-[#1B0D00] pb-2"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
Quiz
</h2>
<Link
href={quizHref}
className={`flex items-center gap-2 px-3 py-2 text-xl transition ${
quizActive ? "bg-[#fccc7e]" : "hover:bg-[#ffdda7af]"
} ${righteous.className}`}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="w-5 h-5 shrink-0"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M12 20h9" />
<path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z" />
</svg>
Take the Quiz
</Link>
</div>
</aside>

<button
onClick={() => setOpen(!open)}
className="toggle-sidebar sticky top-[10%] left-full bg-[#ffdda7d0] h-[85vh] w-[50px] text-[#1B0D00] text-center font-semibold text-2xl border-l-4 rounded-r-2xl border-[#1B0D00] flex items-center justify-center transition-all duration-300"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
<p className="leading-5">
C<br />H<br />A<br />P<br />T<br />E<br />R<br />S
</p>
</button>

</div>
);
}
87 changes: 87 additions & 0 deletions app/sem2/dsc/content/chapter0.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export const Ch0Content = () => {
return (
<div className="course-content">

<p className="p-text">
Welcome to <span className="font-semibold">Data Structures using C</span>.
This course introduces the concepts of organizing and storing data efficiently
using C programming. It covers fundamental data structures and algorithms
such as arrays, linked lists, stacks, queues, trees, graphs, searching,
and sorting techniques.
</p>

<section>
<h3 className="section-heading">Module I: Arrays</h3>
<ul className="section-list">
<li>Introduction to arrays</li>
<li>Declaration and initialization</li>
<li>Common array operations (accessing, traversal, searching, insertion, deletion, updating)</li>
<li>Applications, advantages and limitations</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module II: Linked Lists</h3>
<ul className="section-list">
<li>Singly linked lists</li>
<li>Doubly linked lists</li>
<li>Circular linked lists</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module III: Stacks</h3>
<ul className="section-list">
<li>Stack operations</li>
<li>Array implementation</li>
<li>Applications of stacks</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module IV: Queues</h3>
<ul className="section-list">
<li>Queue operations</li>
<li>Types of queues</li>
<li>Applications of queues</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module V: Trees</h3>
<ul className="section-list">
<li>Binary trees</li>
<li>Tree traversal techniques</li>
<li>Binary search trees</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module VI: Graphs</h3>
<ul className="section-list">
<li>Graph representation</li>
<li>Breadth First Search</li>
<li>Depth First Search</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module VII: Searching</h3>
<ul className="section-list">
<li>Linear Search</li>
<li>Binary Search</li>
</ul>
</section>

<section>
<h3 className="section-heading">Module VIII: Sorting</h3>
<ul className="section-list">
<li>Bubble Sort</li>
<li>Selection Sort</li>
<li>Insertion Sort</li>
</ul>
</section>

</div>
);
};
Loading