School Management Software || Manage Classes
Create School Management System Page-6 || Class Management System
This HTML and JavaScript code creates a user interface for managing student class and section assignments within a web application. The interface allows users to select a class and section from which students will be moved, and a class and section to which the students will be moved. Here's a detailed description of each part of the code:
HTML Structure
Row 1: Selection Dropdowns
From Class and Section:
- Two dropdowns (
select
elements) allow users to select the class and section from which students will be moved. The options range from Nursery to VIII, including special statuses like Pending and Leaved. - The first dropdown (ID:
fromCl
) has anonchange
event that triggers thefclass
function. - The second dropdown (ID:
fromSec
) also triggers thefclass
function on change.
- Two dropdowns (
To Class and Section:
- Similar to the "From" dropdowns, these allow users to select the destination class and section for the students.
- The first dropdown (ID:
toCl
) allows class selection. - The second dropdown (ID:
toSec
) allows section selection.
Row 2: Move Button
Move Button:
- A button labeled "MOVE" (class:
w3-btn w3-teal w3-hover-red
) triggers thetoclass
function to move the students. - An additional hidden input (ID:
idscls
) is used to store the IDs of the selected students.
- A button labeled "MOVE" (class:
Icons and Info Display:
- An icon (ID:
refresh2
) is used to refresh the student list by triggering thefclass
function. - A placeholder (ID:
clcinfo
) displays messages and status updates.
- An icon (ID:
Student List Display
- Scrollable Div:
- A
div
(ID:stdsincl
) displays the list of students in a grid layout. It is styled for overflow to enable scrolling if the list is long.
- A
JavaScript Functions
selidfun
- Purpose:
- Collects the IDs of selected students and stores them in the hidden input field (
idscls
).
- Collects the IDs of selected students and stores them in the hidden input field (
- Implementation:
- Iterates over all checkboxes (
input[name=selidn]
) and concatenates the values of checked ones.
- Iterates over all checkboxes (
fclass
- Purpose:
- Retrieves and displays the list of students based on the selected class and section.
- Implementation:
- Reads the selected "From Class" and "From Section" values.
- If both are selected, it calls a Google Apps Script function (
clcini
) to get the student list. - Handles success (
pass1
) and failure (fail1
) scenarios.
toclass
- Purpose:
- Moves selected students to the new class and section.
- Implementation:
- Reads the selected "To Class," "To Section," and the list of selected student IDs.
- If all necessary values are provided, it calls a Google Apps Script function (
clcfun
) to update the student assignments. - Handles success (
pass2
) and failure (fail2
) scenarios.
Google Apps Script Integration
- The functions
fclass
andtoclass
interact with Google Apps Script using thegoogle.script.run
API. clcini
function is called to fetch student details.clcfun
function is called to update the student assignments.
User Interaction
- Users select the "From Class" and "From Section" to display the current list of students.
- Users can check the students they want to move.
- Users select the "To Class" and "To Section," and click the "MOVE" button to reassign the students.
- Status messages and the student list are updated dynamically based on user actions.
This setup provides a user-friendly interface for managing student class and section assignments, leveraging Google Apps Script for server-side data handling.
Function 1: clcini
This function initializes the data for students in a specific class and section, preparing it for display.
Parameters:
frCl
: The class from which students are being selected.frsec
: The section from which students are being selected.adreg
: The ID of the Google Spreadsheet containing student data.
Functionality:
Open the Spreadsheet:
- Opens the spreadsheet by its ID and gets the sheet named "addatastore".
Read Data:
- Reads all data from the sheet into the variable
tr
.
- Reads all data from the sheet into the variable
Filter and Build HTML:
- Iterates through each row of data.
- Checks if the student's section matches the selected section (or is "ALL").
- If the student is in the selected class and section, and has a valid ID:
- Uses a default image if the student's image URL is empty.
- Constructs HTML for each student, including an image, name, and a checkbox for selection.
Return:
- Returns a string (
wr
) containing the HTML structure for displaying the students.
Function 2: clcfun
This function updates the class and section for selected students.
Parameters:
dtlist
: An array containing:dtlist[0]
: The new class to which students will be moved.dtlist[1]
: The new section to which students will be moved.dtlist[2]
: A comma-separated string of student IDs.dtlist[3]
: The original class from which students are being moved.dtlist[4]
: The ID of the Google Spreadsheet containing student data.
Functionality:
Open the Spreadsheet:
- Opens the spreadsheet by its ID and gets the sheet named "addatastore".
Read Data:
- Reads all data from the sheet into the variable
clr
.
- Reads all data from the sheet into the variable
Get Current Date and Time:
- Gets the current date and time formatted as a string.
Process Each Student:
- Splits the list of student IDs into an array.
- For each student ID:
- Iterates through the data to find the matching student.
- Updates the student's class, section, and the change log in the spreadsheet.
Return:
- Returns a message indicating the number of students moved and their new class and section.