Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Jan-Hendrik Willms
Stud.IP
Commits
bf45c573
Commit
bf45c573
authored
5 months ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
rework admission priority retrieval, fixes #4717
Closes #4717 Merge request
studip/studip!3508
parent
31b27040
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/course/enrolment.php
+30
-10
30 additions, 10 deletions
app/controllers/course/enrolment.php
with
30 additions
and
10 deletions
app/controllers/course/enrolment.php
+
30
−
10
View file @
bf45c573
...
...
@@ -285,16 +285,7 @@ class Course_EnrolmentController extends AuthenticatedController
if
(
$admission_user_limit
&&
$admission_user_limit
<=
$limit
->
getMaxNumber
())
{
$limit
->
setCustomMaxNumber
(
$user_id
,
$admission_user_limit
);
}
$admission_prio
=
Request
::
getArray
(
'admission_prio'
);
$max_prio
=
$admission_prio
?
max
(
$admission_prio
)
:
0
;
$admission_prio
=
array_map
(
function
(
$a
)
use
(
&
$max_prio
)
{
return
$a
>
0
?
$a
:
++
$max_prio
;
},
$admission_prio
);
if
(
count
(
array_unique
(
$admission_prio
))
!=
count
(
Request
::
getArray
(
'admission_prio'
)))
{
PageLayout
::
postInfo
(
_
(
'Sie dürfen jede Priorität nur einmal auswählen. Überprüfen Sie bitte Ihre Auswahl!'
)
);
}
$admission_prio
=
$this
->
getPrioritiesFromRequest
();
$old_prio_count
=
AdmissionPriority
::
unsetAllPrioritiesForUser
(
$courseset
->
getId
(),
$user_id
);
if
(
$order_up
=
key
(
Request
::
getArray
(
'admission_prio_order_up'
)))
{
$prio_to_move
=
$admission_prio
[
$order_up
];
...
...
@@ -344,4 +335,33 @@ class Course_EnrolmentController extends AuthenticatedController
}
$this
->
redirect
(
$this
->
action_url
(
"apply/
{
$this
->
course_id
}{
$anchor
}
"
));
}
/**
* Get the priorities from the request. This will discard all defined
* priorities and set them according to their position.
*/
private
function
getPrioritiesFromRequest
():
array
{
$admission_prio
=
Request
::
getArray
(
'admission_prio'
);
if
(
count
(
$admission_prio
)
===
0
)
{
return
[];
}
// Ensure all items have a positive priority that is not zero
$max_prio
=
max
(
$admission_prio
);
foreach
(
$admission_prio
as
$course_id
=>
$prio
)
{
if
(
$prio
<=
0
)
{
$admission_prio
[
$course_id
]
=
++
$max_prio
;
}
}
// Sort the array by the defined priories
asort
(
$admission_prio
);
// Set the priorities according to their position
return
array_combine
(
array_keys
(
$admission_prio
),
range
(
1
,
count
(
$admission_prio
))
);
}
}
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