Ejemplo n.º 1
0
def checkanswer():
    if not auth.user:
        session.flash = "Please Login"
        return redirect(URL('default', 'index'))

    sid = auth.user.id
    course_name = auth.user.course_name
    # Retrieve the question id from the request object.
    qid = request.vars.get('QID', None)
    username = auth.user.username
    # Retrieve the q (quality of answer) from the request object.
    q = request.vars.get('q', None)

    # If the question id exists:
    if request.vars.QID:
        now = datetime.datetime.utcnow()
        # Use the autograding function to update the flashcard's e-factor and i-interval.
        do_check_answer(sid,
                        course_name,
                        qid,
                        username,
                        q,
                        db,
                        settings,
                        now,
                        float(session.timezoneoffset) if 'timezoneoffset' in session else 0)

        # Since the user wants to continue practicing, continue with the practice action.
        redirect(URL('practice'))
    session.flash = "Sorry, your score was not saved. Please try submitting your answer again."
    redirect(URL('practice'))
Ejemplo n.º 2
0
def checkanswer():

    sid = auth.user.id
    course_name = auth.user.course_name
    # Retrieve the question id from the request object.
    qid = request.vars.get("QID", None)
    username = auth.user.username
    # Retrieve the q (quality of answer) from the request object.
    q = request.vars.get("q", None)

    # If the question id exists:
    if request.vars.QID:
        now = datetime.datetime.utcnow()
        # Use the autograding function to update the flashcard's e-factor and i-interval.
        do_check_answer(
            sid,
            course_name,
            qid,
            username,
            q,
            db,
            settings,
            now,
            float(session.timezoneoffset)
            if "timezoneoffset" in session else 0,
        )

        # Since the user wants to continue practicing, continue with the practice action.
        redirect(URL("practice"))
    session.flash = (
        "Sorry, your score was not saved. Please try submitting your answer again."
    )
    redirect(URL("practice"))
Ejemplo n.º 3
0
def checkanswer():
    if not auth.user:
        session.flash = "Please Login"
        return redirect(URL('default', 'index'))

    sid = auth.user.id
    course_name = auth.user.course_name
    # Retrieve the question id from the request object.
    qid = request.vars.get('QID', None)
    username = auth.user.username
    # Retrieve the q (quality of answer) from the request object.
    q = request.vars.get('q', None)

    # If the question id exists:
    if request.vars.QID:
        now = datetime.datetime.utcnow()
        # Use the autograding function to update the flashcard's e-factor and i-interval.
        do_check_answer(sid, course_name, qid, username, q, db, settings, now,
                        datetime.timedelta(hours=int(session.timezoneoffset)))
        # Since the user wants to continue practicing, continue with the practice action.
        redirect(URL('practice'))
    session.flash = "Sorry, your score was not saved. Please try submitting your answer again."
    redirect(URL('practice'))