コード例 #1
0
def save_presentation(lti=lti):
    assignment_id = request.values.get('assignment_id', None)
    if assignment_id is None:
        return failure("No Assignment ID given!")
    presentation = request.values.get('introduction', "")
    parsons = request.values.get('parsons', "false") == "true"
    importable = request.values.get('importable', "false") == "true"
    secret = request.values.get('secret', "false") == "true"
    disable_algorithm_errors = request.values.get('disable_algorithm_errors',
                                                  'false') == 'true'
    disable_timeout = request.values.get('disable_timeout', 'false') == 'true'
    #text_first = request.values.get('text_first', "false") == "true"
    mode = request.values.get("initial", None)
    name = request.values.get('name', "")
    modules = request.values.get('modules', "")
    files = request.values.get('files', "")
    assignment = Assignment.by_id(int(assignment_id))
    if not g.user.is_instructor(int(assignment.course_id)):
        return jsonify(
            success=False,
            message="You are not an instructor in this assignments' course.")
    Assignment.edit(assignment_id=assignment_id,
                    presentation=presentation,
                    name=name,
                    parsons=parsons,
                    mode=mode,
                    modules=modules,
                    importable=importable,
                    disable_algorithm_errors=disable_algorithm_errors,
                    disable_timeout=disable_timeout,
                    files=files,
                    secret=secret)
    return jsonify(success=True, ip=request.remote_addr)
コード例 #2
0
ファイル: lti.py プロジェクト: scareface972/blockpy
def save_presentation(lti=lti):
    assignment_id = request.form.get('question_id', None)
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    presentation = request.form.get('presentation', "")
    name = request.form.get('name', "")
    if User.is_lti_instructor(session["roles"]):
        Assignment.edit(assignment_id=assignment_id, presentation=presentation, name=name)
        return jsonify(success=True)
    else:
        return jsonify(success=False, message="You are not an instructor!")
コード例 #3
0
ファイル: blockpy.py プロジェクト: RealTimeWeb/Blockpy-Server
def save_presentation(lti=lti):
    assignment_id = request.form.get('assignment_id', None)
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    presentation = request.form.get('introduction', "")
    parsons = request.form.get('parsons', "false") == "true"
    importable = request.form.get('importable', "false") == "true"
    text_first = request.form.get('text_first', "false") == "true"
    name = request.form.get('name', "")
    modules = request.form.get('modules', "")
    assignment = Assignment.by_id(int(assignment_id))
    if not g.user.is_instructor(int(assignment.course_id)):
        return jsonify(success=False, message="You are not an instructor in this assignments' course.")
    Assignment.edit(assignment_id=assignment_id, presentation=presentation, name=name, parsons=parsons, text_first=text_first, modules=modules, importable=importable)
    return jsonify(success=True)
コード例 #4
0
def save_questions(lti=lti):
    assignment_id = request.form.get('assignment_id', None)
    course_id = request.values.get('course_id',
                                   g.course.id if 'course' in g else None)
    if None in (assignment_id, course_id):
        return jsonify(success=False,
                       message="No Assignment ID or Course ID given!")
    if not g.user.is_instructor(int(course_id)):
        return jsonify(
            success=False,
            message="You are not an instructor in this assignments' course.")
    body = request.form.get('body', '')
    Assignment.edit(assignment_id=assignment_id,
                    presentation=body,
                    type='poll')
    return jsonify(success=True)
コード例 #5
0
ファイル: blockpy.py プロジェクト: houcy/Blockpy-Server
def save_presentation(lti=lti):
    assignment_id = request.values.get('assignment_id', None)
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    presentation = request.values.get('introduction', "")
    parsons = request.values.get('parsons', "false") == "true"
    importable = request.values.get('importable', "false") == "true"
    disable_algorithm_errors = request.values.get('disable_algorithm_errors', 'false') == 'true'
    text_first = request.values.get('text_first', "false") == "true"
    name = request.values.get('name', "")
    modules = request.values.get('modules', "")
    assignment = Assignment.by_id(int(assignment_id))
    if not g.user.is_instructor(int(assignment.course_id)):
        return jsonify(success=False, message="You are not an instructor in this assignments' course.")
    Assignment.edit(assignment_id=assignment_id, presentation=presentation, name=name, parsons=parsons, text_first=text_first, modules=modules, importable=importable, disable_algorithm_errors=disable_algorithm_errors)
    return jsonify(success=True)
コード例 #6
0
def save_presentation(lti=lti):
    assignment_id = request.form.get('question_id', None)
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    presentation = request.form.get('presentation', "")
    parsons = request.form.get('parsons', "false") == "true"
    text_first = request.form.get('text_first', "false") == "true"
    name = request.form.get('name', "")
    if User.is_lti_instructor(session["roles"]):
        Assignment.edit(assignment_id=assignment_id,
                        presentation=presentation,
                        name=name,
                        parsons=parsons,
                        text_first=text_first)
        return jsonify(success=True)
    else:
        return jsonify(success=False, message="You are not an instructor!")
