File size: 1,796 Bytes
e807081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit as st
import os

# Set the main directories
SYLLABUS_DIR = "syllabus"
SUBJECT_DIRS = {
    "Maths": "paper-1-maths",
    "Advanced Operating Systems": "paper-2-advanceOS",
    "Data Structures": "paper-3-DS",
    "C++ Programming": "paper-4-cplusplus",
    "Computer Architecture": "paper-5-computer-architecture"
}

# Helper function to read markdown files
def read_markdown_file(filepath):
    with open(filepath, "r") as file:
        return file.read()

# Sidebar for navigation
st.sidebar.title("Notes Navigator")
st.sidebar.write("Select a subject and unit to view notes.")

# Syllabus Section
if st.sidebar.checkbox("Show Syllabus"):
    st.header("Syllabus")
    for subject_file in os.listdir(SYLLABUS_DIR):
        file_path = os.path.join(SYLLABUS_DIR, subject_file)
        if os.path.isfile(file_path) and subject_file.endswith(".md"):
            subject_name = subject_file.replace(".md", "").replace("-", " ").title()
            with st.expander(subject_name):
                content = read_markdown_file(file_path)
                st.markdown(content, unsafe_allow_html=True)

# Subject and Unit Selection
selected_subject = st.sidebar.selectbox("Select Subject", list(SUBJECT_DIRS.keys()))
subject_folder = SUBJECT_DIRS[selected_subject]

# Unit Selection
selected_unit = st.sidebar.selectbox("Select Unit", ["Unit 1", "Unit 2", "Unit 3", "Unit 4", "Unit 5"])
unit_file = f"{selected_unit.lower().replace(' ', '-')}.md"
unit_file_path = os.path.join(subject_folder, unit_file)

# Display selected notes
st.header(f"{selected_subject} - {selected_unit}")
if os.path.exists(unit_file_path):
    unit_content = read_markdown_file(unit_file_path)
    st.markdown(unit_content, unsafe_allow_html=True)
else:
    st.error("The selected notes file does not exist.")