Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
f8f47e05
Commit
f8f47e05
authored
1 year ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
Fix: formsemestre_table_estim_cost: error handling
parent
959a98d0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/formsemestre.py
+1
-1
1 addition, 1 deletion
app/models/formsemestre.py
app/scodoc/sco_cost_formation.py
+36
-39
36 additions, 39 deletions
app/scodoc/sco_cost_formation.py
with
37 additions
and
40 deletions
app/models/formsemestre.py
+
1
−
1
View file @
f8f47e05
...
@@ -873,7 +873,7 @@ class FormSemestre(db.Model):
...
@@ -873,7 +873,7 @@ class FormSemestre(db.Model):
descr_sem
+=
"
"
+
self
.
modalite
descr_sem
+=
"
"
+
self
.
modalite
return
descr_sem
return
descr_sem
def
get_abs_count
(
self
,
etudid
):
def
get_abs_count
(
self
,
etudid
)
->
tuple
[
int
,
int
,
int
]
:
"""
Les comptes d
'
absences de cet étudiant dans ce semestre:
"""
Les comptes d
'
absences de cet étudiant dans ce semestre:
tuple (nb abs non just, nb abs justifiées, nb abs total)
tuple (nb abs non just, nb abs justifiées, nb abs total)
Utilise un cache.
Utilise un cache.
...
...
This diff is collapsed.
Click to expand it.
app/scodoc/sco_cost_formation.py
+
36
−
39
View file @
f8f47e05
...
@@ -30,17 +30,18 @@
...
@@ -30,17 +30,18 @@
(coût théorique en heures équivalent TD)
(coût théorique en heures équivalent TD)
"""
"""
from
flask
import
request
from
flask
import
request
,
Response
from
app.models
import
FormSemestre
from
app.models
import
FormSemestre
from
app.scodoc.gen_tables
import
GenTable
from
app.scodoc
import
sco_preferences
from
app.scodoc
import
sco_preferences
from
app.scodoc.gen_tables
import
GenTable
from
app.scodoc.sco_exceptions
import
ScoValueError
import
app.scodoc.sco_utils
as
scu
import
app.scodoc.sco_utils
as
scu
import
sco_version
import
sco_version
def
formsemestre_table_estim_cost
(
def
formsemestre_table_estim_cost
(
formsemestre
_id
,
formsemestre
:
FormSemestre
,
n_group_td
=
1
,
n_group_td
=
1
,
n_group_tp
=
1
,
n_group_tp
=
1
,
coef_tp
=
1
,
coef_tp
=
1
,
...
@@ -55,8 +56,6 @@ def formsemestre_table_estim_cost(
...
@@ -55,8 +56,6 @@ def formsemestre_table_estim_cost(
peut conduire à une sur-estimation du coût s
'
il y a des modules optionnels
peut conduire à une sur-estimation du coût s
'
il y a des modules optionnels
(dans ce cas, retoucher le tableau excel exporté).
(dans ce cas, retoucher le tableau excel exporté).
"""
"""
formsemestre
=
FormSemestre
.
get_formsemestre
(
formsemestre_id
)
rows
=
[]
rows
=
[]
for
modimpl
in
formsemestre
.
modimpls
:
for
modimpl
in
formsemestre
.
modimpls
:
rows
.
append
(
rows
.
append
(
...
@@ -76,14 +75,14 @@ def formsemestre_table_estim_cost(
...
@@ -76,14 +75,14 @@ def formsemestre_table_estim_cost(
+
coef_cours
*
row
[
"
heures_cours
"
]
+
coef_cours
*
row
[
"
heures_cours
"
]
+
coef_tp
*
row
[
"
heures_tp
"
]
+
coef_tp
*
row
[
"
heures_tp
"
]
)
)
sum_cours
=
sum
(
[
t
[
"
heures_cours
"
]
for
t
in
rows
]
)
sum_cours
=
sum
(
t
[
"
heures_cours
"
]
for
t
in
rows
)
sum_td
=
sum
(
[
t
[
"
heures_td
"
]
for
t
in
rows
]
)
sum_td
=
sum
(
t
[
"
heures_td
"
]
for
t
in
rows
)
sum_tp
=
sum
(
[
t
[
"
heures_tp
"
]
for
t
in
rows
]
)
sum_tp
=
sum
(
t
[
"
heures_tp
"
]
for
t
in
rows
)
sum_heqtd
=
sum_td
+
coef_cours
*
sum_cours
+
coef_tp
*
sum_tp
sum_heqtd
=
sum_td
+
coef_cours
*
sum_cours
+
coef_tp
*
sum_tp
assert
abs
(
sum
(
[
t
[
"
HeqTD
"
]
for
t
in
rows
]
)
-
sum_heqtd
)
<
0.01
,
"
%s != %s
"
%
(
#
assert abs(sum(t["HeqTD"] for t in rows) - sum_heqtd) < 0.01, "%s != %s" % (
sum
(
[
t
[
"
HeqTD
"
]
for
t
in
rows
]
),
#
sum(t["HeqTD"] for t in rows),
sum_heqtd
,
#
sum_heqtd,
)
#
)
rows
.
append
(
rows
.
append
(
{
{
...
@@ -117,7 +116,7 @@ def formsemestre_table_estim_cost(
...
@@ -117,7 +116,7 @@ def formsemestre_table_estim_cost(
),
),
rows
=
rows
,
rows
=
rows
,
html_sortable
=
True
,
html_sortable
=
True
,
preferences
=
sco_preferences
.
SemPreferences
(
formsemestre
_
id
),
preferences
=
sco_preferences
.
SemPreferences
(
formsemestre
.
id
),
html_class
=
"
table_leftalign table_listegroupe
"
,
html_class
=
"
table_leftalign table_listegroupe
"
,
xls_before_table
=
[
xls_before_table
=
[
[
formsemestre
.
titre_annee
()],
[
formsemestre
.
titre_annee
()],
...
@@ -146,47 +145,45 @@ def formsemestre_table_estim_cost(
...
@@ -146,47 +145,45 @@ def formsemestre_table_estim_cost(
return
tab
return
tab
# view
def
formsemestre_estim_cost
(
def
formsemestre_estim_cost
(
formsemestre_id
,
formsemestre_id
:
int
,
n_group_td
=
1
,
n_group_td
:
int
|
str
=
1
,
n_group_tp
=
1
,
n_group_tp
:
int
|
str
=
1
,
coef_tp
=
1
,
coef_tp
:
float
|
str
=
1.0
,
coef_cours
=
1.5
,
coef_cours
:
float
|
str
=
1.5
,
fmt
=
"
html
"
,
fmt
=
"
html
"
,
):
)
->
str
|
Response
:
"""
Page (formulaire) estimation coûts
"""
"""
Page (formulaire) estimation coûts
"""
try
:
n_group_td
=
int
(
n_group_td
)
n_group_td
=
int
(
n_group_td
)
n_group_tp
=
int
(
n_group_tp
)
n_group_tp
=
int
(
n_group_tp
)
coef_tp
=
float
(
coef_tp
)
coef_tp
=
float
(
coef_tp
)
coef_cours
=
float
(
coef_cours
)
coef_cours
=
float
(
coef_cours
)
except
ValueError
as
exc
:
raise
ScoValueError
(
"
paramètre invalide: utiliser des nombres
"
)
from
exc
formsemestre
=
FormSemestre
.
get_formsemestre
(
formsemestre_id
)
tab
=
formsemestre_table_estim_cost
(
tab
=
formsemestre_table_estim_cost
(
formsemestre
_id
,
formsemestre
,
n_group_td
=
n_group_td
,
n_group_td
=
n_group_td
,
n_group_tp
=
n_group_tp
,
n_group_tp
=
n_group_tp
,
coef_tp
=
coef_tp
,
coef_tp
=
coef_tp
,
coef_cours
=
coef_cours
,
coef_cours
=
coef_cours
,
)
)
h
=
"""
tab
.
html_before_table
=
f
"""
<form name=
"
f
"
method=
"
get
"
action=
"
%s
"
>
<form name=
"
f
"
method=
"
get
"
action=
"
{
request
.
base_url
}
"
>
<input type=
"
hidden
"
name=
"
formsemestre_id
"
value=
"
%s
"
></input>
<input type=
"
hidden
"
name=
"
formsemestre_id
"
value=
"
{
formsemestre
.
id
}
"
></input>
Nombre de groupes de TD: <input type=
"
text
"
name=
"
n_group_td
"
value=
"
%s
"
onchange=
"
document.f.submit()
"
/><br>
Nombre de groupes de TD: <input type=
"
text
"
name=
"
n_group_td
"
value=
"
{
n_group_td
}
"
onchange=
"
document.f.submit()
"
/><br>
Nombre de groupes de TP: <input type=
"
text
"
name=
"
n_group_tp
"
value=
"
%s
"
onchange=
"
document.f.submit()
"
/>
Nombre de groupes de TP: <input type=
"
text
"
name=
"
n_group_tp
"
value=
"
{
n_group_tp
}
"
onchange=
"
document.f.submit()
"
/>
Coefficient heures TP: <input type=
"
text
"
name=
"
coef_tp
"
value=
"
%s
"
onchange=
"
document.f.submit()
"
/>
Coefficient heures TP: <input type=
"
text
"
name=
"
coef_tp
"
value=
"
{
coef_tp
}
"
onchange=
"
document.f.submit()
"
/>
<br>
<br>
</form>
</form>
"""
%
(
"""
request
.
base_url
,
formsemestre_id
,
n_group_td
,
n_group_tp
,
coef_tp
,
)
tab
.
html_before_table
=
h
tab
.
base_url
=
"
%s?formsemestre_id=%s&n_group_td=%s&n_group_tp=%s&coef_tp=%s
"
%
(
tab
.
base_url
=
"
%s?formsemestre_id=%s&n_group_td=%s&n_group_tp=%s&coef_tp=%s
"
%
(
request
.
base_url
,
request
.
base_url
,
formsemestre
_
id
,
formsemestre
.
id
,
n_group_td
,
n_group_td
,
n_group_tp
,
n_group_tp
,
coef_tp
,
coef_tp
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment