Пример #1
0
def handle_answerPost(doubtId, answer):
    # $$$$ Professors are not supported to solve doubts
    currentClass = runningClasses[su.get_class_id(session)]
    solvedDoubt = currentClass.getDoubt(doubtId)                    # We are using variables in memory
    solver = DBUtils.getStudentBy_id(su.get_student_id(session))    # Student solver
    room = su.get_classRoom(session)                                # Room to send the response

    # Update currentClass.doubts and db
    solvedDoubt.add_Answer(answer, solver)                          # Do not use DBUtils.

    answerJson = '{"doubtid":' + str(doubtId) + ',"text":"' + answer + '"}'
    socketio.emit('new_answer', answerJson, room=room)
Пример #2
0
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)
Пример #3
0
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')