예제 #1
0
def modifyUSession():
    uSession = UserSession.query.get(request.args['sessionID'])
    newDescription = uSession.description
    newFeedBack_score = uSession.feedback_score
    newStart_date = uSession.start_date
    newEnd_date = uSession.end_date
    newCourse = Course.query.get(request.args["courseID"])
    if not(newDescription == request.args['description']):
        newDescription = request.args['description']
    if not(newFeedBack_score == request.args['feedback']):
        newFeedBack_score = request.args['feedback']
    from datetime import datetime
    if not(newStart_date == datetime.fromtimestamp(float(request.args['startDate'])/1000)):
        newStart_date = datetime.fromtimestamp(float(request.args['startDate'])/1000)
    if not(newEnd_date == datetime.fromtimestamp(float(request.args['endDate'])/1000)):
        newEnd_date = datetime.fromtimestamp(float(request.args['endDate'])/1000)
    newSession = UserSession(uSession.user, newCourse, newDescription, newFeedBack_score, newStart_date, newEnd_date)
    oldId =uSession.id
    uSession.deleteUntrackedSession()
    db.session.delete(uSession)
    db.session.commit()
    newSession.id = oldId
    db.session.add(newSession)
    db.session.commit()
    
    return "done"
예제 #2
0
def createTestSessions():
    x = 0
    data = ""
    while x < 10:
        userID = random.randint(1,len(User.query.all())-1)
        user = User.query.get(userID)
        courses = user.getUserCourses()
        course = courses[random.randint(0,len(courses)-1)]
        userSession = UserSession(user, course, "Ik ben aan het studeren, dus ik ben een goede student!")
        randomStart = random.randint(1386264114,1416264114)
        userSession.start_date = datetime.fromtimestamp(randomStart)
        randomEnd = randomStart + random.randint(0,7200)
        userSession.end_date = datetime.fromtimestamp(randomEnd)
        db.session.add(userSession)
        db.session.commit()
        i = 0
        while (i < (randomEnd-randomStart)):
            pauze = random.randint(0,50)
            if(pauze == 1):
                pauze = json.loads(userSession.pauses)
                pauzeTime=random.uniform(0,userSession.getSessionDuration()/5)
                pauze.append( (i,i+pauzeTime) )
                userSession.pauses = json.dumps(pauze)
            generateTestData(userSession,i)
            i = i+50
        userSession.setFeedback(random.random())
        userSession.commitSession()
        data = data + user.email.__str__() + " heeft een tracked session gedaan voor het vak: " + course.course + ". totale studietijd: " + userSession.getSessionDuration().__str__() + " seconden."
        data = data + "\n"
        x = x+1
    return data
예제 #3
0
def modifieUntrackedSession():
    uSession = UserSession.query.get(1)
    oldId = uSession.id
    newDescription = uSession.description
    newFeedBack_score = uSession.feedback_score
    newStart_date = uSession.start_date
    newEnd_date = uSession.end_date
    if not(newDescription == "description is aangepast"):
        newDescription = "description is aangepast"
    if not(newFeedBack_score == "nieuweFeedback"):
        newFeedBack_score = "nieuweFeedback"
    if not(newStart_date == newStart_date):
        newStart_date = newStart_date
    if not(newEnd_date == newEnd_date):
        newEnd_date = newEnd_date
    newSession = UserSession(uSession.user, uSession.course, newDescription, newFeedBack_score, newStart_date, newEnd_date)
    db.session.delete(uSession)
    db.session.commit()
    newSession.id = oldId
    db.session.add(newSession)
    db.session.commit()
    return "ok"
예제 #4
0
def createUntrackedSession():
    x=0
    data =""
    while x <4:
        userID = random.randint(1,5)
        user = User.query.get(userID)
        courseID = random.randint(1,11)
        course = Course.query.get(courseID)
        randomStart = random.randint(1386264114,1416264114)
        start_date = datetime.fromtimestamp(randomStart)
        randomEnd = randomStart + random.randint(0,7200)
        end_date = datetime.fromtimestamp(randomEnd)
        feedback_text = "dat was een lastige studeersessie"
        userSession = UserSession(user, course , "een untracked studeersessie", feedback_text, start_date, end_date)
        db.session.add(userSession)
        db.session.commit()
        data = data + user.email.__str__() + " heeft een untracked session gedaan voor het vak: " + course.course + ". totale studietijd: " + userSession.getSessionDuration().__str__() + " seconden."
        data = data + "\n"
        x=x+1 
    return data