本文整理汇总了Python中models.Test.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Test.get_by_id方法的具体用法?Python Test.get_by_id怎么用?Python Test.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Test
的用法示例。
在下文中一共展示了Test.get_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_test
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def new_test():
form = TestForm()
if form.validate_on_submit():
test = Test(
test_name=form.test_name.data,
num_mc=form.num_mc.data,
mc_answers = int(form.mc_answers.data),
num_or=form.num_or.data,
#or_points = int(form.or_points.data),
num_students=form.num_students.data,
#test_data = defaultGrid(form.num_mc.data, int(form.mc_answers.data), form.num_or.data, form.or_points.data,form.num_students.data),
mc_data = mcDetails(form.num_mc.data, int(form.mc_answers.data)),
or_data = orDetails(form.num_mc.data,form.num_or.data),
student_data = studentDetails(form.num_students.data),
added_by=session['email']
)
try:
test.put()
test_id = test.key.id()
test = Test.get_by_id(test_id)
mc_data = json.dumps(test.mc_data)
or_data = json.dumps(test.or_data)
student_data = json.dumps(test.student_data)
flash(u'Test %s successfully saved.' % test_id, 'success')
return render_template('test_details.html', test = Test.get_by_id(test_id), test_id = test_id, mc_data = mc_data, or_data = or_data, student_data = student_data)
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'info')
return redirect(url_for('list_tests'))
return redirect(url_for('list_tests'))
示例2: student_details
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def student_details(test_id):
test = Test.get_by_id(test_id)
if request.method == "POST":
data = request.get_json(force=False, silent=False, cache=False)
test.student_data = data
test.put()
student_data = json.dumps(test.student_data)
return render_template('student_details.html', test_id = test_id, test = test, student_data = student_data)
示例3: update_test
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def update_test(test_id):
test = Test.get_by_id(test_id)
if request.method == "POST":
data = request.get_json(force=False, silent=False, cache=False)
test.test_data = data
#test.test_data = request.get_json(force=False, silent=False, cache=False);
test.put()
new_data = json.dumps(test.test_data)
return render_template('update_test.html', test=test, mc_data = new_data, bad_test = test.test_data)
示例4: delete_test
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def delete_test(test_id):
"""Delete a test object"""
test = Test.get_by_id(test_id)
try:
test.key.delete()
flash(u'Test %s successfully deleted.' % test_id, 'success')
return redirect(url_for('list_tests'))
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'info')
return redirect(url_for('list_tests'))
示例5: edit_test
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def edit_test(test_id):
test = Test.get_by_id(test_id)
form = TestForm(obj=test)
if request.method == "POST":
if form.validate_on_submit():
test.test_name = form.data.get('test_name')
test.num_mc = form.data.get('num_mc')
test.num_or = form.data.get('num_or')
#test.num_students = json.dumps(form.data.get('num_students'))
test.num_students = form.data.get('num_students')
test.put()
flash(u'Test %s successfully saved.' % test_id, 'success')
return redirect(url_for('list_tests'))
return render_template('edit_test.html', test=test, form=form)
示例6: test_details
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def test_details(test_id):
test = Test.get_by_id(test_id)
if request.method == "POST":
data = request.get_json(force=False, silent=False, cache=False)
if data[0][0] == "Open Response":
test.or_data = data
test.put()
elif data[0][0] == "Multiple Choice":
test.mc_data = data
test.put()
else:
test.student_data = data
test.put()
mc_data = json.dumps(test.mc_data)
or_data = json.dumps(test.or_data)
student_data = json.dumps(test.student_data)
return render_template('test_details.html', test_id = test_id, test = test, mc_data = mc_data, or_data = or_data, student_data = student_data)
示例7: analysis
# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import get_by_id [as 别名]
def analysis(test_id):
test = Test.get_by_id(test_id)
analysis_data, fixedRows, num_mc, num_or, num_groups, num_periods = analysisGrid(test.num_mc, test.num_or, test.mc_data, test.or_data, test.mc_answers, test.student_data) #, test.or_points)
analysis_data = json.dumps(analysis_data)
return render_template('test_analysis.html', test_id = test_id, test = test, analysis_data = analysis_data, fixedRows = fixedRows, num_mc = num_mc, num_or = num_or, num_groups = num_groups, num_periods = num_periods)