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

add the duration before each quizz

parent 35429859
...@@ -81,13 +81,12 @@ if __name__ == "__main__": ...@@ -81,13 +81,12 @@ if __name__ == "__main__":
userStatistic.setUserSequence((userId, seq)) userStatistic.setUserSequence((userId, seq))
print("total duration:"+str(userStatistic.computeTotalDuration())) print("total duration:"+str(userStatistic.computeTotalDuration()))
print("computeAverageDurationOnEachPart:"+str(userStatistic.computeAverageDurationOnEachPart(filterType=[Course.CHAPTER]))) print("computeAverageDurationOnEachPart:"+str(userStatistic.computeAverageDurationOnEachPart(filterType=[Course.CHAPTER])))
print("computeAverageDurationOnEachPart:"+str(userStatistic.computeAverageDurationOnEachPart(filterType=[Course.CHAPTER])))
print("AverageIndicatorTimeSession:"+str(userStatistic.computeIndicatorInterTimeSession())) print("AverageIndicatorTimeSession:"+str(userStatistic.computeIndicatorInterTimeSession()))
print("computeNumberAccessPerPartID:"+str(userStatistic.computeNumberAccessPerPartID(filterType=[Course.CHAPTER]))) print("computeNumberAccessPerPartID:"+str(userStatistic.computeNumberAccessPerPartID(filterType=[Course.CHAPTER])))
print("computeNumberOfSessions:"+str(userStatistic.computeNumberOfSessions())) print("computeNumberOfSessions:"+str(userStatistic.computeNumberOfSessions()))
print("All Marks:"+str(userStatistic.getAllMarks())) print("All Marks:"+str(userStatistic.getAllMarks()))
print("percent of course viewed:"+str(userStatistic.computePercentOfCourseViewed(filterTypeP=[Course.CHAPTER]))) print("percent of course viewed:"+str(userStatistic.computePercentOfCourseViewed(filterTypeP=[Course.CHAPTER])))
print("computeDurationBeforeEachAssessment:"+str(userStatistic.computeDurationBeforeEachAssessment()))
else: else:
pass pass
......
...@@ -51,6 +51,7 @@ from statisticManager.scriptSimpleStatistic import ScriptSimpleStatistic ...@@ -51,6 +51,7 @@ from statisticManager.scriptSimpleStatistic import ScriptSimpleStatistic
from statisticManager.scriptFrequentSequenceStatistic import ScriptFrequentSequenceStatistic from statisticManager.scriptFrequentSequenceStatistic import ScriptFrequentSequenceStatistic
from statisticManager.scriptMarksCurve import ScriptMarksCurve from statisticManager.scriptMarksCurve import ScriptMarksCurve
from statisticManager.scriptPercentCourseViewed import ScriptPercentCourseViewed from statisticManager.scriptPercentCourseViewed import ScriptPercentCourseViewed
from statisticManager.scriptDurationBeforeEachQuizz import ScriptDurationBeforeEachQuizz
if __name__ == "__main__": if __name__ == "__main__":
...@@ -70,7 +71,8 @@ if __name__ == "__main__": ...@@ -70,7 +71,8 @@ if __name__ == "__main__":
scriptUserDurationCurve = ScriptUserDurationCurve() scriptUserDurationCurve = ScriptUserDurationCurve()
scriptSimpleStatistic = ScriptSimpleStatistic() scriptSimpleStatistic = ScriptSimpleStatistic()
scriptFrequentSequenceStatistic = ScriptFrequentSequenceStatistic(frequentSequence) scriptFrequentSequenceStatistic = ScriptFrequentSequenceStatistic(frequentSequence)
scriptPercentCourseViewed = ScriptPercentCourseViewed()
scriptDurationBeforeEachQuizz = ScriptDurationBeforeEachQuizz()
# userSequences = sequenceSession.getSequencesAllSucceed(Course.COURSE_ID_ARDUINO) # userSequences = sequenceSession.getSequencesAllSucceed(Course.COURSE_ID_ARDUINO)
# #
# print(str(userSequences[1][9])) # print(str(userSequences[1][9]))
...@@ -87,9 +89,9 @@ if __name__ == "__main__": ...@@ -87,9 +89,9 @@ if __name__ == "__main__":
scriptPercentCourseViewed = ScriptPercentCourseViewed()
#scriptMarksCurve.generateNonPremium(Course.COURSE_ID_ARDUINO, sequenceSession, show = True) #scriptMarksCurve.generateNonPremium(Course.COURSE_ID_ARDUINO, sequenceSession, show = True)
scriptPercentCourseViewed.generateAllGroup(sequenceSession) scriptDurationBeforeEachQuizz.generateAllGroup(sequenceSession)
#scriptSimpleStatistic.generateAllGroup(sequenceSession) #scriptSimpleStatistic.generateAllGroup(sequenceSession)
#scriptSimpleStatistic.exportLatex() #scriptUserDeviationAveragePoint.generateAllGroup(sequenceSession) #scriptSimpleStatistic.exportLatex() #scriptUserDeviationAveragePoint.generateAllGroup(sequenceSession)
......
# -*- 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 DurationBeforeEachQuizz:
'''
class to generate on figure on a specific course and a specific group of users.
'''
NAME_DIRECTORY_FIGURES = 'figures'
def __init__(self, idCourse, title):
'''
@param idCourse: id of the course to generate the data
@param title: title of the figure
'''
self.userStatistic = UserStatistic(idCourse)
self.idCourse = idCourse
self.course = Course(self.idCourse)
self.title = self.course.getCourseName(self.idCourse, summary = True)+" - "+title
self.sequenceCourse = self.course.getSequenceId([Course.EXERCISE])
self.X = range(0, len(self.sequenceCourse))
#self.X = self.sequenceCourse
self.figure = plt.figure()
self.figure.canvas.set_window_title(self.title)
self.figure.suptitle(self.title)
plt.xlabel('index of each quizz id')
plt.ylabel('hours')
def computeY(self, userSequences):
'''
compute the Y values from the userSequences (sum of the duration for each part and for each users)
@param userSequences: all the user sequences from which are computed the duration
@return: a matrix Ys where each line is the durations of one user for each part
'''
Ys = [None] * len(userSequences)
print("size:"+str(len(Ys)))
for i, (userId, sequence) in enumerate(userSequences):
self.userStatistic.setUserSequence((userId, sequence))
Ys[i] = self.userStatistic.computeDurationBeforeEachAssessment()
return Ys
def setData(self, userSequences, color, line='.'):
'''
add a set of userSequences to the figure
@param userSequences: group of sequences to add
@param color: color of the curve
@param line: style of the line
'''
(courseId, userSequences) = userSequences
Ys = self.computeY(userSequences)
self.plot(Ys, color, line)
def plot(self, Ys, colorMark, line):
'''
plot all the curves on the figure
'''
for i in range(0, len(Ys)):
plt.plot(self.X, Ys[i], '-', color= colorMark)
def show(self):
'''
show the current figures
'''
plt.show()
def setLimitYAxe(self, ymin, ymax):
'''
set the y axes of the current figure
'''
axes = self.figure.gca()
axes.set_ylim([ymin,ymax])
def getLimitYaxes(self):
'''
retrieve the boundary of the Y axes
@return: (x, y) where x is the min and y the max
'''
return self.figure.gca().get_ylim()
def saveFigure(self):
'''
save the figure in the directory in jpg format
'''
fileName = os.path.join(DurationBeforeEachQuizz.NAME_DIRECTORY_FIGURES, self.title)
fileName = fileName.replace(" ", "")
print(fileName)
self.figure.savefig(fileName+'.png')
def closeFigure(self):
plt.close(self.figure)
\ No newline at end of file
# -*- coding: UTF-8 -*-
'''
Created on 01-Apr-2016
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: A. Pigeau
'''
from durationBeforeEachQuizz import DurationBeforeEachQuizz
from dataManager.course import Course
from sequenceManager.sequenceInterface import SequenceInterface
class ScriptDurationBeforeEachQuizz:
'''
class to generate the figures on the duration of users on each part of the courses.
Figures are saved in figures directory
'''
def generateAllGroup(self, sequenceSession):
'''
Generate all the figures for the premium group (succeed vs failed) for all courses
'''
for idCourse in Course.ID_COURSES:
self.generatePremium(idCourse, sequenceSession, show = False)
self.generateNonPremium(idCourse, sequenceSession, show = False)
self.generateAll(idCourse, sequenceSession, show= False)
def generatePremium(self, idCourse, sequenceSession, show = True):
userSequencesSucceed = sequenceSession.getSequencesPremiumSucceed(idCourse)
userSequencesFailed = sequenceSession.getSequencesPremiumFailed(idCourse)
self.generateGenericGroup(idCourse, userSequencesSucceed, userSequencesFailed,
SequenceInterface.getGroupName(SequenceInterface.GROUP_PREMIUM), show)
def generateNonPremium(self, idCourse, sequenceSession, show = True):
userSequencesSucceed = sequenceSession.getSequencesNonPremiumSucceed(idCourse)
userSequencesFailed = sequenceSession.getSequencesNonPremiumFailed(idCourse)
self.generateGenericGroup(idCourse, userSequencesSucceed, userSequencesFailed,
SequenceInterface.getGroupName(SequenceInterface.GROUP_NON_PREMIUM), show)
def generateAll(self, idCourse, sequenceSession, show = True):
userSequencesSucceed = sequenceSession.getSequencesAllSucceed(idCourse)
userSequencesFailed = sequenceSession.getSequencesAllFailed(idCourse)
self.generateGenericGroup(idCourse, userSequencesSucceed, userSequencesFailed,
SequenceInterface.getGroupName(SequenceInterface.GROUP_ALL), show)
def generateGenericGroup(self, idCourse, userSequencesSucceed, userSequencesFailed, title, show = True):
statsSucceed = DurationBeforeEachQuizz(idCourse, title+' succeed')
statsSucceed.setData(userSequencesSucceed, 'b')
#userDurationCurveSucceed.show()
statsFailed = DurationBeforeEachQuizz(idCourse, title+' failing')
statsFailed.setData(userSequencesFailed, 'b')
(xS, yS) = statsSucceed.getLimitYaxes()
(xF, yF) = statsFailed.getLimitYaxes()
statsFailed.setLimitYAxe(0, max(yS, yF))
statsSucceed.setLimitYAxe(0, max(yS, yF))
statsFailed.saveFigure()
statsSucceed.saveFigure()
if show:
statsFailed.show()
statsFailed.closeFigure()
statsSucceed.closeFigure()
\ No newline at end of file
...@@ -261,7 +261,7 @@ class UserStatistic: ...@@ -261,7 +261,7 @@ class UserStatistic:
return average return average
def averageDurationBeforeEachAssessment(self): def computeDurationBeforeEachAssessment(self):
''' '''
List of duration of part visualized before each assessment List of duration of part visualized before each assessment
...@@ -269,4 +269,21 @@ class UserStatistic: ...@@ -269,4 +269,21 @@ class UserStatistic:
''' '''
pass
\ No newline at end of file idExercises = self.course.getAllExercisesId()
durations = []
dictDurations = {}
duration = 0.0
for element in self.sequence:
if element[SequenceInterface.INDEX_PART_TYPE] == Course.EXERCISE:
dictDurations[element[SequenceInterface.INDEX_PART_ID]] = duration / UserStatistic.UNITY
duration = 0.0
else:
duration = duration + element[SequenceInterface.INDEX_DURATION]
for idExo in idExercises:
durations.append(round(dictDurations.get(idExo, 0.0), 2))
return durations
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment