def build_assess_form(q, errorModels=(), bottom='', title='Assessing your answer'): 'return HTML for standard form for round 2' doc = webui.Document(title) if getattr(q, 'showAnswer', False) and getattr(q, 'explanation', False): doc.add_text('Answer: ' + q.explanation, 'B') doc.add_text('<HR>\n') doc.add_text( '''How does your answer compare with the right answer? If your answer was different, please briefly explain below how your reasoning differed.''', 'B') form = webui.Form('submit') form.append(webui.Input('qid', 'hidden', str(q.id))) form.append(webui.Input('stage', 'hidden', 'assess')) options = (('correct', 'Essentially the same.'), ('close', 'Close.'), ('different', 'Different.')) form.append(webui.RadioSelection('assessment', options)) if errorModels: form.append( "<br>\n<b>Did you make any of the following common errors?</b><br>\n" ) form.append( webui.CheckboxSelection('errors', list(enumerate(errorModels)))) form.append('''<br>\nIf you made an error not listed above, please indicate how your reasoning differed from the right idea. Otherwise, you may leave this blank, or ask any question about this problem that still puzzles you:<br>\n''') form.append(webui.Textarea('differences')) form.append('<br>\n') doc.append(form) doc.add_text(bottom) return str(doc)
def build_quizmode_form(formtitle='Switch to Quiz Mode?', explanation='''Quiz Mode presents all questions on a single form, so students answer them all and then submit the form once. This is designed for giving the students a test rather than the usual mode of walking them through one exercise at a time.''', title='Quiz', instructions='''Please answer all of the following questions. You must answer all questions. When you have answered all questions, click Go to submit your answers. Note that your submitted answers are final; you cannot resubmit answers again.''' ): doc = webui.Document(formtitle) doc.add_text(explanation) form = webui.Form('quizmode') form.append('<br>\nQuiz Title:\n') form.append(webui.Input('title', value='Quiz', size=50)) form.append('<br>\nInstructions for the students:<br>\n') form.append(webui.Textarea('instructions', value=instructions)) form.append('<br>\nWill this quiz be graded?<br>\n') options = (('yes', 'Graded'), ('', 'Ungraded')) form.append(webui.RadioSelection('graded', options)) form.append('<br>\n') doc.append(form) return str(doc)
def build_reconsider_form(qid, bottom='', title='Reconsidering your answer'): 'return HTML for standard form for round 2' doc = webui.Document(title) doc.add_text('''<B>Instructions</B>: As soon as your partner is ready, please take turns explaining why you think your answer is right, approximately one minute each. Then answer the following questions:<BR> ''') form = webui.Form('submit') form.append(webui.Input('qid', 'hidden', str(qid))) form.append(webui.Input('stage', 'hidden', 'reconsider')) d = dict( unchanged='I still prefer my original answer.', switched= "I've decided my partner's answer is better (enter his/her name below)." ) form.append(webui.RadioSelection('status', d.items(), selected='unchanged')) add_confidence_choice(form) form.append( "<br>\nYour partner's username (only needed if you prefer their answer):" ) form.append(webui.Input('partner')) form.append('<br>\n') doc.append(form) doc.add_text(bottom) return str(doc)
def _append_to_form(self, form, suffix='', conf=True): l = [] for i, s in enumerate(self.choices): l.append((i, '<B>%s</B>. %s' % (letters[i], s))) form.append(webui.RadioSelection('choice' + suffix, l)) if conf: forms.add_confidence_choice(form) form.append('<br>\n')
def prototype_form(self, offset=0, maxview=None, title='Categorize Responses'): offset = int(offset) unclustered = self.count_unclustered() if unclustered == 0: return self.cluster_report() doc = webui.Document(title) doc.add_text('''<B>Instructions</B>: if you wish, you can choose individual responses as distinct categories of answers, and then ask the students to assign themselves to these categories. However, this is purely <B>optional</B>. Click here to <A HREF="prototype_form">UPDATE</A> for the latest results.''') if self.categories: # not empty doc.add_text('%d Categories' % len(self.categories), 'h1') for r in self.categories: if r == self.correctAnswer: doc.add_text('<B>correct</B>: ' + str(r), 'LI') else: doc.add_text(str(r), 'LI') doc.add_text('%d Uncategorized Responses' % unclustered, 'h1') doc.add_text('''Choose one or more responses as new, distinct categories of student answers:<br> ''') l = list(self.iter_unclustered())[offset:] if not maxview: try: maxview = self.maxview except AttributeError: maxview = 10 maxview = int(maxview) if maxview and len(l) > maxview: l = l[:maxview] form = webui.Form('add_prototypes') for r in l: form.append( webui.RadioSelection('resp_' + str(r.uid), (('add', str(r)), ))) doc.append(form) if offset > 0: doc.add_text( '<A HREF="prototype_form?offset=%d&maxview=%d">[Previous %d]</A>\n' % (max(0, offset - maxview), maxview, maxview)) if maxview and unclustered > offset + maxview: doc.add_text( '<A HREF="prototype_form?offset=%d&maxview=%d">[Next %d]</A>\n' % (offset + maxview, maxview, maxview)) doc.add_text('''<br>If you want to "declare victory", click here to proceed to the <A HREF="cluster_report">cluster report</A>.''') doc.add_text(self.server.admin_nav()) return str(doc)
def build_cluster_form(self, title='Cluster Your Answer'): doc = webui.Document(title) doc.add_text('''Either choose the answer that basically matches your original answer, or choose <B>None of the Above</B><br> ''') form = webui.Form('submit') form.append(webui.Input('qid', 'hidden', str(self.id))) form.append(webui.Input('stage', 'hidden', 'cluster')) l = [] for i, r in enumerate(self.list_categories()): l.append((i, str(r))) l.append(('none', 'None of the above')) form.append(webui.RadioSelection('match', l)) form.append('<br>\n') doc.append(form) doc.add_text(self._navHTML) return str(doc)
def get_choice_form(self, action='vote', confidenceChoice=True, maxreasons=2, fmt='%(answer)s', separator='<hr>\n', useSubmit=True): if useSubmit: form = webui.Form('submit') form.append(webui.Input('qid', 'hidden', str(self.id))) form.append(webui.Input('stage', 'hidden', action)) else: form = webui.Form(action) l = [] for i, category in enumerate(self.list_categories()): responses = self.categories.get(category, ()) try: if self.is_correct(category): tag = 'correct' else: tag = 'wrong' except AttributeError: # correct answer not yet categorized tag = '' d = dict(n=len(responses), tag=tag, answer=str(category)) s = fmt % d if maxreasons and responses: s += '<h3>Some arguments for this:</h3>\n' for r in responses[:maxreasons]: try: s += '<LI>%s</LI>\n' % r.reasons except AttributeError: pass separator = '<hr>\n' s += separator l.append((i, s)) form.append(webui.RadioSelection('choice', l)) if confidenceChoice: forms.add_confidence_choice(form) form.append('<br>\n') return form
def add_confidence_choice(form, levels=('Just guessing', 'Not quite sure', 'Pretty sure')): form.append('<br>\nHow confident are you in your answer?<br>\n') form.append(webui.RadioSelection('confidence', list(enumerate(levels))))