File size: 6,690 Bytes
a8a001c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Resource - Educational Resource Management System</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <div class="container">
        <div class="header">
            <h1><a href="{{ url_for('index') }}">Educational Resource Management System</a></h1>
            <a href="{{ url_for('logout') }}" class="logout-btn">Logout</a>
        </div>

        <div class="user-welcome">
            <h2>Welcome, {{ session['username'] }}!</h2>
            <p>You are logged in as a {{ session['user_type'] }}</p>
        </div>

        <nav>
            <ul class="nav-list">
                {% if session['user_type'] == 'admin' %}
                    <li><a href="{{ url_for('add_resource') }}">Add Resource</a></li>
                {% endif %}
                <li><a href="{{ url_for('view_resources') }}">View Resources</a></li>
            </ul>
        </nav>

        <div class="dashboard-content">
            <h2>Add New Resource</h2>

            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    {% for category, message in messages %}
                        <p style="color: {{ 'red' if category == 'error' else 'green' }}">{{ message }}</p>
                    {% endfor %}
                {% endif %}
            {% endwith %}

            <form action="{{ url_for('add_resource') }}" method="POST" enctype="multipart/form-data" class="add-resource-form">
                <div class="form-group">
                    <label for="name">Resource Name:</label>
                    <input type="text" id="name" name="name" required>
                </div>

                <div class="form-group">
                    <label for="type">Resource Type:</label>
                    <select id="type" name="type" required>
                        <option value="" disabled selected>Select Resource Type</option>
                        <option value="Textbooks">Textbooks</option>
                        <option value="Digital Materials">Digital Materials</option>
                        <option value="Library Books">Library Books</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="institution">Institution:</label>
                    <select id="institution" name="institution" onchange="updateDepartments()" required>
                        <option value="" disabled selected>Select Institution</option>
                        <option value="MIT Institute of Design">MIT Institute of Design</option>
                        <option value="MIT College of Management">MIT College of Management</option>
                        <option value="MIT School of Food Technology">MIT School of Food Technology</option>
                        <option value="MIT School of Film and Theatre">MIT School of Film and Theatre</option>
                        <option value="MIT School of Indian Civil Services">MIT School of Indian Civil Services</option>
                        <option value="MIT School of Computing">MIT School of Computing</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="department">Department:</label>
                    <select id="department" name="department" required>
                        <option value="" disabled selected>Select Department</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="resource_file">Upload Resource (PDF/Video):</label>
                    <input type="file" id="resource_file" name="resource_file" required>
                </div>

                <button type="submit" class="submit-btn">Add Resource</button>
            </form>
        </div>
    </div>

    <script>

        const departments = {

            "MIT Institute of Design": [

                "Bachelor of Design",

                "Master of Design (Animation Design)",

                "Master of Design (Design Management)",

                "Master of Design (Fashion Management and Marketing)"

            ],

            "MIT College of Management": [

                "Bachelor of Commerce (HONORS)",

                "Bachelor of Computer Applications",

                "Master of Business Administration (Executive)"

            ],

            "MIT School of Food Technology": [

                "B. Tech. (Food Technology)",

                "M. Tech. (Food Safety and Quality Management)",

                "M. Tech. (Food Technology)"

            ],

            "MIT School of Film and Theatre": [

                "B.A. in Direction & Screenplay Writing",

                "B.Sc. in Filmmaking",

                "Bachelor of Arts (Dramatics)",

                "M.A. in Direction & Screenplay Writing"

            ],

            "MIT School of Indian Civil Services": [

                "B.A. (Administration)",

                "M.A. (Administration)"

            ],

            "MIT School of Computing": [

                "Bachelor of Technology (Computer Science & Engineering)",

                "Master of Science (Computer Science/Artificial Intelligence & Machine Learning)",

                "Master of Technology (Computer Science & Engineering - Intelligent Systems & Analysis)",

                "Master of Technology (Information Technology - Cyber Security)"

            ]

        };



        function updateDepartments() {

            const institutionSelect = document.getElementById("institution");

            const departmentSelect = document.getElementById("department");

            const selectedInstitution = institutionSelect.value;



            departmentSelect.innerHTML = "<option value='' disabled selected>Select Department</option>";



            if (departments[selectedInstitution]) {

                departments[selectedInstitution].forEach(department => {

                    const option = document.createElement("option");

                    option.value = department;

                    option.text = department;

                    departmentSelect.appendChild(option);

                });

            }

        }

    </script>
</body>
</html>