def selectPlace(): # form = forms.PlaceSelectionForm(request.form) selectedRunningClass = runningClasses[su.get_class_id(session)] rows = selectedRunningClass.classSize[0] cols = selectedRunningClass.classSize[1] takenPlaces = selectedRunningClass.filledPlaces() if (request.method == 'POST'): # Get running classroom instance # Form information placeStr = request.form['place'] placeList = placeStr.split('_') row = int(placeList[0]) column = int(placeList[1]) # Form info # row = form['row'].data # column = form['column'].data # Check if is out of bounds if (row <= rows and column <= cols): # Inside of bounds. The student can take the seat. student_id = su.get_student_id(session) student = DBUtils.getStudentBy_id(student_id) # Generate student groupIsIn = selectedRunningClass.addStudentToPlace( student, (row, column)) # Add to selected class su.set_grupo_id(session, groupIsIn.groupID) # Store id as reference flash('Place selected', 'success') assigmentID = selectedRunningClass.assigment.db_id # Current assigment id groupIsIn.assigmentProgress = su.get_page( session) # Last visited page startPage = su.get_page(session) # Last visited page ''' Socket.io notification''' handle_joinGroup(groupIsIn) # Render de selected assigment at the start page return redirect( url_for('assigment.assigmentByID', id=assigmentID, page=startPage)) # Go to assigment else: flash('Place out of bounds', 'danger') return redirect(url_for('student.selectPlace')) return render_template('selectPlace.html', rows=rows, columns=cols, takenPlaces=takenPlaces)
def assigmentByID(id, page): page_no = int(page) # Conversion to int assigment = DBUtils.getAssigment( id) # Get requested assigment (db_id -> id) currentClass = runningClasses[su.get_class_id(session)] global class_id_aux class_id_aux = su.get_class_id(session) print('class id aux 1: ' + str(class_id_aux)) global group_id_aux group_id_aux = su.get_grupo_id(session) print('group_id_aux 1: ' + str(group_id_aux)) currentGroup = currentClass.studentGroups[su.get_grupo_id(session)] form = forms.PostDoubtForm(request.form) if assigment is None: # Doesn't exist an assigment with the requested id flash('Doesn\'t exists an assigment with id: ' + str(id), 'danger') else: # If zero last one visited in session if page_no == 0: page_no = su.get_page(session) # Render last visited else: su.set_page(session, page_no) # Update session currentGroup.assigmentProgress = page_no # Update group obj totalSections = len(assigment.sections) progress = ProgressPercentaje(page_no, totalSections) if totalSections > 0: if page_no > 0 and page_no <= len(assigment.sections): # The requested page exists updateGroupAssigmentProgress(page_no) # Notify return render_template( 'assigment.html', assigment=assigment, progress=progress, page=page_no, totalSections=totalSections, section=assigment.sections_dict() [page_no - 1], # -1 Because the computer starts counting at 0 form=form) else: # Error flash('Requested page out of bounds', 'danger') else: # Error flash('No sections in current assigment', 'danger')
def addNewMember(): if (request.method == 'POST'): # Data structures to store the information studentPasswordIncorrect = None # Check the button pressed, and tries to log in if request.form['btn'] == 'isStudent': studentPasswordIncorrect = ac.access.loginStudent(request, session) else: flash('Error', 'danger') raise IOError('login error') pass # Logging if studentPasswordIncorrect is not None: # Professor found if (not studentPasswordIncorrect): # Correct password flash('You are now logged in', 'success') # Success now join the desired group selectedRunningClass = runningClasses[su.get_class_id(session)] groupIsIn = selectedRunningClass.studentGroups[su.get_grupo_id( session)] studentid = su.get_students_id_group(session)[ -1] # last student to join the group student = DBUtils.getStudentBy_id(studentid) selectedRunningClass.addStudentToPlace( student, groupIsIn.positionInClass) # Redirect for assigment page assigmentID = selectedRunningClass.assigment.db_id # Current assigment id ''' Socket.io notification''' StudentClass.handle_joinGroup(groupIsIn) # Render de selected assigment at the start page return redirect( url_for('assigment.assigmentByID', id=assigmentID, page=su.get_page(session))) else: # Incorrect password error = 'Password Not matched' return render_template('login.html', error=error) else: error = 'Email not found' return render_template('login.html', error=error) # By default render Login template return render_template('appendStudent.html')