Exemple #1
0
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)
Exemple #2
0
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')
Exemple #3
0
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)