Example #1
0
def editSet(setId=None):
    '''
    Display an edit form for a "Terms and Definitions" set.
    '''
    theset = models.getSetById(setId)
    terms,definitions,termtypes,definitiontypes = models.getSetData(theset)
    return render_template('newset.html', isEdit=True, setId=setId, settitle=theset.title, prompts=terms,
        deftypes=definitiontypes, answers=definitions,private=theset.isprivate, flashes=get_flashed_messages())
Example #2
0
def normalGame(setId, gameType):
    studyset = models.getSetById(setId)
    if not studyset:
        return "404 set not found"
    #terms,defs,termtypes,deftypes = models.getSetData(studyset)
    terms = models.getStudyData(studyset)
    # TODO: ESCAPE QUOTES
    # defs=defs,termtypes=termtypes,deftypes=deftypes
    return render_template('playnormal.html',set=studyset,terms=terms,
        setId=setId,type=gameType,isEditable=True)
Example #3
0
def addOrRemoveFav(setId=None):
    '''
    Add or remove a given set as a favorite.
    '''
    if(models.favExists(g.userId.lower(), setId)):
        models.removeFav(g.userId.lower(),setId)
    else:
        models.addFav(g.userId.lower(),setId)
    #redir back to set
    theset = models.getSetById(setId)
    if theset.settype == "tag":
        return redirect(url_for('tagImage',setId=setId))
    return redirect(url_for('reviewSet',reviewid=setId))
Example #4
0
def viewStats(setId=None):
    '''
    View stats for a given set.
    '''
    theset = models.getSetById(setId)
    terms = []
    if theset.settype == "tag":
        terms = models.getImageTags(setId)
    else:
        terms = models.getStudyData(theset)
    stats = []
    for term in terms:
        overallPercent, num = models.getStatsFor(theset, term)
        stats.append([term, int(round(overallPercent)), overallPercent*6, num])
    mean, distr = models.getOverallStats(theset)
    return render_template('stats.html', stats=stats,theset=theset, mean=int(round(mean)), distr=distr)
Example #5
0
def reviewSet(reviewid=None):
    studyset = models.getSetById(reviewid)
    if not studyset:
        return "404 set not found"
    #terms,defs,termtypes,deftypes = models.getSetData(studyset)
    terms = models.getStudyData(studyset)
    isCreator = False
    isFav = False
    if g.userId != None:
        creator = models.getCreator(reviewid).username
        isCreator = creator.lower() == g.userId.lower()
        isFav = models.favExists(g.userId.lower(), reviewid)
    # TODO: ESCAPE QUOTES
    # ,defs=defs,termtypes=termtypes, deftypes=deftypes,
    return render_template('reviewset.html',settitle=studyset.title,
        private=studyset.isprivate,terms=terms, setId=reviewid,
        isEditable=True, isCreator=isCreator,isFavable=True,isFav=isFav)