def createClassroom(): form = forms.CreateClassroom(request.form) # Dynamic drop-down menu to choose the available assigments for professor assigments = assigmentsTupleList(session['id_professor']) form.assigment.choices = assigments if (request.method == 'POST' and form.validate()): # Form information about the new classroom rows = form['rows'].data columns = form['columns'].data room = form['room'].data selectedAssigmentID = form['assigment'].data # Classroom objects initialization assigmentObj = DBUtils.getAssigment( selectedAssigmentID) # Object assigment currentProfessor = DBUtils.getProfessor( su.get_professor_id(session)) # Object professor classroom = dataStructures.Classroom((rows, columns), currentProfessor, assigmentObj, room) # Object ClassRoom runningClasses[ classroom. id] = classroom # Add to runningClasses (dict) with id to be able to track different courses su.set_class_id(session, classroom.id) # Add to professor's session # Messages flash( 'Classroom created for assigment id = ' + str(selectedAssigmentID), 'success') return redirect(url_for('professor.classroom')) return render_template('createClassroom.html', form=form)
def openClassroom(): form = forms.OpenClassroom(request.form) # Dynamic drop-down menu to choose the available assigments for professor assigments = assigmentsTupleList(session['id_professor']) form.assigment.choices = assigments classrooms = classroomsTupleList() form.classroom.choices = classrooms if (request.method == 'POST' and form.validate()): # Form information about the new classroom selectedAssigmentID = form['assigment'].data selectedClassroomID = form['classroom'].data # Classroom objects initialization classroomObj = DBUtils.getClassroom(selectedClassroomID) assigmentObj = DBUtils.getAssigment(selectedAssigmentID) rows = int(float(classroomObj.rows)) columns = int(float(classroomObj.columns)) room = classroomObj.name # Object assigment currentProfessor = DBUtils.getProfessor( su.get_professor_id(session)) # Object professor classroom = dataStructures.Classroom((rows, columns), currentProfessor, assigmentObj, room) # Object ClassRoom runningClasses[ classroom. id] = classroom # Add to runningClasses (dict) with id to be able to track different courses su.set_class_id(session, classroom.id) # Add to professor's session return redirect(url_for('professor.classroom')) return render_template('openClassroom.html', form=form)