Commit f108e6d8 authored by Florent Chehab's avatar Florent Chehab
Browse files

Update architecture, added config file and generating

parent 47219307
......@@ -2,3 +2,4 @@
.ipynb_checkpoints
proj_env
data
__pycache__
\ No newline at end of file
{
"python.pythonPath": "${workspaceFolder}/proj_env/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.flake8Enabled": true
}
\ No newline at end of file
......@@ -33,7 +33,7 @@
"<center>\n",
"<img src=\"https://gitlab.utc.fr/LaTeX-UTC/Graphismes-UTC/raw/56dd9762de926727aa45c8279dcdf54a753335c8/logos/UTC/logo_UTC.png\" alt=\"Logo UTC\" width=\"200px\"/> \n",
"<br>\n",
"<H1>Observatoire des évaluations d'UVs</H1>\n",
"<font size=\"15\">Observatoire des évaluations d'UVs</font>\n",
"</center>"
]
},
......@@ -43,17 +43,21 @@
"metadata": {},
"outputs": [],
"source": [
"import socket\n",
"\n",
"def is_connected():\n",
" hostname = \"www.utc.fr\"\n",
" try:\n",
" host = socket.gethostbyname(hostname)\n",
" s = socket.create_connection((host, 80), 2)\n",
" return True\n",
" except:\n",
" pass\n",
" return False"
"import yaml\n",
"import warnings\n",
"import os.path\n",
"from src.generate_data import generate_data_file\n",
"\n",
"CONFIGURATION = yaml.load(open('./config.yml'))\n",
"ALL_SEMESTERS = {info['sem']:info['end_date'] for info in CONFIGURATION[\"other_semesters\"]}\n",
"ALL_SEMESTERS[CONFIGURATION[\"main_semester\"]['sem']] = CONFIGURATION[\"main_semester\"]['end_date']\n",
"\n",
"for semester in ALL_SEMESTERS.keys():\n",
" if not os.path.isfile('./data/' + semester + '.json'):\n",
" warnings.warn(\"Il manque des fichiers de données des évaluations d'UVs pour le semestre \"\n",
" + semester \n",
" + \". Nous allons en générer pour pouvoir continer.\")\n",
" generate_data_file(semester)"
]
},
{
......@@ -65,6 +69,7 @@
"# For auto completion inside jupyter notebook\n",
"%config IPCompleter.greedy=True\n",
"\n",
"from src.tools import is_connected # simple function to check if we have an internet connectection\n",
"import json\n",
"from collections import OrderedDict\n",
"from datetime import datetime\n",
......@@ -90,7 +95,7 @@
"\n",
"\n",
"# import data\n",
"data_json = json.load(open('../data/A2017.json'))\n",
"data_json = json.load(open('./data/A2017.json'))\n",
"DATE = data_json[\"date\"]\n",
"semester = data_json[\"semester\"]\n",
"data_dict = OrderedDict(data_json[\"data\"])\n",
......@@ -108,9 +113,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Généralités\n",
"# Généralités\n",
"\n",
"### Présentation des données"
"## Présentation des données"
]
},
{
......@@ -411,9 +416,16 @@
"# Tweak css for displaying data \n",
"\n",
"from IPython.core.display import HTML\n",
"style = open('./style.css').read()\n",
"style = open('./src/style.css').read()\n",
"HTML(\"<style>\"+style+\"</style>\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
main_semester:
sem: A2017
end_date: 13/01/2018
other_semesters:
- sem: P2017
end_date: 30/06/2017
\ No newline at end of file
import datetime
from datetime import date
import string
import random
import json
import os.path
def generate_data_file(semester):
"""
Function for generating a random data file to
be used in analysis
"""
TODAY = datetime.datetime.today().strftime('%d/%m/%Y')
output = {
'date': TODAY,
'semester': semester,
'data': {}
}
def random_eval(nb_evals):
stats = {}
for i in range(1, 10):
pp = random.randint(0, nb_evals)
p = random.randint(0, nb_evals - pp)
m = random.randint(0, nb_evals - pp - p)
mm = nb_evals - pp - p - m
stats[str(i)] = {
'++': pp,
'+': p,
'-': m,
'--': mm
}
return stats
def random_date():
start_date = date.today().toordinal() - 60
end_date = date.today().toordinal()
random_day = date.fromordinal(random.randint(start_date, end_date))
return random_day.strftime('%d/%m/%Y')
NB_UVS = 200
for uv in range(1, NB_UVS):
uv_code = 'UV' + str(uv)
nb_etu_registered = random.randint(10, 100)
nb_etu_abs = random.randint(1, 9)
nb_etu_passed = random.randint(1, nb_etu_registered - nb_etu_abs)
nb_evals = random.randint(1, nb_etu_registered - nb_etu_abs)
date_review = random.choice([None, random_date()])
comment = None
if date_review:
comment = random.randint(0, 500)
output['data'][uv_code] = {
'name': ''.join(random.choices(string.ascii_uppercase, k=40)),
'nb_etu_registered': nb_etu_registered,
'nb_etu_abs': nb_etu_abs,
'nb_etu_passed': nb_etu_passed,
'nb_evals': nb_evals,
'stats': random_eval(nb_evals),
'date_review': date_review,
'comment': comment
}
fp = os.path.realpath(__file__) + '/../../data/' + semester + '.json'
with open(os.path.abspath(fp), 'w') as outfile:
json.dump(output, outfile)
import socket
def is_connected():
hostname = "www.utc.fr"
try:
host = socket.gethostbyname(hostname)
socket.create_connection((host, 80), 2)
except: # noqa: E722
pass
return False
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