Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iena-course-format
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iena
iena-course-format
Commits
f5f12d8c
Commit
f5f12d8c
authored
5 months ago
by
DELARUELLE Myriam
Browse files
Options
Downloads
Patches
Plain Diff
fix cache + search
parent
a1abd9a9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
amd/build/suivi.js
+49
-28
49 additions, 28 deletions
amd/build/suivi.js
suivi_unit.php
+19
-16
19 additions, 16 deletions
suivi_unit.php
with
68 additions
and
44 deletions
amd/build/suivi.js
+
49
−
28
View file @
f5f12d8c
...
...
@@ -129,27 +129,47 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}
function
fetchProgress
(){
completeUrl
=
getCompleteUrl
();
data
=
{
action
:
'
fetchprogress
'
};
if
(
localStorage
.
groups
&&
JSON
.
parse
(
localStorage
.
groups
).
length
>
0
){
var
cachedgroupsid
=
JSON
.
parse
(
localStorage
.
groups
);
var
groupsid
=
[];
for
(
var
i
=
0
;
i
<
cachedgroupsid
.
length
;
i
++
)
{
groupsid
.
push
(
cachedgroupsid
[
i
]);
}
if
(
groupsid
.
length
==
0
){
groupsid
.
push
(
-
2
);
}
data
.
groupsid
=
groupsid
;
}
$
.
ajax
({
url
:
completeUrl
,
data
:
{
action
:
'
fetchprogress
'
}
,
data
:
data
,
type
:
'
post
'
,
success
:
function
(
request
)
{
data
=
calcPercentage
(
JSON
.
parse
(
request
));
if
(
data
.
students
.
length
<
1000
){
localStorage
.
setItem
(
"
groups
"
,
request
);
parsedrequest
=
JSON
.
parse
(
request
);
data
=
calcPercentage
(
parsedrequest
);
if
(
data
.
students
.
length
<
1000
&&
!
localStorage
.
groups
){
localStorage
.
setItem
(
"
groups
"
,
parsedrequest
[
"
groups
"
]);
}
initActivityFilter
(
false
);
updateActivitiesFilterLabel
(
false
);
initGroupFilter
(
false
);
updateGroupsFilterLabel
(
false
);
showHideActivities
(
false
);
updateActivitiesFilterLabel
(
false
);
changeSection
(
false
);
initGroupFilter
(
false
);
updateGroupsFilterLabel
(
false
);
reloadTable
(
data
);
changeSection
(
false
);
reloadTable
(
data
);
return
data
;
}
});
...
...
@@ -205,12 +225,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
success
:
function
(
request
)
{
showHideActivities
();
parsedrequest
=
JSON
.
parse
(
request
);
data
=
calcPercentage
(
parsedrequest
);
data
=
calcPercentage
(
JSON
.
parse
(
request
));
showHideStudents
();
if
(
data
.
students
.
length
<
1000
){
localStorage
.
setItem
(
"
groups
"
,
JSON
.
stringify
(
parsedrequest
[
"
groups
"
]));
localStorage
.
setItem
(
"
groups
"
,
request
);
}
reloadTable
(
data
);
updateGroupsFilterLabel
(
false
);
...
...
@@ -715,12 +736,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}
updateGroupsFilterLabel
();
});
if
(
localStorage
.
groups
){
var
checkedGroups
=
JSON
.
parse
(
localStorage
.
groups
);
if
(
localStorage
.
groups
&&
JSON
.
parse
(
localStorage
.
groups
)
!=
0
){
var
checkedGroups
=
JSON
.
parse
(
localStorage
.
groups
);
//var checkedGroups=JSON.parse(localStorage.groups);
var
groups
=
$
(
"
input[type='checkbox'].justone-group
"
);
if
(
$
(
"
input[type='checkbox'].justone-group[value=
"
+
checkedGroups
[
0
]
+
"
]
"
).
length
>
0
){
if
(
groups
.
length
===
checkedGroups
.
length
){
//if($("input[type='checkbox'].justone-group[value="+checkedGroups[0]+"]").length > 0){
if
(
groups
.
length
===
checkedGroups
.
length
&&
checkedGroups
[
0
]
!=
0
){
$
(
"
.selectallgroups
"
).
prop
(
"
checked
"
,
true
);
$
(
"
input[type='checkbox'].justone-group
"
).
prop
(
"
checked
"
,
true
);
}
...
...
@@ -735,7 +757,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
}
}
}
}
//
}
}
else
{
if
(
data
.
countstudents
<
1000
){
...
...
@@ -788,7 +810,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
$
.
when
(
message
).
done
(
function
(
localizedEditString
)
{
$
(
"
#partial-table
"
).
html
(
"
<div class='alert alert-primary' role='alert'>
"
+
localizedEditString
+
loader
+
"
</div>
"
);
console
.
log
(
$
(
"
#partial-table
"
));
});
}
...
...
@@ -836,6 +857,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
form
.
submit
();
}
else
if
(
value
==
"
download
"
){
e
.
stopPropagation
();
e
.
preventDefault
();
table_download
(
data
);
}
}
...
...
@@ -846,7 +869,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
.
replace
(
/
\s
+/g
,
'
-
'
)
/* Replace spaces with - */
.
replace
(
/&/g
,
'
-and-
'
)
/* Replace & with 'and' */
.
replace
(
/
[^\w\-]
+/g
,
''
)
/* Remove all non-word chars */
.
replace
(
/
\-\-
+/g
,
'
-
'
);
/* Replace multiple - with single - */
.
replace
(
/
\-\-
+/g
,
'
-
'
)
/* Replace multiple - with single - */
}
...
...
@@ -869,9 +893,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
continue
;
}
head
.
push
(
'
"
'
+
data
.
modules
[
m
].
displayname
.
replace
(
'
,
'
,
''
)
+
'
"
'
);
}
}
csvContent
+=
head
.
join
(
"
,
"
);
csvContent
+=
"
\n
"
;
...
...
@@ -942,9 +965,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'],
csvContent
+=
dataString
+
"
\n
"
;
}
}
var
encodedUri
=
encodeURI
(
csvContent
);
var
section_name
=
data
.
active_section_id
;
if
(
section_name
==
0
)
{
section_name
=
"
cours-complet
"
;
...
...
This diff is collapsed.
Click to expand it.
suivi_unit.php
+
19
−
16
View file @
f5f12d8c
...
...
@@ -266,11 +266,11 @@ function get_progress_students($modules, $progress, $groups, $activegroupsids, $
$arrayprogress
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$activegroupsids
);
$i
++
){
if
(
$cache
->
get
(
$courseid
.
"-"
.
$activegroupsids
[
$i
])
!==
false
){
error_log
(
"on est passé dans le cache"
);
$progress
=
$cache
->
get
(
$courseid
.
"-"
.
$activegroupsids
[
$i
]);
}
else
{
error_log
(
"pas dans le cache"
);
//On récupère le progrès des étudiants qui font partie des groupes activegroupsids
$progressrequest
=
$completion
->
get_progress_all
(
''
,
...
...
@@ -283,6 +283,7 @@ function get_progress_students($modules, $progress, $groups, $activegroupsids, $
);
//On active le cache seulement s'il y a plus de x étudiants
if
(
$countstudents
<
1000
){
error_log
(
"on set le cache"
);
$cache
->
set
(
$courseid
.
"-"
.
$activegroupsids
[
$i
],
$progressrequest
);
}
$progress
=
$progressrequest
;
...
...
@@ -300,9 +301,10 @@ function get_progress_student($identifier, $completion, $modules){
global
$COURSE
;
$countmethod
=
0
;
$users
=
array
();
$start
=
microtime
(
true
);
//Essayer de faire des switch case avec counttries
$arrayparams
=
array
();
$explodedname
=
explode
(
" "
,
$identifier
);
$sql
=
"SELECT DISTINCT u.id, u.firstname, u.lastname, u.email, u.idnumber
FROM
{
user
}
u
...
...
@@ -317,27 +319,26 @@ function get_progress_student($identifier, $completion, $modules){
if
(
count
(
$explodedname
)
>
1
){
$sql
.
=
" AND (u.lastname LIKE ? AND u.firstname LIKE
'?'
) OR (u.lastname LIKE
'?'
AND u.firstname LIKE
'?'
)"
;
$sql
.
=
" AND (u.lastname LIKE ? AND u.firstname LIKE
?
) OR (u.lastname LIKE
?
AND u.firstname LIKE
?
)"
;
array_push
(
$arrayparams
,
$
identifier
[
0
],
$identifier
[
1
],
$identifier
[
1
],
$identifier
[
0
]);
array_push
(
$arrayparams
,
$
explodedname
[
0
],
$explodedname
[
1
],
$explodedname
[
1
],
$explodedname
[
0
]);
}
else
{
$sql
.
=
" AND u.lastname LIKE ? OR u.idnumber = ?"
;
array_push
(
$arrayparams
,
"
%
"
.
$identifier
.
"%"
,
$identifier
);
array_push
(
$arrayparams
,
""
.
$identifier
.
"%"
,
$identifier
);
}
$users
=
array_values
(
$DB
->
get_records_sql
(
$sql
,
$arrayparams
));
error_log
(
"Après le sql"
);
error_log
(
$time_elapsed_secs
=
microtime
(
true
)
-
$start
);
$users
=
array_values
(
$DB
->
get_records_sql
(
$sql
,
$arrayparams
));
if
(
count
(
$users
)
>
0
){
$completion_student
=
array
();
$where
=
array
();
$where_params
=
array
();
//regarder get_in_or_equal
error_log
(
"flag2"
);
for
(
$i
=
0
;
$i
<
count
(
$users
);
$i
++
){
// foreach($users as $user){
...
...
@@ -356,12 +357,12 @@ function get_progress_student($identifier, $completion, $modules){
}
$arrayprogress
=
(
object
)
array_unique
(
array_merge
((
array
)
$arrayprogress
,
(
array
)
$completion_student
),
SORT_REGULAR
);
}
error_log
(
"avant le format progress"
);
error_log
(
$time_elapsed_secs
=
microtime
(
true
)
-
$start
);
error_log
(
"flag3"
);
return
format_progress
(
$arrayprogress
,
$modules
,
false
,
true
);
}
else
{
error_log
(
"Pas trouvé ?"
);
//On a pas trouvé d'utilisateur
return
array
(
"error"
=>
"Pas d'utilisateurs trouvés"
);
}
...
...
@@ -540,22 +541,24 @@ else if(isset($_POST['action']) && $_POST['action'] == 'search_student' && isset
$data
=
[];
$sanitized
=
filter_var
(
$_POST
[
'search_input'
],
FILTER_SANITIZE_STRING
);
error_log
(
$sanitized
);
$modules
=
get_activities
(
$completion
,
$activesectionid
);
$data
[
"modules"
]
=
$modules
;
$data
[
"students"
]
=
get_progress_student
(
$sanitized
,
$completion
,
$modules
);
$data
=
set_links
(
$data
,
$modules
,
$listoptions
);
//
$data = set_links($data, $modules, $listoptions);
echo
json_encode
(
$data
);
}
// If a post is sent trought the page --> Si on change les filtres (de groupes), le template est appelé en JS
else
if
(
isset
(
$_POST
[
'action'
])
&&
!
empty
(
$_POST
[
'action'
]))
{
error_log
(
"on passe dans l'action "
);
$groups
=
groups_get_all_groups
(
$COURSE
->
id
,
0
,
0
,
'g.*'
,
true
);
$data
=
[];
$modules
=
get_activities
(
$completion
,
$activesectionid
);
$data
[
"students"
]
=
get_progress_students
(
$modules
,
$arrayprogress
,
$groups
,
$activegroupsids
,
$activesectionid
,
$courseid
,
$cache
,
$completion
);
$data
[
"modules"
]
=
$modules
;
$data
[
"countstudents"
]
=
count
(
$data
[
"students"
]);
$data
=
set_links
(
$data
,
$modules
,
$listoptions
);
$data
[
"groups"
]
=
$activegroupsids
;
//$data = set_links($data, $modules, $listoptions);
echo
json_encode
(
$data
);
}
...
...
@@ -563,7 +566,6 @@ else if (isset($_POST['action']) && !empty($_POST['action'])) {
else
{
init_page
(
$course
,
$PAGE
);
echo
$OUTPUT
->
header
();
error_log
(
"je load juste la page"
);
//$progress=$cache->get($activegroupids);
$groups
=
groups_get_all_groups
(
$COURSE
->
id
,
0
,
0
,
'g.*'
,
true
);
$data
=
[];
...
...
@@ -589,8 +591,9 @@ else {
//$groups = $groupsall->groups;
$sections
=
get_sections
(
$activesectionid
);
//$data["countstudents"]=$countstudents;
$data
=
set_links
(
$data
,
$modules
,
$listoptions
);
$data
=
set_filters
(
$data
,
$filters
,
$symbols
,
$sections
,
$groupsall
->
current_user_groups
,
$groupsall
->
othergroups
,
$activesectionid
);
$data
[
"groups"
]
=
$activegroupsids
;
if
(
isset
(
$_GET
[
"msg_success"
]))
{
$msg
=
$_GET
[
"msg_success"
];
$data
[
"msg_success"
]
=
$msg
;
...
...
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