예제 #1
0
def load(lti=None, assignments=None, submissions=None, embed=False):
    """
    
    """
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    if assignments:
        if submissions:
            course_id = submissions[0].course_id
        else:
            course_id = assignments[0].course_id
        if g.user and g.user is not None:
            instructor_mode = g.user.is_instructor(course_id)
        else:
            instructor_mode = False
        if 'course_id' in request.form:
            course_id = int(request.form.get('course_id'))
    else:
        instructor_mode = False
        if 'course_id' in request.form:
            course_id = int(request.form.get('course_id'))
        else:
            course_id = None
    return render_template('blockpy/blockpy.html',
                           group=zip(assignments, submissions),
                           course_id=course_id,
                           user_id=g.user.id if g.user is not None else -1,
                           embed=embed,
                           instructor_mode=instructor_mode)
예제 #2
0
def load(lti=lti,
         lti_exception=None,
         assignments=None,
         submissions=None,
         embed=False):
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    if 'course_id' in request.values:
        course_id = int(request.values.get('course_id'))
    else:
        course_id = g.course.id if "course" in g else None
    if assignments:
        if g.user and g.user is not None:
            instructor_mode = g.user.is_instructor(course_id)
        else:
            instructor_mode = False
    else:
        instructor_mode = False
    if submissions:
        code = submissions[0].load_poll()
    else:
        code = []
    return render_template('poll/poll.html',
                           assignment=assignments[0] if assignments else None,
                           submission=submissions[0] if submissions else None,
                           code=code,
                           course_id=course_id,
                           embed=embed,
                           instructor_mode=instructor_mode,
                           user_id=g.user.id if g.user else None)
예제 #3
0
def load(lti, lti_exception=None):
    assignments, submissions = get_assignments_from_request()
    if not assignments:
        return jsonify(success=False, message="Assignment not found")
    embed = request.values.get('embed', 'false') == 'True'
    # Use the proper template
    if assignments[0].type == 'maze':
        return maze.load(assignments=assignments,
                         submissions=submissions,
                         lti=lti,
                         embed=embed)
    elif assignments[0].type == 'explain':
        return explain.load(assignments=assignments,
                            submissions=submissions,
                            lti=lti,
                            embed=embed)
    elif assignments[0].type in ('corgis (visualizer)', 'visualizer'):
        return corgis.redirect_language_index(language='visualizer',
                                              assignments=assignments,
                                              submissions=submissions,
                                              lti=lti,
                                              embed=embed)
    else:
        return blockpy.load(assignments=assignments,
                            submissions=submissions,
                            lti=lti,
                            embed=embed)
예제 #4
0
def load(lti, lti_exception=None):
    lookup = request.values.get('lookup', None)
    assignment_group_id = None
    if lookup is not None:
        embed = True
        # Security through obscurity
        # AGI_NNYYYY
        # AGI_011 => 1
        # AGI_2278129 => 12
        try:
            INTRO, CODE = lookup.split("_")
            start, length = map(int, CODE[:2])
            assignment_group_id = int(CODE[2+start:2+start+length])
        except ValueError:
            return jsonify(success=False, message="I didn't understand the lookup code: "+lookup)
    else:
        embed = request.values.get('embed', 'false') == 'True'
    assignments, submissions = get_assignments_from_request(assignment_group_id=assignment_group_id)
    if not assignments:
        return jsonify(success=False, message="Assignment not found")
    # Use the proper template
    if assignments[0].type == 'maze':
        return maze.load(assignments=assignments, submissions=submissions, lti=lti,embed=embed)
    elif assignments[0].type in ('corgis (visualizer)', 'visualizer'):
        return corgis.redirect_language_index(language='visualizer', assignments=assignments, submissions=submissions, lti=lti, embed=embed)
    else:
        return blockpy.load(assignments=assignments, submissions=submissions, lti=lti, embed=embed)
예제 #5
0
def load(lti=lti, lti_exception=None, assignments=None, submissions=None, embed=False):
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    return render_template('maze/maze.html',
                                   assignment= assignments[0], 
                                   submission= submissions[0],
                                   level=assignments[0].name,
                                   embed=embed,
                                   user_id=g.user.id)
예제 #6
0
def load(lti=None, assignments=None, submissions=None, embed=False):
    """
    
    """
    if "embed" in request.args:
        embed = request.args.get("embed")
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    if "assignment_group_id" in request.args:
        group_id = int(request.args.get("assignment_group_id"))
    else:
        group_id = None
    if "assignment_id" in request.args:
        assignment_id = request.args.get("assignment_id")
    elif assignments:
        assignment_id = assignments[0].id
    else:
        assignment_id = None
    if assignments:
        if submissions:
            course_id = submissions[0].course_id
        else:
            course_id = assignments[0].course_id
        if g.user and g.user is not None:
            instructor_mode = g.user.is_instructor(course_id)
        else:
            instructor_mode = False
        if 'course_id' in request.values:
            course_id = int(request.values.get('course_id'))
    else:
        instructor_mode = False
        if 'course_id' in request.values:
            course_id = int(request.values.get('course_id'))
        else:
            course_id = None
    group = list(zip(assignments, submissions))

    return render_template('blockpy/blockpy.html',
                           group=group,
                           group_id=group_id,
                           course_id=course_id,
                           user_id=g.user.id if g.user is not None else -1,
                           embed=embed,
                           ip=request.remote_addr,
                           assignment_id=assignment_id,
                           instructor_mode=instructor_mode)
예제 #7
0
def load(lti=lti, lti_exception=None, assignments=None, submissions=None, embed=False):
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    if "assignment_group_id" in request.args:
        group_id = int(request.args.get("assignment_group_id"))
    else:
        group_id = None
    if "assignment_id" in request.args:
        assignment_id = request.args.get("assignment_id")
    elif assignments:
        assignment_id = assignments[0].id
    else:
        assignment_id = None
    if assignments:
        if submissions:
            course_id = submissions[0].course_id
        else:
            course_id = assignments[0].course_id
        if 'course_id' in request.values:
            course_id = int(request.values.get('course_id'))
    else:
        if 'course_id' in request.values:
            course_id = int(request.values.get('course_id'))
        else:
            course_id = None
    group = list(zip(assignments, submissions))
    for assignment, submission in group:
        if assignment_id == None:
            break
        elif assignment.id == int(assignment_id):
            break
    return render_template('maze/maze.html',
                                   group=group,
                                   assignment=assignment,
                                   submission= submission,
                                   assignment_id = assignment.id,
                                   group_id = group_id,
                                   level=assignment.name,
                                   embed=embed,
                                   course_id=course_id,
                                   user_id=g.user.id)
예제 #8
0
def load(lti=lti,
         lti_exception=None,
         assignments=None,
         submissions=None,
         embed=False):
    if assignments is None or submissions is None:
        assignments, submissions = get_assignments_from_request()
    if 'course_id' in request.values:
        course_id = int(request.values.get('course_id'))
    else:
        course_id = g.course.id if "course" in g else None
    MAX_QUESTIONS = 4
    code, elements = submissions[0].load_explanation(MAX_QUESTIONS)
    return render_template('explain/explain.html',
                           assignment=assignments[0],
                           submission=submissions[0],
                           code=code,
                           course_id=course_id,
                           elements=elements,
                           embed=embed,
                           user_id=g.user.id)