Commit 91511e65 authored by Antoine PIGEAU's avatar Antoine PIGEAU
Browse files

bug correction + feature # attempt on exercises

parent a5281b82
......@@ -54,7 +54,7 @@ class EventBeforeEachQuizz:
self.figure = plt.figure()
self.figure.canvas.set_window_title(self.title)
self.figure.suptitle(self.title)
plt.xlabel('Quizz id')
plt.xlabel('Quiz id')
plt.ylabel('# of events')
......@@ -75,8 +75,8 @@ class EventBeforeEachQuizz:
numberOfEvents = self.userStatistic.getNumberOfEventBeforeEachAssessment()
for i, duration in enumerate(numberOfEvents):
totalNumberOfEvents[i].append(numberOfEvents)
for i, event in enumerate(numberOfEvents):
totalNumberOfEvents[i].append(event)
return totalNumberOfEvents
......
# -*- 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 NumberOfAttemptQuiz:
'''
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('Quiz id')
plt.ylabel('# of access')
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
'''
numberOfPart = len(self.sequenceCourse)
totalNumberOfEvents = [[] for i in range(0, numberOfPart)]
for i, (userId, sequence) in enumerate(userSequences):
self.userStatistic.setUserSequence((userId, sequence))
numberOfEvents = self.userStatistic.getNumberAccessPerPartID(filterType=[Course.EXERCISE])
for i, attempt in enumerate(numberOfEvents):
totalNumberOfEvents[i].append(attempt)
return totalNumberOfEvents
def setData(self, userSequences):
'''
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
data = self.computeY(userSequences)
self.plot(data)
def plot(self, data):
'''
plot all the curves on the figure
'''
plt.boxplot(data)
plt.xticks( range(1,len(self.sequenceCourse)+1), self.sequenceCourse, rotation=20, fontsize=8 )
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(NumberOfAttemptQuiz.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 numberOfAttemptQuiz import NumberOfAttemptQuiz
from dataManager.course import Course
from sequenceManager.sequenceInterface import SequenceInterface
class ScriptNumberOfAttemptQuizz:
'''
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:
for group in SequenceInterface.GROUPS:
plot = NumberOfAttemptQuiz(idCourse, SequenceInterface.getGroupName(group))
plot.setData(sequenceSession.getSequences(idCourse, group))
plot.saveFigure()
\ No newline at end of file
......@@ -75,8 +75,8 @@ class SessionBeforeEachQuizz:
numberOfSessions = self.userStatistic.getNumberOfSessionBeforeEachAssessment()
for i, duration in enumerate(numberOfSessions):
totalNumberOfSessions[i].append(numberOfSessions)
for i, session in enumerate(numberOfSessions):
totalNumberOfSessions[i].append(session)
return totalNumberOfSessions
......
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