mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
pedagogy: uv autofill finishing touches
This commit is contained in:
parent
1c0d15ba2a
commit
5cc7eff94f
@ -35,8 +35,8 @@ def find_uv(lang, year, code):
|
||||
full_uv is the detailed representation of an UV.
|
||||
"""
|
||||
# query the UV list
|
||||
uvs_url = settings.SITH_PEDAGOGY_UTBM_API_UVS_URL
|
||||
response = urllib.request.urlopen(uvs_url.format(lang=lang, year=year))
|
||||
uvs_url = settings.SITH_PEDAGOGY_UTBM_API + "/uvs/{}/{}".format(lang, year)
|
||||
response = urllib.request.urlopen(uvs_url)
|
||||
uvs = json.loads(response.read().decode("utf-8"))
|
||||
|
||||
try:
|
||||
@ -46,11 +46,10 @@ def find_uv(lang, year, code):
|
||||
return (None, None)
|
||||
|
||||
# get detailed information about the UV
|
||||
response = urllib.request.urlopen(
|
||||
settings.SITH_PEDAGOGY_UTBM_API_UV_URL.format(
|
||||
lang=lang, year=year, code=code, formation=short_uv["codeFormation"]
|
||||
)
|
||||
uv_url = settings.SITH_PEDAGOGY_UTBM_API + "/uv/{}/{}/{}/{}".format(
|
||||
lang, year, code, short_uv["codeFormation"]
|
||||
)
|
||||
response = urllib.request.urlopen(uv_url)
|
||||
full_uv = json.loads(response.read().decode("utf-8"))
|
||||
|
||||
return (short_uv, full_uv)
|
||||
@ -112,9 +111,17 @@ def make_clean_uv(short_uv, full_uv):
|
||||
|
||||
res["title"] = full_uv["libelle"]
|
||||
|
||||
res["objectives"] = full_uv["objectifs"]
|
||||
res["program"] = full_uv["programme"]
|
||||
res["skills"] = full_uv["acquisitionCompetences"]
|
||||
res["key_concepts"] = full_uv["acquisitionNotions"]
|
||||
descriptions = {
|
||||
"objectives": "objectifs",
|
||||
"program": "programme",
|
||||
"skills": "acquisitionCompetences",
|
||||
"key_concepts": "acquisitionNotions",
|
||||
}
|
||||
|
||||
for res_key, full_uv_key in descriptions.items():
|
||||
res[res_key] = full_uv[full_uv_key]
|
||||
# if not found or the API did not return a string
|
||||
if type(res[res_key]) != str:
|
||||
res[res_key] = ""
|
||||
|
||||
return res
|
||||
|
@ -47,6 +47,13 @@ function createQuickNotif(msg) {
|
||||
document.getElementById('quick_notif').appendChild(el)
|
||||
}
|
||||
|
||||
function deleteQuickNotifs() {
|
||||
const el = document.getElementById('quick_notif')
|
||||
while (el.firstChild) {
|
||||
el.removeChild(el.firstChild)
|
||||
}
|
||||
}
|
||||
|
||||
function display_notif() {
|
||||
$('#header_notif').toggle().parent().toggleClass("white");
|
||||
}
|
||||
|
@ -52,6 +52,7 @@
|
||||
year--
|
||||
}
|
||||
const url = "{{ url('api:uv_endpoint') }}?year=" + year + "&code=" + codeInput.value
|
||||
deleteQuickNotifs()
|
||||
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
|
@ -445,10 +445,7 @@ SITH_PEDAGOGY_UV_RESULT_GRADE = [
|
||||
("ABS", _("Abs")),
|
||||
]
|
||||
|
||||
base_url = "https://extranet1.utbm.fr/gpedago/api/guide"
|
||||
SITH_PEDAGOGY_UTBM_API_UVS_URL = base_url + "/uvs/{lang}/{year}"
|
||||
SITH_PEDAGOGY_UTBM_API_UV_URL = base_url + "/uv/{lang}/{year}/{code}/{formation}"
|
||||
del base_url
|
||||
SITH_PEDAGOGY_UTBM_API = "https://extranet1.utbm.fr/gpedago/api/guide"
|
||||
|
||||
SITH_ECOCUP_CONS = 1152
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user