コード例 #7
0
def save_code(lti=lti):
    assignment_id = request.values.get('assignment_id', None)
    assignment_version = int(request.values.get('version', -1))
    course_id = request.values.get('course_id',
                                   g.course.id if 'course' in g else None)
    if None in (assignment_id, course_id) or course_id == "":
        return failure("No Assignment ID or Course ID given!")
    code = request.values.get('code', '')
    timestamp = request.values.get('timestamp', '')
    filename = request.values.get('filename', '__main__')
    is_version_correct = True
    if filename == "__main__":
        submission, is_version_correct = Submission.save_code(
            g.user.id,
            assignment_id,
            int(course_id),
            code,
            assignment_version,
            timestamp=timestamp)
    elif g.user.is_instructor(int(course_id)):
        if filename == "give_feedback":
            Assignment.edit(assignment_id=assignment_id, give_feedback=code)
        elif filename == "on_change":
            Assignment.edit(assignment_id=assignment_id, on_step=code)
        elif filename == "starting_code":
            Assignment.edit(assignment_id=assignment_id, starting_code=code)
        log = Log.new('instructor',
                      filename,
                      assignment_id,
                      g.user.id,
                      body=code,
                      timestamp=timestamp)
    return jsonify(success=True,
                   is_version_correct=is_version_correct,
                   ip=request.remote_addr)
コード例 #8
0
ファイル: blockpy.py プロジェクト: RealTimeWeb/Blockpy-Server
def save_code(lti=lti):
    assignment_id = request.form.get('assignment_id', None)
    assignment_version = int(request.form.get('version', -1))
    course_id = request.form.get('course_id', g.course.id)
    if None in (assignment_id, course_id):
        return jsonify(success=False, message="No Assignment ID or Course ID given!")
    code = request.form.get('code', '')
    filename = request.form.get('filename', '__main__')
    is_version_correct = True
    if filename == "__main__":
        submission, is_version_correct = Submission.save_code(g.user.id, assignment_id, int(course_id), code, assignment_version)
    elif g.user.is_instructor(int(course_id)):
        if filename == "give_feedback":
            Assignment.edit(assignment_id=assignment_id, give_feedback=code)
        elif filename == "on_change":
            Assignment.edit(assignment_id=assignment_id, on_step=code)
        elif filename == "starting_code":
            Assignment.edit(assignment_id=assignment_id, starting_code=code)
    return jsonify(success=True, is_version_correct=is_version_correct)
コード例 #9
0
ファイル: lti.py プロジェクト: scareface972/blockpy
def save_code(lti=lti):
    assignment_id = request.form.get('question_id', None)
    assignment_version = int(request.form.get('version', -1))
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    code = request.form.get('code', '')
    filename = request.form.get('filename', '__main__')
    user = User.from_lti("canvas", session["pylti_user_id"], 
                         session.get("user_email", ""),
                         session.get("lis_person_name_given", ""),
                         session.get("lis_person_name_family", ""))
    is_version_correct = True
    if filename == "__main__":
        submission, is_version_correct = Submission.save_code(user.id, assignment_id, code, assignment_version)
    elif User.is_lti_instructor(session["roles"]):
        if filename == "on_run":
            Assignment.edit(assignment_id=assignment_id, on_run=code)
        elif filename == "on_change":
            Assignment.edit(assignment_id=assignment_id, on_step=code)
        elif filename == "starting_code":
            Assignment.edit(assignment_id=assignment_id, on_start=code)
    return jsonify(success=True, is_version_correct=is_version_correct)
コード例 #10
0
def save_code(lti=lti):
    assignment_id = request.form.get('question_id', None)
    assignment_version = int(request.form.get('version', -1))
    if assignment_id is None:
        return jsonify(success=False, message="No Assignment ID given!")
    code = request.form.get('code', '')
    filename = request.form.get('filename', '__main__')
    user = User.from_lti("canvas", session["pylti_user_id"],
                         session.get("user_email", ""),
                         session.get("lis_person_name_given", ""),
                         session.get("lis_person_name_family", ""))
    is_version_correct = True
    if filename == "__main__":
        submission, is_version_correct = Submission.save_code(
            user.id, assignment_id, code, assignment_version)
    elif User.is_lti_instructor(session["roles"]):
        if filename == "on_run":
            Assignment.edit(assignment_id=assignment_id, on_run=code)
        elif filename == "on_change":
            Assignment.edit(assignment_id=assignment_id, on_step=code)
        elif filename == "starting_code":
            Assignment.edit(assignment_id=assignment_id, on_start=code)
    return jsonify(success=True, is_version_correct=is_version_correct)