Commit bc92365b authored by Antoine PIGEAU's avatar Antoine PIGEAU
Browse files

Merge remote-tracking branch 'origin/master' into 2016-2017-Indicators

Conflicts:
	2015-Hubble-UserProfile/statisticManager/userStatistic.py
parents e6482245 91511e65
......@@ -27,6 +27,7 @@ import operator
from _sqlite3 import DatabaseError
from dataManager.databaseManagerData4 import DatabaseManager
from scriptDatabaseManager4 import ScriptDatabaseManager
from setuptools.dist import sequence
class Course:
'''
......@@ -270,6 +271,10 @@ class Course:
return idExercises;
def getNumberofExercise(self):
return len(self.getAllExercisesId())
def getSequenceId(self, filterType=[]):
'''
return the ids for the sequence of the course
......@@ -331,5 +336,16 @@ class Course:
return dictDuration
def isConsecutive(self, currentPart, nextPart):
sequenceWithoutExercise = self.getSequenceId(filterType=[Course.CHAPTER])
for i in range(len(sequenceWithoutExercise)-1):
if (sequenceWithoutExercise[i] == currentPart and
sequenceWithoutExercise[i+1] == nextPart):
return True
return False
def __str__(self):
return "id:"+str(self.id)+" title:"+self.title+" sequence:"+str(self.sequence)
\ No newline at end of file
......@@ -808,6 +808,37 @@ class DatabaseManager:
'''
self.removeAllTuples(DatabaseManager.TABLE_RESULT_NAME)
def getResultOfUser(self, idUser, idCourse):
'''
retrieve the result of the user idUser
'''
result = None
try:
self.connection.text_factory = str
cursor = self.connection.cursor()
query = ("SELECT r."+DatabaseManager.RESULT_COLUMN_USER_SCORE+
" FROM "+DatabaseManager.TABLE_RESULT_NAME+" r WHERE r."+
DatabaseManager.RESULT_COLUMN_USER_ID+" = \'"+str(idUser)+"\' AND r."+
DatabaseManager.RESULT_COLUMN_COURSE_ID+" = "+str(idCourse))
print str(query)
cursor.execute(query)
rows = cursor.fetchall()
for row in rows:
result = row[0]
except:
print "DatabaseManager - getResultOfUser(idUser, idCourse) error:", sys.exc_info()[0], sys.exc_info()[1]
return result
'''
*******************************************************************************************
......@@ -1230,7 +1261,7 @@ class DatabaseManager:
def getPremium(self, idCourse):
'''
retrieve all the users that follows a course idCourse as a premium, even the premium isers without a mark
retrieve all the users that follows a course idCourse as a premium, even the premium users without a mark
@param idCourse: the id of the course followed
......@@ -1264,7 +1295,7 @@ class DatabaseManager:
'''
retrieve the premium users that take the course courseId and got a mark higher or equal to minScore and strictly lower than maxScore
The user is considered as a premium for a course if the user is registered as premium if he passed the exam in the interval of
Old version : The user is considered as a premium for a course if the user is registered as premium if he passed the exam in the interval of
the premium registration + 15 days: [startedat, endedat + 15 days]
@return: a list (userId, ...userId)
......@@ -1280,9 +1311,11 @@ class DatabaseManager:
"SELECT DISTINCT(p.userid) FROM premium p, result r WHERE "+
"p.userid = r.userid AND "+
"r.courseid = "+str(courseId)+" AND "+
"DATE(r.createdat) BETWEEN DATE(p.startedat) AND DATE(p.endedat, '+15 day') AND r.score >= "+
#"DATE(r.createdat) BETWEEN DATE(p.startedat) AND DATE(p.endedat, '+15 day') AND r.score >= "+
str(DatabaseManager.BOUNDARY_SCORE_FAILED)+" AND r.score < "+str(DatabaseManager.BOUNDARY_SCORE_SUCCEED))
print str(query)
cursor.execute(query)
......
......@@ -50,7 +50,7 @@ if __name__ == "__main__":
print("start of the process testCheck")
startTime = datetime.now()
course = Course(Course.COURSE_ID_BOOTSTRAP)
course = Course(Course.COURSE_ID_ARDUINO)
databaseManager = DatabaseManager()
similarity = Similarity()
frequentSequence = FrequentSequenceLaptop()
......@@ -67,30 +67,46 @@ if __name__ == "__main__":
display a specific sequence
'''
l = sequenceSession.loadSavedSequences(Course.COURSE_ID_ARDUINO)
for (userId, seq) in l:
print(str(seq))
# for (userId, seq) in l:
# print(str(seq))
i = 0
for (userId, seq) in l :
if(userId == 'f4e11762405de6a8491e2516d61dee37'): # d349d66bbba4eb559840b4bb279b2c64
if(userId == 'f4e11762405de6a8491e2516d61dee37'):
#if(len(seq) < 5): # d349d66bbba4eb559840b4bb279b2c64
for item in seq:
print(str(item))
course = Course(Course.COURSE_ID_ARDUINO)
userStatistic = UserStatistic(Course.COURSE_ID_ARDUINO)
print(str(dir(userStatistic)))
userStatistic.setUserSequence((userId, seq))
print("total duration:"+str(userStatistic.computeTotalDuration()))
print("computeAverageDurationOnEachPart:"+str(userStatistic.computeAverageDurationOnEachPart(filterType=[Course.CHAPTER])))
print("AverageIndicatorTimeSession:"+str(userStatistic.computeIndicatorInterTimeSession()))
print("computeNumberAccessPerPartID:"+str(userStatistic.computeNumberAccessPerPartID(filterType=[Course.CHAPTER])))
print("computeNumberOfSessions:"+str(userStatistic.computeNumberOfSessions()))
print("total duration:"+str(userStatistic.getTotalDuration()))
print("getAverageDurationOnEachPart:"+str(userStatistic.getAverageDurationOnEachPart(filterType=[Course.CHAPTER])))
print("getIndicatorInterTimeSession:"+str(userStatistic.getIndicatorInterTimeSession()))
print("getNumberAccessPerPartID:"+str(userStatistic.getNumberAccessPerPartID(filterType=[Course.CHAPTER])))
print("getNumberOfSessions:"+str(userStatistic.getNumberOfSessions()))
print("All Marks:"+str(userStatistic.getAllMarks()))
print("percent of course viewed:"+str(userStatistic.computePercentOfCourseViewed(filterTypeP=[Course.CHAPTER])))
print("computeDurationBeforeEachAssessment:"+str(userStatistic.computeDurationBeforeEachAssessment()))
print("computeAverageTimeByAccess:"+str(userStatistic.computeAverageTimeByAccess()))
(average, median, stdDeviation, interTimes) = userStatistic.computeIndicatorInterTimeSession()
print("Number of Marks:"+str(userStatistic.getNumberOfMarks()))
print("percent of course viewed:"+str(userStatistic.getPercentOfCourseViewed(filterTypeP=[Course.CHAPTER])))
print("getDurationBeforeEachAssessment:"+str(userStatistic.getDurationBeforeEachAssessment()))
print("getAverageTimeByAccess:"+str(userStatistic.getAverageTimeByAccess()))
(average, median, stdDeviation, interTimes) = userStatistic.getIndicatorInterTimeSession()
print("inter session time, average/median, stdDeviation:"+str(average)+" "+str(median)+" "+str(stdDeviation))
print("inter session time, list inter times:"+str(interTimes))
print("stats session:"+str(userStatistic.getStatsSession()))
print("split list:"+str(userStatistic._UserStatistic__splitBySession()))
print("linearity:"+str(userStatistic.getLinearity()))
print("Course sequence"+str(course.getSequenceId(filterType=[Course.CHAPTER])))
print("Last event after 1 week:"+str(userStatistic.getTimeSinceLastEvent(7)))
print("Last event after 2 weeks:"+str(userStatistic.getTimeSinceLastEvent(14)))
print("Last event after 3 weeks:"+str(userStatistic.getTimeSinceLastEvent(21)))
print("# of events before each quizz:"+str(userStatistic.getNumberOfEventBeforeEachAssessment()))
print("# of sessions before each quizz:"+str(userStatistic.getNumberOfSessionBeforeEachAssessment()))
print("per day number of events, sessions:"+str(userStatistic._UserStatistic__getStatsPerDay()))
print("# of session/event per day before each quizz:"+str(userStatistic.getAverageStatsPerDayBeforeEachAssessment()))
print("\n\n")
else:
pass
......
......@@ -22,25 +22,31 @@ This file is part of Hubble-UserProfile.
import sys
from datetime import datetime
from statisticManager import scriptTimeBetweenSession
from statisticManager.userStatistic import UserStatistic
sys.setrecursionlimit(10000)
from dataManager.course import Course
from dataManager.scriptDatabaseManager4 import ScriptDatabaseManager
from dataManager.databaseManagerData4 import DatabaseManager
from sequenceManager.sequenceInterface import SequenceInterface
from sequenceManager.sequenceVisualisation import SequenceVisualisation
from sequenceManager.sequenceSession import SequenceSession
from sequenceManager.scriptSequence import ScriptSequence
from sequenceManager.similarity import Similarity
from sequenceManager.frequentSequence import FrequentSequenceLaptop
from userManager.userManagerSession import UserManagerSession
from userManager.userManagerProxy import UserManagerProxy
from statisticManager.plotHistogram import PlotHistogram
from statisticManager.countHistogram import CountHistogram
from statisticManager.durationHistogram import DurationHistogram
from statisticManager.scriptHistogram import ScriptHistogram
from sequenceManager.frequentSequence import FrequentSequenceLaptop
from statisticManager.userDurationCurve import UserDurationCurve
from statisticManager.scriptUserDurationCurve import ScriptUserDurationCurve
from statisticManager.scriptTimeBetweenSession import ScriptTimeBetweenSession
from statisticManager.scriptUserDeviationAveragePoint import ScriptUserDeviationAveragePoint
......@@ -48,7 +54,12 @@ from statisticManager.scriptNumberSessionHistogram import ScriptNumberSessionHis
from statisticManager.scriptSimpleStatistic import ScriptSimpleStatistic
from statisticManager.scriptFrequentSequenceStatistic import ScriptFrequentSequenceStatistic
from statisticManager.interTimeBoxPlot import InterTimeBoxPlot
from statisticManager.scriptInterTimeBoxPlot import ScriptInterTimeBoxPlot
from statisticManager.scriptUserMarksPerQuizBoxPlot import ScriptUserMarkdsPerQuizBoxPlot
from statisticManager.scriptAccessPerSessionBoxPlot import ScriptAccessPerSessionBoxPlot
from statisticManager.scriptDurationOnEachPartBoxPlot import ScriptDurationOnEachPartBoxPlot
from statisticManager.scriptDurationBeforeEachQuizz import ScriptDurationBeforeEachQuizz
from statisticManager.scriptPercentCourseViewed import ScriptPercentCourseViewed
if __name__ == "__main__":
......@@ -64,7 +75,7 @@ if __name__ == "__main__":
scriptDatabaseManager = ScriptDatabaseManager()
sequenceSession = SequenceSession()
userManagerSession = UserManagerSession()
userManagerProxy = UserManagerProxy(userManagerSession)
userManagerProxySession = UserManagerProxy(userManagerSession)
scriptSequence = ScriptSequence(sequenceSession, frequentSequence, similarity)
sequenceVisualisation = SequenceVisualisation()
scriptUserDurationCurve = ScriptUserDurationCurve()
......@@ -73,10 +84,44 @@ if __name__ == "__main__":
scriptNumberSessionHistogram = ScriptNumberSessionHistogram()
scriptSimpleStatistic = ScriptSimpleStatistic()
scriptFrequentSequenceStatistic = ScriptFrequentSequenceStatistic(frequentSequence)
scriptInterTimeBoxPlot = ScriptInterTimeBoxPlot()
scriptUserMarkdsPerQuizBoxPlot = ScriptUserMarkdsPerQuizBoxPlot()
scriptAccessPerSessionBoxPlot = ScriptAccessPerSessionBoxPlot()
scriptDurationOnEachPartBoxPlot = ScriptDurationOnEachPartBoxPlot()
scriptDurationBeforeEachQuizz = ScriptDurationBeforeEachQuizz()
scriptPercentCourseViewed = ScriptPercentCourseViewed()
scriptSimpleStatistic.generateAllGroup(sequenceSession)
scriptSimpleStatistic.exportLatexSecondTable()
# (idUser, sequence) = sequenceSession.getSequenceUser(Course.COURSE_ID_BOOTSTRAP, 'c05e3a015c60bc29218c81e275ff0d34')
#
# userStatistic.setUserSequence((idUser, sequence))
#
# print("\n\n\nidUser:"+str(idUser))
# print("Marks: "+str(userStatistic.getAllMarks()))
# print("final result: "+str(databaseManager.getResultOfUser(idUser, idCourse)))
# print("number of session: "+str(userStatistic.getNumberOfSessions()))
# print("all exercise of user:"+str(databaseManager.getAllExerciseOfUser(idUser)))
# print("date start: "+str(sequence[0][SequenceInterface.INDEX_STARTDATE]))
#
# print("sequence: "+str(sequence))
#sequenceSession.removeOldUserFromAllCourse()
#scriptUserMarkdsPerQuizBoxPlot.generateAllGroup(sequenceSession)
#scriptNumberSessionHistogram.generateAllGroup(sequenceSession)
#scriptPercentCourseViewed.generateAllGroup(sequenceSession)
#scriptAccessPerSessionBoxPlot.generateAllGroup(sequenceSession)
#scriptDurationOnEachPartBoxPlot.generateAllGroup(sequenceSession)
#scriptInterTimeBoxPlot.generateAllGroup(sequenceSession)
#scriptUserMarkdsPerQuizBoxPlot.generateAllGroup(sequenceSession)
#scriptDurationBeforeEachQuizz.generateAllGroup(sequenceSession)
interTimeBoxPlot = InterTimeBoxPlot(Course.COURSE_ID_ARDUINO, "title")
interTimeBoxPlot.setData(sequenceSession)
interTimeBoxPlot.show()
#scriptInterTimeBoxPlot.generateAllGroup(sequenceSession)
#userManagerProxySession.printStats()
#scriptSequence.launchTest([5], crossValidation=1)
#scriptSequence.launchTest([5], crossValidation=1)
#scriptSequence.launchTest([3,4,5,6,7,8,9,10], crossValidation=10)
......
......@@ -29,31 +29,47 @@ sys.setrecursionlimit(10000)
from dataManager.course import Course
from dataManager.scriptDatabaseManager4 import ScriptDatabaseManager
from dataManager.databaseManagerData4 import DatabaseManager
from sequenceManager.sequenceInterface import SequenceInterface
from sequenceManager.sequenceVisualisation import SequenceVisualisation
from sequenceManager.sequenceSession import SequenceSession
from sequenceManager.scriptSequence import ScriptSequence
from sequenceManager.similarity import Similarity
from sequenceManager.frequentSequence import FrequentSequenceDesktop
from userManager.userManagerSession import UserManagerSession
from userManager.userManagerVisualisation import UserManagerVisualisation
from userManager.userManagerProxy import UserManagerProxy
from statisticManager.plotHistogram import PlotHistogram
from statisticManager.countHistogram import CountHistogram
from statisticManager.durationHistogram import DurationHistogram
from statisticManager.scriptHistogram import ScriptHistogram
from sequenceManager.frequentSequence import FrequentSequenceLaptop
from statisticManager.userDurationCurve import UserDurationCurve
from statisticManager.scriptUserDurationCurve import ScriptUserDurationCurve
from statisticManager.numberSessionHistogram import NumberSessionHistogram
from statisticManager.scriptNumberSessionHistogram import ScriptNumberSessionHistogram
from statisticManager import numberSessionHistogram, scriptNumberSessionHistogram
from statisticManager.scriptSimpleStatistic import ScriptSimpleStatistic
from statisticManager.scriptFrequentSequenceStatistic import ScriptFrequentSequenceStatistic
from statisticManager.scriptMarksCurve import ScriptMarksCurve
from statisticManager.scriptPercentCourseViewed import ScriptPercentCourseViewed
from statisticManager.scriptDurationBeforeEachQuizz import ScriptDurationBeforeEachQuizz
from statisticManager.scriptUserDurationBoxPlot import ScriptUserDurationBoxPlot
from statisticManager.scriptUserDeviationAveragePoint import ScriptUserDeviationAveragePoint
from statisticManager.scriptInterTimeBoxPlot import ScriptInterTimeBoxPlot
from statisticManager.scriptDurationOnEachPartBoxPlot import ScriptDurationOnEachPartBoxPlot
from statisticManager.scriptUserMarksPerQuizBoxPlot import ScriptUserMarkdsPerQuizBoxPlot
from statisticManager.scriptAccessPerSessionBoxPlot import ScriptAccessPerSessionBoxPlot
from statisticManager.scriptDurationBeforeEachQuizz import ScriptDurationBeforeEachQuizz
from statisticManager.scriptTotalDurationHistogram import ScriptTotalDurationHistogram
from statisticManager.scriptNumberOfEventBoxPlot import ScriptNumberOfEventBoxPlot
from statisticManager.scriptNumberOfSessionBoxPlot import ScriptNumberOfSessionBoxPlot
from statisticManager.scriptNumberOfAccessOnEachPartBoxPlot import ScriptNumberOfAccessOnEachPartBoxPlot
from statisticManager.scriptLinearityBoxPlot import LinearityBoxPlot, ScriptLinearityBoxPlot
from statisticManager.scriptTimeSinceLastEventBoxPlot import ScriptTimeSinceLastEventBoxPlot
from statisticManager.scriptEventBeforeEachQuizz import ScriptEventBeforeEachQuizz
from statisticManager.scriptSessionBeforeEachQuizz import ScriptSessionBeforeEachQuizz
from statisticManager.scriptSessionPerDayBeforeEachQuizz import ScriptSessionPerDayBeforeEachQuizz
from statisticManager.scriptFinalMarkBoxPlot import ScriptFinalMarkBoxPlot
if __name__ == "__main__":
......@@ -62,10 +78,11 @@ if __name__ == "__main__":
course = Course(Course.COURSE_ID_BOOTSTRAP)
databaseManager = DatabaseManager()
similarity = Similarity()
frequentSequence = FrequentSequenceLaptop()
frequentSequence = FrequentSequenceDesktop()
scriptDatabaseManager = ScriptDatabaseManager()
sequenceSession = SequenceSession()
userManagerSession = UserManagerSession()
userManagerProxySession = UserManagerProxy(userManagerSession)
userManagerVisualisation = UserManagerVisualisation()
userManagerProxyVisualisation = UserManagerProxy(userManagerVisualisation)
scriptSequence = ScriptSequence(sequenceSession, frequentSequence, similarity)
......@@ -87,12 +104,59 @@ if __name__ == "__main__":
scriptFrequentSequenceStatistic = ScriptFrequentSequenceStatistic(frequentSequence)
scriptPercentCourseViewed = ScriptPercentCourseViewed()
scriptDurationBeforeEachQuizz = ScriptDurationBeforeEachQuizz()
scriptUserDeviationAveragePoint = ScriptUserDeviationAveragePoint()
scriptInterTimeBoxPlot = ScriptInterTimeBoxPlot()
scriptUserMarkdsPerQuizBoxPlot = ScriptUserMarkdsPerQuizBoxPlot()
scriptAccessPerSessionBoxPlot = ScriptAccessPerSessionBoxPlot()
scriptDurationBeforeEachQuizz = ScriptDurationBeforeEachQuizz()
scriptTotalDurationHistogram = ScriptTotalDurationHistogram()
scriptNumberSessionHistogram = ScriptNumberSessionHistogram()
scriptNumberOfEventBoxPlot = ScriptNumberOfEventBoxPlot()
scriptNumberOfSessionBoxPlot = ScriptNumberOfSessionBoxPlot()
scriptNumberOfAccessOnEachPartBoxPlot = ScriptNumberOfAccessOnEachPartBoxPlot()
scriptLinearityBoxPlot = ScriptLinearityBoxPlot()
scriptTimeSinceLastEventBoxPlot = ScriptTimeSinceLastEventBoxPlot()
scriptEventBeforeEachQuizz = ScriptEventBeforeEachQuizz()
scriptSessionBeforeEachQuizz = ScriptSessionBeforeEachQuizz()
scriptSessionPerDayBeforeEachQuizz = ScriptSessionPerDayBeforeEachQuizz()
scriptFinalMarkBoxPlot = ScriptFinalMarkBoxPlot()
#scriptSimpleStatistic.generateAllGroup(sequenceSession)
#scriptSimpleStatistic.exportLatex()
#scriptNumberSessionHistogram.generateAllGroup(sequenceSession)
scriptUserDeviationAveragePoint = ScriptUserDeviationAveragePoint()
scriptUserDeviationAveragePoint.generateAllGroup(sequenceSession)
#scriptNumberOfEventBoxPlot.generateAllGroup(sequenceSession)
#scriptNumberOfSessionBoxPlot.generateAllGroup(sequenceSession)
#scriptDurationBeforeEachQuizz.generateAllGroup(sequenceSession)
#scriptNumberOfAccessOnEachPartBoxPlot.generateAllGroup(sequenceSession)
#scriptLinearityBoxPlot.generateAllGroup(sequenceSession)
#sequenceSession.exportAllCSVFile()
#scriptTimeSinceLastEventBoxPlot.generateAllGroup(sequenceSession)
#scriptEventBeforeEachQuizz.generateAllGroup(sequenceSession)
#scriptSessionBeforeEachQuizz.generateAllGroup(sequenceSession)
#scriptTotalDurationHistogram.generateAllGroup(sequenceSession)
#scriptSessionPerDayBeforeEachQuizz.generateAllGroup(sequenceSession)
scriptFinalMarkBoxPlot.generateAllGroup(sequenceSession)
#scriptUserMarkdsPerQuizBoxPlot.generateAllGroup(sequenceSession)
#scriptDurationBeforeEachQuizz.generateAllGroup(sequenceSession)
#scriptInterTimeBoxPlot.generateAllGroup(sequenceSession)
#scriptDurationBeforeEachQuizz.generateAllGroup(sequenceSession)
# userManagerProxySession.refresh = True
# userManagerProxySession.generateAllUserIds()
# userManagerProxySession.printStats()
# scriptSimpleStatistic.generateAllGroup(sequenceSession)
# scriptSimpleStatistic.exportLatexFirstTable()
# print("\n\n\n")
# scriptSimpleStatistic.exportLatexSecondTable()
# print("\n\n\n")
# scriptSimpleStatistic.exportLatexThirdTable()
#scriptUserDeviationAveragePoint.generateAllGroup(sequenceSession)
# userSequences = sequenceSession.getSequencesAllSucceed(Course.COURSE_ID_ARDUINO)
#
......
......@@ -58,7 +58,7 @@ class SequenceInterface:
INDEX_PART_ID = 0
INDEX_SESSION_NUMBER = 1
INDEX_NUMBER_SEQUENCE = 2
INDEX_SEQUENCE_NUMBER = 2
INDEX_DURATION = 3
INDEX_STARTDATE = 4
INDEX_ENDDATE = 5
......@@ -169,7 +169,7 @@ class SequenceInterface:
'''
get the sequences of the users included in idUsers for a specific course and a score in [minscore, maxScore[
return: a tuple (idCourse, [(idUser, [(idPart, idSession, duration), (), ...,()]) , ...]). Second argument is a list.
@return: a tuple (idCourse, [(idUser, [(idPart, idSession, duration), (), ...,()]) , ...]). Second argument is a list.
'''
allSequences = self.loadSavedSequences(idCourse)
......@@ -247,7 +247,7 @@ class SequenceInterface:
'''
get the sequences of all users for a specific course
@return: a list [(idUser, [(idPart, ..., idSession, duration), (), ...,()]) , ...]
@return: a list (idCourse, [(idUser, [(idPart, ..., idSession, duration), (), ...,()]) , ...])
'''
idUsers = self.userManagerInterface.getAll(idCourse)
......@@ -292,6 +292,21 @@ class SequenceInterface:
return self.getFilteredSequences(idUsers, idCourse)
def getSequenceUser(self, idCourse, idUser):
'''
retrieve the sequence of the user idUser for the course idCourse
@return: (idUser, sequences)
'''
sequences = self.loadSavedSequences(idCourse)
for (idUserSequence, sequence) in sequences:
if(idUserSequence == idUser):
return (idUser, sequence)
return None
def getSequences(self, idCourse, group):
'''
get the sequences of all failed users for a specific course
......@@ -459,6 +474,7 @@ class SequenceInterface:
for (idExo, createdAt, completedAt, scoreExo) in filteredIdExercise:
if completedAt != "null":
'''find the correct location to add the exercice'''
print("completedAt:"+str(completedAt)+" number of exercise:"+str(len(filteredIdExercise)))
dateExerciseCompletedAt = datetime.strptime(completedAt, DatabaseManager.DATE_FORMAT_OUTPUT)
......@@ -567,3 +583,64 @@ class SequenceInterface:
fileName = self.sequenceBaseFileName+str(idCourse)+".p"
pickle.dump(sequencesOutput, open(os.path.join(self.nameDirectorySequences, fileName), "wb"))
def getOldUsers(self, idCourse):
'''
retrieve the old user from all the succeed users for the course idCourse
An old user is a user that succeed without a mark for all the exercise
@return: [idUser, ...]
'''
(idCourse, sequences) = self.getSequences(idCourse, SequenceInterface.GROUP_SUCCEED_ALL_USERS)
course = Course(idCourse)
oldUsers = []
numberOfExercise = course.getNumberofExercise()
idExercises = course.getAllExercisesId()
for (idUser, sequence) in sequences:
numberOfMarks = 0
for idExo in idExercises:
for s in sequence:
if s[SequenceInterface.INDEX_PART_ID] == idExo:
numberOfMarks = numberOfMarks + 1
break
if numberOfMarks < numberOfExercise:
oldUsers.append(idUser)
print("Number of old user for the course "+course.getCourseName(idCourse, summary=True)+":"+str(len(oldUsers)))
return oldUsers
def removeOldUser(self, idCourse):
'''
twitter and bootstrap contains user that work on a different structure than the actual course.
So that some are considered as success user but have no marks for the exercise
this function removes them for the course idCourse and save the new file
'''
oldUsers = self.getOldUsers(idCourse)
(idCourse, sequences) = self.getSequencesAll(idCourse)
newSequences = []
for (idUser, sequence) in sequences:
if idUser not in oldUsers:
newSequences.append((idUser, sequence))
fileName = self.sequenceBaseFileName+str(idCourse)+".p"
pickle.dump(newSequences, open(os.path.join(self.nameDirectorySequences, fileName), "wb"))
def removeOldUserFromAllCourse(self):
for idCourse in Course.ID_COURSES:
self.removeOldUser(idCourse)
\ No newline at end of file
# -*- coding: UTF-8 -*-
'''
Created on 29-Apr-2014
This file is part of Hubble-UserProfile.
Hubble-UserProfile is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubble-UserProfile is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Hubble-UserProfile. If not, see <http://www.gnu.org/licenses/>.
@author: Antoine Pigeau
'''
import numpy as np
import os
import matplotlib.pyplot as plt
from dataManager.course import Course
from sequenceManager.sequenceInterface import SequenceInterface
from userStatistic import UserStatistic
#from nb_conda.handlers import static
class AccessPerSessionBoxPlot:
'''
class to generate on figure on a specific course and a specific group of users.
'''
NAME_DIRECTORY_FIGURES = 'figures'
def __init__(self, idCourse):
'''
@param idCourse: id of the course to generate the data
'''
self.idCourse = idCourse
self.course = Course(self.idCourse)
self.title = self.course.getCourseName(self.idCourse, summary = True)
self.figure= plt.figure()
self.figure.canvas.set_window_title(self.title)
self.figure.suptitle(self.title)
plt.xlabel('groups')
plt.ylabel('number of access')
self.userStatistic = UserStatistic(idCourse)
def computeY(self, sequenceSession):
'''
'''
data = []
for group in SequenceInterface.GROUPS:
(courseId, userSequences) = sequenceSession.getSequences(self.idCourse, group)
dataPart = []
for i, (userId, sequence) in enumerate(userSequences):
self.userStatistic.setUserSequence((userId, sequence))