Exemplo n.º 1
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)
Exemplo n.º 2
0
def tagImage(setId=None, play=None):
    theSet = models.getTagSet(setId)
    width,height = models.getImageDims(setId)
    tags = models.getImageTags(setId)
    isCreator = False
    if g.userId != None:
        creator = models.getCreator(setId).username
        isCreator = creator.lower() == g.userId.lower()
    isGame,isEdit = False,False
    if play == 'edit':
        isEdit = True
    elif play:
        isGame = True
    isFav = False 
    if g.userId:
        isFav = models.favExists(g.userId.lower(), setId) #TODO BREAKS WHEN NOT LOGGED IN
    return render_template('tagimage.html', theset=theSet, setId=setId,imgwidth=width,
        imgheight=height, tags=tags, isCreator=isCreator,isGame=isGame, isEditable=True, isEdit=isEdit,
        isFavable=True,isFav=isFav, flashes=get_flashed_messages())