У меня возникла проблема при попытке отобразить данные в таблице. Данные извлекаются и отображаются в журналах правильно, но не отображаются в таблице внешнего интерфейса.
Это таблица:
@app.route('/advising', methods=['GET', 'POST'])
@login_required
def advising():
logger.debug(f"Advising route accessed by user {current_user.id}")
# Authorization Check
if current_user.user_type_ID != 1:
flash('Access denied. You are not an advisor.', 'error')
return redirect(url_for('dashboard'))
try:
# Fetch advisor details
advisor_id = functions.get_advisor_id(current_user.id)
logger.debug(f"Fetched advisor ID: {advisor_id}")
if not advisor_id:
flash('Advisor ID not found. Please try again.', 'error')
return redirect(url_for('dashboard'))
advisor_info = functions.fetch_advisor_info(advisor_id)
logger.debug(f"Fetched advisor info: {advisor_info}")
if not advisor_info:
flash('Unable to load advisor information. Please contact support.', 'error')
return redirect(url_for('dashboard'))
# Initialize context variables
student_info = None
gpa_deficit = 0
probation_status = False
consecutive_semesters = 0
transcript = None
recommended_courses = None
# Handle student search
if request.method == 'POST' and 'search_student' in request.form:
student_id = request.form.get('student_id')
logger.debug(f"Received student search request with student_ID: {student_id}")
if student_id:
try:
# Resolve student_ID to user_ID
user_id = functions.get_user_id_from_student_id(student_id)
if not user_id:
logger.warning(f"No user_ID found for student_ID: {student_id}")
flash(f"Student with ID {student_id} not found.", 'error')
else:
# Fetch student info using user_ID
student_info = functions.fetch_student_info_by_id(user_id)
logger.debug(f"Fetched student info for user_ID {user_id}: {student_info}")
if student_info:
# Fetch additional student data
gpa_deficit = functions.calculate_gpa_deficit(user_id)
logger.debug(f"GPA Deficit: {gpa_deficit}")
con_sem = functions.probation_semesters_count(user_id)
logger.debug(f"Consecutive semesters on probation: {con_sem}")
probation_status = functions.check_probation_status(user_id, con_sem)
logger.debug(f"Probation Status: {probation_status}")
consecutive_semesters = functions.count_consecutive_probation_semesters(user_id)
logger.debug(f"Consecutive Semesters on Probation: {consecutive_semesters}")
transcript = functions.fetch_student_transcript(user_id)
logger.debug(f"Fetched transcript: {transcript}")
sttran = functions.student_transcript(user_id)
logger.debug(f"Fetched sttran: {sttran}")
# Validate transcript structure
if not isinstance(sttran, list):
logger.error("Transcript is not a list. Invalid structure.")
raise ValueError("Transcript data is not in expected format.")
# Ensure every item in the transcript is a dictionary
sttran = [
course for course in sttran
if isinstance(course, dict) and 'grade' in course and 'course_code' in course
]
# Filter transcript data
filtered = [
course for course in sttran
if course['grade'] not in ['W', 'P', 'F', 'FA', 'I']
]
completed_courses = [course['course_code'] for course in filtered]
completed_course_types = {
course['course_type']: completed_courses.count(course['course_type'])
for course in filtered
}
recommended_courses = functions.recommend_courses(
user_id,
student_info['cumulative_gpa'],
completed_courses,
completed_course_types,
probation_status,
con_sem
)
logger.debug(f"Fetched recommended courses: {recommended_courses}")
else:
logger.warning(f"No data found for user_ID: {user_id}")
flash(f"Student with ID {student_id} not found.", 'error')
except Exception as e:
logger.error(f"Error during student search for student_ID {student_id}: {str(e)}", exc_info=True)
flash("An error occurred while searching for the student.", "error")
# Fetch availability slots for advisor
advisor_slots = functions.fetch_availability_slots(advisor_id)
logger.debug(f"Fetched advisor slots: {advisor_slots}")
# Render the page with all required context
return render_template(
'advising.html',
advisor_info=advisor_info,
advisor_slots=advisor_slots,
student_info=student_info,
gpa_deficit=gpa_deficit,
probation_status=probation_status,
consecutive_semesters=consecutive_semesters,
transcript=transcript,
recommended_courses=recommended_courses,
)
except Exception as e:
logger.error(f"Unexpected error in advising route: {str(e)}", exc_info=True)
flash('An error occurred while loading the advising page. Please try again later.', 'error')
return redirect(url_for('dashboard'))
Когда я добавляю {{рекомендуемые_курсы}} для отладки, я вижу необработанные данные, отображаемые во внешнем интерфейсе. Однако сама таблица остается пустой. Что может быть причиной этой проблемы?
У меня возникла проблема при попытке отобразить данные в таблице. Данные извлекаются и отображаются в журналах правильно, но не отображаются в таблице внешнего интерфейса. Это таблица: [code]
{% else %} No recommended courses available. {% endif %} ` [/code] Это маршрут: [code]@app.route('/advising', methods=['GET', 'POST']) @login_required def advising(): logger.debug(f"Advising route accessed by user {current_user.id}")
# Authorization Check if current_user.user_type_ID != 1: flash('Access denied. You are not an advisor.', 'error') return redirect(url_for('dashboard'))
try: # Fetch advisor details advisor_id = functions.get_advisor_id(current_user.id) logger.debug(f"Fetched advisor ID: {advisor_id}") if not advisor_id: flash('Advisor ID not found. Please try again.', 'error') return redirect(url_for('dashboard'))
advisor_info = functions.fetch_advisor_info(advisor_id) logger.debug(f"Fetched advisor info: {advisor_info}") if not advisor_info: flash('Unable to load advisor information. Please contact support.', 'error') return redirect(url_for('dashboard'))
# Handle student search if request.method == 'POST' and 'search_student' in request.form: student_id = request.form.get('student_id') logger.debug(f"Received student search request with student_ID: {student_id}") if student_id: try: # Resolve student_ID to user_ID user_id = functions.get_user_id_from_student_id(student_id) if not user_id: logger.warning(f"No user_ID found for student_ID: {student_id}") flash(f"Student with ID {student_id} not found.", 'error') else: # Fetch student info using user_ID student_info = functions.fetch_student_info_by_id(user_id) logger.debug(f"Fetched student info for user_ID {user_id}: {student_info}") if student_info: # Fetch additional student data gpa_deficit = functions.calculate_gpa_deficit(user_id) logger.debug(f"GPA Deficit: {gpa_deficit}") con_sem = functions.probation_semesters_count(user_id) logger.debug(f"Consecutive semesters on probation: {con_sem}") probation_status = functions.check_probation_status(user_id, con_sem) logger.debug(f"Probation Status: {probation_status}") consecutive_semesters = functions.count_consecutive_probation_semesters(user_id) logger.debug(f"Consecutive Semesters on Probation: {consecutive_semesters}") transcript = functions.fetch_student_transcript(user_id) logger.debug(f"Fetched transcript: {transcript}") sttran = functions.student_transcript(user_id) logger.debug(f"Fetched sttran: {sttran}")
# Validate transcript structure if not isinstance(sttran, list): logger.error("Transcript is not a list. Invalid structure.") raise ValueError("Transcript data is not in expected format.")
# Ensure every item in the transcript is a dictionary sttran = [ course for course in sttran if isinstance(course, dict) and 'grade' in course and 'course_code' in course ]
# Filter transcript data filtered = [ course for course in sttran if course['grade'] not in ['W', 'P', 'F', 'FA', 'I'] ] completed_courses = [course['course_code'] for course in filtered] completed_course_types = { course['course_type']: completed_courses.count(course['course_type']) for course in filtered } recommended_courses = functions.recommend_courses( user_id, student_info['cumulative_gpa'], completed_courses, completed_course_types, probation_status, con_sem ) logger.debug(f"Fetched recommended courses: {recommended_courses}") else: logger.warning(f"No data found for user_ID: {user_id}") flash(f"Student with ID {student_id} not found.", 'error') except Exception as e: logger.error(f"Error during student search for student_ID {student_id}: {str(e)}", exc_info=True) flash("An error occurred while searching for the student.", "error")
# Render the page with all required context return render_template( 'advising.html', advisor_info=advisor_info, advisor_slots=advisor_slots, student_info=student_info, gpa_deficit=gpa_deficit, probation_status=probation_status, consecutive_semesters=consecutive_semesters, transcript=transcript, recommended_courses=recommended_courses, )
except Exception as e: logger.error(f"Unexpected error in advising route: {str(e)}", exc_info=True) flash('An error occurred while loading the advising page. Please try again later.', 'error') return redirect(url_for('dashboard')) [/code] [code] Debug: {{ recommended_courses }} [/code] Когда я добавляю {{рекомендуемые_курсы}} для отладки, я вижу необработанные данные, отображаемые во внешнем интерфейсе. Однако сама таблица остается пустой. Что может быть причиной этой проблемы?
Я использую django для серверной части и next.js для внешнего интерфейса.
У меня в базе данных есть таблица Person, которую я недавно изменил и добавил два новых значения: `government_id и фискальный_адрес.
Моя модель Django выглядит так:
class...
Я работаю над проектом, в котором считываю последовательные данные с Arduino с помощью Python и отображаю их в веб-интерфейсе, созданном с помощью Flask. Соединение Arduino, кажется, работает нормально, и я могу правильно прочитать данные на...
У меня есть проверка длины строки во внешнем интерфейсе для текстовой области (с использованием JavaScript).
У меня также есть проверка на серверной части (с использованием встроенного правила проверки Laravel).
Проблема в том, что длина строки во...
Извините, что беспокою вас, ребята, но у меня возникли проблемы с попыткой сделать некоторые тесты, которые будут отображаться в системе автоматического тестирования. Я написал два базовых теста (С++), чтобы посмотреть, что произойдет в плагине, но...