Skip to content

Instantly share code, notes, and snippets.

@moschlar
Forked from ralphbean/submission.py
Created May 29, 2012 20:22
Show Gist options
  • Save moschlar/2830475 to your computer and use it in GitHub Desktop.
Save moschlar/2830475 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
'''
Created on 17.03.2012
Ported to tw2 on 25.05.2012
@author: moschlar
'''
import tw2.core as twc
import tw2.forms as twf
import tw2.bootstrap as twb
from sauce.model import DBSession, Assignment
class language_id(twf.SingleSelectField):
options = [x for x in enumerate((u'Brainfuck', ))]
def prepare(self):
self.options = [
(lang.id, lang.name)
for lang in DBSession.query(Assignment)\
.get(self.parent.parent.assignment_id.value).allowed_languages
]
super(language_id, self).prepare()
class SubmissionForm(twb.HorizontalForm):
#class SubmissionForm(twf.TableForm):
title = 'Submission'
assignment_id = twf.HiddenField()
submission_id = twf.HiddenField()
filename = twf.TextField()
source = twf.TextArea(
placeholder=u'Paste your source code here',
css_class='span5', rows=8)
source_file = twf.FileField(css_class='span5')
language_id = language_id
submit_help = twf.Label(text=u'''
When you click "Test", your submission will be checked against the test cases
you see on the assignment page. You are only allowed to submit if these tests
have been run successful.
If you click "Finish", your submission will be closed (and will not be
editable any more) and will be verified with the test cases visible to
you and probably some more test cases your teacher provided.
When you click "Delete" your submission will be deleted.
''')
# Hide submit field
submit_text = None
# And use my own ones
buttons = [
twb.SubmitButton('test', value='Test', css_class='btn btn-primary'),
twb.SubmitButton('submit', value='Submit', css_class='btn btn-success'),
twb.SubmitButton('reset', value='Delete', css_class='btn btn-danger')
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment