Exemplo n.º 1
0
def poblar_student_video(student_name,kaid_student, dates, session):
    llamada = "/api/v1/user/videos?userId=&username="******"&email=&dt_start="+dates
    jason = get_api_resource2(session,llamada,SERVER_URL2)
    source = unicode(jason, 'ISO-8859-1')
    data = simplejson.loads(source)
    for i in range(len(data)):
        #if data[i]["points"] >0 :
        try:
            student_video = Student_Video(total_seconds_watched = data[i]["seconds_watched"],
                                                                       total_points_earned = data[i]["points"],
                                                                       last_second_watched = data[i]["last_second_watched"],
                                                                       is_video_complete = data[i]["completed"],
                                                                       id_video_name_id = data[i]["video"]["id"],
                                                                       kaid_student_id = kaid_student,
                                                                       youtube_id = data[i]["video"]["youtube_id"]
                                                                       )
            student_video.save()
        except:
            pass
Exemplo n.º 2
0
def poblar_student_video(student_name,kaid_student, dates, session):
    llamada = "/api/v1/user/videos?userId=&username="******"&email=&dt_start="+dates
    jason = get_api_resource2(session,llamada,SERVER_URL)
    source = unicode(jason, 'ISO-8859-1')
    data = simplejson.loads(source)
    #print "videos: ", len(data)
    for k in range(len(data)):
        #if data[i]["points"] >0 :
        #Tratar de hacer una especie de update_or_create()
        try:
            student_video = Student_Video(total_seconds_watched = data[k]["seconds_watched"],
                                                                       total_points_earned = data[k]["points"],
                                                                       last_second_watched = data[k]["last_second_watched"],
                                                                       is_video_complete = data[k]["completed"],
                                                                       id_video_name_id = data[k]["video"]["id"],
                                                                       kaid_student_id = kaid_student,
                                                                       youtube_id = data[k]["video"]["youtube_id"]
                                                                       )
            student_video.save()
        except Exception as e:
            logging.info(e)