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
Terraform modules
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
Jakob Diel
Stud.IP
Commits
f7b14b87
Commit
f7b14b87
authored
2 years ago
by
Moritz Strohm
Browse files
Options
Downloads
Patches
Plain Diff
fix for BIESt 1813, closes
#1813
Closes
#1813
Merge request
!1365
parent
b8ccb22d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/course/timesrooms.php
+55
-20
55 additions, 20 deletions
app/controllers/course/timesrooms.php
app/views/course/timesrooms/editStack.php
+18
-8
18 additions, 8 deletions
app/views/course/timesrooms/editStack.php
with
73 additions
and
28 deletions
app/controllers/course/timesrooms.php
+
55
−
20
View file @
f7b14b87
...
@@ -680,30 +680,65 @@ class Course_TimesroomsController extends AuthenticatedController
...
@@ -680,30 +680,65 @@ class Course_TimesroomsController extends AuthenticatedController
*/
*/
$this
->
date
=
CourseDate
::
findOneByMetadate_id
(
$cycle_id
);
$this
->
date
=
CourseDate
::
findOneByMetadate_id
(
$cycle_id
);
$this
->
checked_dates
=
$_SESSION
[
'_checked_dates'
];
$this
->
checked_dates
=
$_SESSION
[
'_checked_dates'
];
$this
->
preparation_time
=
'0'
;
//Check if the preparation time is the same for all dates.
$this
->
selected_lecturer_ids
=
$this
->
getSameFieldValue
(
$checked_course_dates
,
function
(
CourseDate
$date
)
{
//In that case, use the common value as preparation time.
return
$date
->
dozenten
->
pluck
(
'user_id'
);
$i
=
0
;
});
$ptime
=
0
;
$this
->
selected_room_id
=
$this
->
getSameFieldValue
(
$checked_course_dates
,
function
(
CourseDate
$date
)
{
foreach
(
$checked_course_dates
as
$course_date
)
{
return
$date
->
room_booking
->
resource_id
??
''
;
$current_ptime
=
$course_date
->
room_booking
->
preparation_time
;
});
if
(
$i
==
0
)
{
$this
->
selected_room_name
=
$this
->
getSameFieldValue
(
$checked_course_dates
,
function
(
CourseDate
$date
)
{
$ptime
=
$current_ptime
;
return
$date
->
raum
??
''
;
}
else
{
});
if
(
$current_ptime
!=
$ptime
)
{
$ptime
=
-
1
;
$preparation_time
=
$this
->
getSameFieldValue
(
$checked_course_dates
,
function
(
CourseDate
$date
)
{
break
;
return
$date
->
room_booking
->
preparation_time
??
0
;
}
});
}
$this
->
preparation_time
=
floor
(
$preparation_time
/
60
);
$i
++
;
}
if
(
$ptime
>
-
1
)
{
$this
->
preparation_time
=
$ptime
/
60
;
}
$this
->
max_preparation_time
=
Config
::
get
()
->
RESOURCES_MAX_PREPARATION_TIME
;
$this
->
max_preparation_time
=
Config
::
get
()
->
RESOURCES_MAX_PREPARATION_TIME
;
$this
->
render_template
(
'course/timesrooms/editStack'
);
$this
->
render_template
(
'course/timesrooms/editStack'
);
}
}
/**
* Checks a specific field value of the specified course dates for equality.
* A closure defines which field of the course dates to check.
*
* @param CourseDate[] $dates The dates from which to extract values.
* @param Closure $callback The closure that extracts values from a CourseDate object that is passed to it.
* @return mixed The identical value that has been retrieved from all course dates or a value that is equal to
* false in case the value differs. The returned result might be a string or an array or it may be empty.
*/
protected
function
getSameFieldValue
(
array
$dates
,
Closure
$callback
)
{
$data
=
array_map
(
$callback
,
$dates
);
$initial
=
null
;
foreach
(
$data
as
$item
)
{
if
(
$initial
===
null
)
{
$initial
=
$item
;
continue
;
}
// Compare array by checking their sizes and different items
if
(
is_array
(
$initial
)
&&
(
count
(
$initial
)
!==
count
(
$item
)
||
count
(
array_diff
(
$initial
,
$item
))
>
0
)
)
{
return
[];
}
// Otherwise compare items themselves
if
(
!
is_array
(
$initial
)
&&
$initial
!=
$item
)
{
return
''
;
}
}
return
$initial
;
}
/**
/**
* Creates a new room request for the selected dates.
* Creates a new room request for the selected dates.
...
...
This diff is collapsed.
Click to expand it.
app/views/course/timesrooms/editStack.php
+
18
−
8
View file @
f7b14b87
...
@@ -5,13 +5,13 @@
...
@@ -5,13 +5,13 @@
* @var array $linkAttributes
* @var array $linkAttributes
* @var array $checked_dates
* @var array $checked_dates
* @var array $selectable_rooms
* @var array $selectable_rooms
* @var array $tpl
* @var QuickSearch $room_search
* @var QuickSearch $room_search
* @var array $only_bookable_rooms
* @var array $only_bookable_rooms
* @var array $teachers
* @var array $teachers
* @var array $gruppen
* @var array $gruppen
* @var int $preparation_time
* @var int $preparation_time
* @var int $max_preparation_time
* @var int $max_preparation_time
* @var string[] $selected_lecturer_ids
*/
*/
?>
?>
<form
method=
"post"
action=
"
<?=
$controller
->
url_for
(
'course/timesrooms/saveStack/'
.
$cycle_id
,
$linkAttributes
)
?>
"
<form
method=
"post"
action=
"
<?=
$controller
->
url_for
(
'course/timesrooms/saveStack/'
.
$cycle_id
,
$linkAttributes
)
?>
"
...
@@ -46,7 +46,8 @@
...
@@ -46,7 +46,8 @@
<select
name=
"room_id"
onFocus=
"jQuery('input[type=radio][name=action][value=room]').prop('checked', 'checked')"
>
<select
name=
"room_id"
onFocus=
"jQuery('input[type=radio][name=action][value=room]').prop('checked', 'checked')"
>
<option
value=
"0"
>
<?=
_
(
'Auswählen'
)
?>
</option>
<option
value=
"0"
>
<?=
_
(
'Auswählen'
)
?>
</option>
<?
foreach
(
$selectable_rooms
as
$room
)
:
?>
<?
foreach
(
$selectable_rooms
as
$room
)
:
?>
<option
value=
"
<?=
htmlReady
(
$room
->
id
)
?>
"
>
<option
value=
"
<?=
htmlReady
(
$room
->
id
)
?>
"
<?=
$room
->
id
===
$selected_room_id
?
'selected'
:
''
?>
>
<?=
htmlReady
(
$room
->
name
)
?>
<?=
htmlReady
(
$room
->
name
)
?>
</option>
</option>
<?
endforeach
?>
<?
endforeach
?>
...
@@ -75,7 +76,7 @@
...
@@ -75,7 +76,7 @@
<?=
$placerholder
?>
<?=
$placerholder
?>
</label>
</label>
<label>
<label>
<input
type=
"text"
name=
"freeRoomText"
value=
"
<?=
htmlReady
(
$
tpl
[
'freeRoomText'
]
)
?>
"
<input
type=
"text"
name=
"freeRoomText"
value=
"
<?=
htmlReady
(
$
selected_room_name
)
?>
"
placeholder=
"
<?=
$placerholder
?>
"
placeholder=
"
<?=
$placerholder
?>
"
onFocus=
"jQuery('input[type=radio][name=action][value=freetext]').prop('checked', 'checked')"
>
onFocus=
"jQuery('input[type=radio][name=action][value=freetext]').prop('checked', 'checked')"
>
</label>
</label>
...
@@ -108,6 +109,15 @@
...
@@ -108,6 +109,15 @@
<fieldset
class=
"collapsed"
>
<fieldset
class=
"collapsed"
>
<legend>
<?=
_
(
'Durchführende Lehrende'
)
?>
</legend>
<legend>
<?=
_
(
'Durchführende Lehrende'
)
?>
</legend>
<?
if
(
$selected_lecturer_ids
)
:
?>
<ul>
<?
foreach
(
$teachers
as
$teacher
)
:
?>
<?
if
(
in_array
(
$teacher
[
'user_id'
],
$selected_lecturer_ids
))
:
?>
<li>
<?=
htmlReady
(
$teacher
[
'fullname'
])
?>
</li>
<?
endif
?>
<?
endforeach
?>
</ul>
<?
endif
?>
<label>
<label>
<?=
_
(
'Aktion auswählen'
)
?>
<?=
_
(
'Aktion auswählen'
)
?>
<select
name=
"related_persons_action"
id=
"related_persons_action"
>
<select
name=
"related_persons_action"
id=
"related_persons_action"
>
...
@@ -121,11 +131,11 @@
...
@@ -121,11 +131,11 @@
<label>
<label>
<?=
_
(
'Lehrende'
)
?>
<?=
_
(
'Lehrende'
)
?>
<select
name=
"related_persons[]"
id=
"related_persons"
multiple
>
<select
name=
"related_persons[]"
id=
"related_persons"
multiple
>
<?
foreach
(
$teachers
as
$teacher
)
:
?>
<?
foreach
(
$teachers
as
$teacher
)
:
?>
<option
value=
"
<?=
htmlReady
(
$teacher
[
'user_id'
])
?>
"
>
<option
value=
"
<?=
htmlReady
(
$teacher
[
'user_id'
])
?>
"
>
<?=
htmlReady
(
$teacher
[
'fullname'
])
?>
<?=
htmlReady
(
$teacher
[
'fullname'
])
?>
</option>
</option>
<?
endforeach
?>
<?
endforeach
?>
</select>
</select>
</label>
</label>
<?
endif
?>
<?
endif
?>
...
...
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