File size: 968 Bytes
cf815ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#utils.py
import base64
from database_functions import add_user_privacy  # Make sure this is correctly implemented

def get_image_html(image_path):
    with open(image_path, "rb") as img_file:
        base64_image = base64.b64encode(img_file.read()).decode('utf-8')
    return f'<img src="data:image/jpg;base64,{base64_image}" alt="SBC6" width="450" style="display: block; margin: auto;"/>'

def collect_student_info(class_name, index_no):
    # Validate inputs
    if not class_name or not index_no:
        return False, "Please select your class and index number.", None
    
    try:
        # Call the updated add_user function with class_name and index_no
        userid, dbMsg = add_user_privacy(class_name, index_no)
        return True, dbMsg, userid
    except Exception as e:
        # Log the exception and handle it appropriately
        print(f"An error occurred: {e}")
        return False, "An error occurred while adding user to the database.", None