Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Untis
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Untis
Commits
91e1f398
Commit
91e1f398
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add lesson times to timetable
parent
b0737275
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/apps/untis/parse.py
+25
-4
25 additions, 4 deletions
biscuit/apps/untis/parse.py
with
25 additions
and
4 deletions
biscuit/apps/untis/parse.py
+
25
−
4
View file @
91e1f398
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils
import
timezone
from
schoolapps.settings
import
LESSONS
class
Lesson
(
object
):
class
Lesson
(
object
):
...
@@ -205,20 +208,38 @@ class LessonElementContainer(object):
...
@@ -205,20 +208,38 @@ class LessonElementContainer(object):
self
.
room
=
room
self
.
room
=
room
def
parse_lesson_times
():
times
=
[]
for
i
,
t
in
enumerate
(
LESSONS
):
start_split
=
t
[
0
].
split
(
"
:
"
)
start_time
=
timezone
.
datetime
(
year
=
2000
,
day
=
1
,
month
=
1
,
hour
=
int
(
start_split
[
0
]),
minute
=
int
(
start_split
[
1
]))
end_time
=
start_time
+
timezone
.
timedelta
(
minutes
=
45
)
print
(
start_time
)
print
(
end_time
)
times
.
append
({
"
number
"
:
i
+
1
,
"
number_format
"
:
t
[
1
],
"
start
"
:
start_time
,
"
end
"
:
end_time
,
})
return
times
def
get_plan
(
type
,
id
):
def
get_plan
(
type
,
id
):
"""
Generates a plan for type (TYPE_TEACHE, TYPE_CLASS, TYPE_ROOM) and a id of the teacher (class, room)
"""
"""
Generates a plan for type (TYPE_TEACHE, TYPE_CLASS, TYPE_ROOM) and a id of the teacher (class, room)
"""
# Get parsed lessons
# Get parsed lessons
lessons
=
parse
()
lessons
=
parse
()
times_parsed
=
parse_lesson_times
()
# Init plan array
# Init plan array
plan
=
[]
plan
=
[]
# Fill plan array with LessonContainers (show upside), WIDTH and HEIGHT are defined by Django settings
# Fill plan array with LessonContainers (show upside), WIDTH and HEIGHT are defined by Django settings
for
hour_idx
in
range
(
settings
.
TIMETABLE_HEIGHT
):
for
hour_idx
in
range
(
settings
.
TIMETABLE_HEIGHT
):
plan
.
append
([])
plan
.
append
(
(
[]
,
times_parsed
[
hour_idx
]
if
len
(
times_parsed
)
>
hour_idx
else
None
)
)
for
day_idx
in
range
(
settings
.
TIMETABLE_WIDTH
):
for
day_idx
in
range
(
settings
.
TIMETABLE_WIDTH
):
plan
[
hour_idx
].
append
(
LessonContainer
())
plan
[
hour_idx
]
[
0
]
.
append
(
LessonContainer
())
# Fill plan with lessons
# Fill plan with lessons
for
lesson
in
lessons
:
for
lesson
in
lessons
:
...
@@ -254,7 +275,7 @@ def get_plan(type, id):
...
@@ -254,7 +275,7 @@ def get_plan(type, id):
room_index
=
j
room_index
=
j
# Add the time object to the matching LessonContainer on the right position in the plan array
# Add the time object to the matching LessonContainer on the right position in the plan array
plan
[
time
.
hour
-
1
][
time
.
day
-
1
].
set_time
(
time
)
plan
[
time
.
hour
-
1
][
0
][
time
.
day
-
1
].
set_time
(
time
)
# Check if there is an room for this time and lesson
# Check if there is an room for this time and lesson
try
:
try
:
...
@@ -270,7 +291,7 @@ def get_plan(type, id):
...
@@ -270,7 +291,7 @@ def get_plan(type, id):
if
type
!=
TYPE_ROOM
or
i
==
room_index
:
if
type
!=
TYPE_ROOM
or
i
==
room_index
:
# Add this container object to the LessonContainer object in the plan array
# Add this container object to the LessonContainer object in the plan array
plan
[
time
.
hour
-
1
][
time
.
day
-
1
].
append
(
element_container
)
plan
[
time
.
hour
-
1
][
0
][
time
.
day
-
1
].
append
(
element_container
)
# print(plan)
# print(plan)
#
#
...
...
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