from karmaworld.settings.manual_unique_together import auto_add_check_unique_together
ANONYMOUS_UPLOAD_URLS = 'anonymous_upload_urls'
+KEYWORD_MTURK_THRESHOLD = 3
logger = logging.getLogger(__name__)
fs = FileSystemStorage(location=settings.MEDIA_ROOT)
key.set_contents_from_string(html, headers=s3_upload_headers)
key.set_xml_acl(all_read_xml_acl)
+ def remaining_thanks_for_mturk(self):
+ return KEYWORD_MTURK_THRESHOLD - self.thanks
+
+ def total_thanks_for_mturk(self):
+ return KEYWORD_MTURK_THRESHOLD
+
def get_absolute_url(self):
""" Resolve note url, use 'note' route and slug if slug
otherwise use note.id
from django.views.generic import View
from django.views.generic.detail import SingleObjectMixin
-from karmaworld.apps.notes.models import Note
+from karmaworld.apps.notes.models import Note, KEYWORD_MTURK_THRESHOLD
from karmaworld.apps.notes.forms import NoteForm, NoteDeleteForm
word = form['keyword'].data
definition = form['definition'].data
id = form['id'].data
- if word == '':
- continue
+ if not word and not definition:
+ try:
+ keyword_object = Keyword.objects.get(id=id)
+ keyword_object.delete()
+ except (ValueError, ObjectDoesNotExist):
+ pass
try:
keyword_object = Keyword.objects.get(id=id)
except (ValueError, ObjectDoesNotExist):
# If note thanks exceeds a threshold, create a Mechanical
# Turk task to get some keywords for it
- if note.thanks == 3:
+ if note.thanks == KEYWORD_MTURK_THRESHOLD:
submit_extract_keywords_hit.delay(note)
self.choices = choices
def __unicode__(self):
- return "Multiple choice: {0}: {1}".format(self.question_text, ", ".join(map(str, self.choices)))
+ return u"Multiple choice: {0}: {1}".format(self.question_text, ", ".join(map(str, self.choices)))
def __str__(self):
return unicode(self)
return str(self)
-class FlashCardQuestion(BaseQuizQuestion):
- def __init__(self, keyword_side, definition_side):
- self.keyword_side = keyword_side
- self.definition_side = definition_side
-
- def __unicode__(self):
- return "Flash card: {0} / {1}".format(self.keyword_side, self.definition_side)
-
- def __str__(self):
- return unicode(self)
-
- def __repr__(self):
- return str(self)
-
-
class TrueFalseQuestion(BaseQuizQuestion):
def __init__(self, question_text, true):
self.question_text = question_text
self.true = true
def __unicode__(self):
- return "True or false: {0}".format(self.question_text)
+ return u"True or false: {0}".format(self.question_text)
def __str__(self):
return unicode(self)
text=other_keyword.word,
correct=False))
- question_text = 'Pick the keyword to match "{d}"'.format(d=keyword.definition)
+ question_text = u'Pick the keyword to match "{d}"'.format(d=keyword.definition)
return MultipleChoiceQuestion(question_text, choices)
text=other_keyword.definition,
correct=False))
- question_text = 'Pick the definition to match "{w}"'.format(w=keyword.word)
+ question_text = u'Pick the definition to match "{w}"'.format(w=keyword.word)
return MultipleChoiceQuestion(question_text, choices)
other_keyword = random.choice(keywords.exclude(id=keyword.id))
definition = other_keyword.definition
- question_text = 'The keyword "{w}" matches the definition "{d}"'. \
+ question_text = u'The keyword "{w}" matches the definition "{d}"'. \
format(w=keyword.word, d=definition)
return TrueFalseQuestion(question_text, true)
-def _create_keyword_flashcard_blank(keyword):
- return FlashCardQuestion(keyword.definition, keyword.word)
-
-
def quiz_from_keywords(note):
keywords = Keyword.objects.filter(note=note)
questions = []
+ if len(keywords) < 4:
+ return []
+
for keyword in keywords:
if keyword.word and keyword.definition:
question_type = random.choice(GENERATED_QUESTION_TYPE)
logger = get_task_logger(__name__)
-HIT_TITLE = 'Choose keywords and descriptions from course notes'
-HIT_DESCRIPTION = "Read students' course notes on Karmanotes.org and " \
+HIT_TITLE = 'Help people learn by finding keywords in college course notes'
+HIT_DESCRIPTION = "Read students' course notes on KarmaNotes.org and " \
"identify 10 keywords along with descriptions of them"
HIT_OVERVIEW_TEMPLATE = \
'<p>Go to the page at KarmaNotes.org by clicking the link provided below. ' \
<li data-id="keywords-tab-button" data-text="Awesome!" data-options="tip_location: top">
<p>Keywords you define will appear here, and you can define new ones here too.</p>
</li>
+ {% if note.thanks < 3 %}
+ <li data-id="thank-number" data-text="Awesome!" data-options="tip_location: top">
+ <p>Keywords and quizzes are automatically generated when a note gets {{ note.total_thanks_for_mturk }} thanks. This note needs {{ note.remaining_thanks_for_mturk }} more!</p>
+ </li>
+ {% endif %}
</ol>
{% endblock %}
These quiz questions have been randomly generated from the keywords and definitions associated
with this note. Refresh to get different questions.
{% else %}
- No keywords with definitions have been supplied, so we can't generate any quiz questions.
- Provide some key terms with their definitions, and we'll create questions based on them.
+ Not enough keywords with definitions have been supplied, so we can't generate any quiz questions.
+ Provide at least 4 key terms with their definitions, and we'll create questions based on them.
{% endif %}
</div>
</div>