def scorecard_view(request): auth = ApiKeyAuthentication() if auth.is_authenticated(request) is not True: return HttpResponse("Unauthorized", status=401) record_mobile_tracker(request, None, "scorecard", '{"en":"homepage"}') start_date = datetime.datetime.now() - datetime.timedelta(days=14) end_date = datetime.datetime.now() media = { "views": Tracker.activity_views(user=request.user, type="media", start_date=start_date, end_date=end_date), "secs": Tracker.activity_secs(user=request.user, type="media", start_date=start_date, end_date=end_date), "points": Points.media_points(user=request.user, start_date=start_date, end_date=end_date), } quiz = { "views": Tracker.activity_views(user=request.user, type="quiz", start_date=start_date, end_date=end_date), "secs": Tracker.activity_secs(user=request.user, type="quiz", start_date=start_date, end_date=end_date), "points": Points.quiz_points(user=request.user, start_date=start_date, end_date=end_date), } acts = { "views": Tracker.activity_views(user=request.user, type="page", start_date=start_date, end_date=end_date), "secs": Tracker.activity_secs(user=request.user, type="page", start_date=start_date, end_date=end_date), "points": Points.page_points(user=request.user, start_date=start_date, end_date=end_date), } total = { "views": acts["views"] + quiz["views"] + media["views"], "secs": acts["secs"] + quiz["secs"] + media["secs"], "points": acts["points"] + quiz["points"] + media["points"], } scorecard = {"media": media, "quiz": quiz, "acts": acts, "total": total} return render_to_response( "oppia/mobile/scorecard.html", {"scorecard": scorecard}, context_instance=RequestContext(request) )
def scorecard_view(request): auth = ApiKeyAuthentication() if auth.is_authenticated(request) is not True: return HttpResponse('Unauthorized', status=401) start_date = datetime.datetime.now() - datetime.timedelta(days=14) end_date = datetime.datetime.now() media = {'views':Tracker.activity_views(user=request.user,type='media',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='media',start_date=start_date,end_date=end_date), 'points':Points.media_points(user=request.user,start_date=start_date,end_date=end_date)} quiz = {'views':Tracker.activity_views(user=request.user,type='quiz',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='quiz',start_date=start_date,end_date=end_date), 'points':Points.quiz_points(user=request.user,start_date=start_date,end_date=end_date)} acts = {'views':Tracker.activity_views(user=request.user,type='page',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='page',start_date=start_date,end_date=end_date), 'points':Points.page_points(user=request.user,start_date=start_date,end_date=end_date)} total = {'views':acts['views'] + quiz['views'] + media['views'], 'secs': acts['secs'] + quiz['secs'] + media['secs'], 'points': acts['points'] + quiz['points'] + media['points'],} scorecard = {'media':media, 'quiz':quiz, 'acts':acts, 'total': total} return render_to_response('oppia/mobile/scorecard.html',{ 'scorecard':scorecard }, context_instance=RequestContext(request))
def scorecard_view(request): auth = ApiKeyAuthentication() if auth.is_authenticated(request) is not True: return HttpResponse('Unauthorized', status=401) record_mobile_tracker(request,None,'scorecard','{"en":"homepage"}') start_date = datetime.datetime.now() - datetime.timedelta(days=14) end_date = datetime.datetime.now() media = {'views':Tracker.activity_views(user=request.user,type='media',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='media',start_date=start_date,end_date=end_date), 'points':Points.media_points(user=request.user,start_date=start_date,end_date=end_date)} quiz = {'views':Tracker.activity_views(user=request.user,type='quiz',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='quiz',start_date=start_date,end_date=end_date), 'points':Points.quiz_points(user=request.user,start_date=start_date,end_date=end_date)} acts = {'views':Tracker.activity_views(user=request.user,type='page',start_date=start_date,end_date=end_date), 'secs':Tracker.activity_secs(user=request.user,type='page',start_date=start_date,end_date=end_date), 'points':Points.page_points(user=request.user,start_date=start_date,end_date=end_date)} total = {'views':acts['views'] + quiz['views'] + media['views'], 'secs': acts['secs'] + quiz['secs'] + media['secs'], 'points': acts['points'] + quiz['points'] + media['points'],} scorecard = {'media':media, 'quiz':quiz, 'acts':acts, 'total': total} return render_to_response('oppia/mobile/scorecard.html',{ 'scorecard':scorecard }, context_instance=RequestContext(request))
def dehydrate_quiz_points(self, bundle): start_date = datetime.datetime.now() - datetime.timedelta(days=14) end_date = datetime.datetime.now() return Points.quiz_points(user=bundle.obj, start_date=start_date, end_date=end_date)
def dehydrate_quiz_points(self,bundle): start_date = datetime.datetime.now() - datetime.timedelta(days=14) end_date = datetime.datetime.now() return Points.quiz_points(user=bundle.obj,start_date=start_date,end_date=end_date)