Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle_local_hsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
elc
moodle_local_hsh
Commits
8ea86363
Commit
8ea86363
authored
2 years ago
by
Elke Kreim
Browse files
Options
Downloads
Patches
Plain Diff
Remove semester_date.php
parent
a5285c61
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
semester_date.php
+0
-178
0 additions, 178 deletions
semester_date.php
with
0 additions
and
178 deletions
semester_date.php
deleted
100644 → 0
+
0
−
178
View file @
a5285c61
<?php
//start HsH
// #### Start - Change From Beuth-Hochschule M.E. ID=07_04 ####
// Functions from block_sem_course_overview to sort the courses in the navigation (my courses)
// This function returns the semester to a given date.
function
getSem
(
$startDate
,
$short
=
true
)
{
global
$coc_config
;
$coc_config
=
get_config
(
'block_course_overview_campus'
);
$startYear
=
date
(
"Y"
,
$startDate
);
$startMonth
=
date
(
"n"
,
$startDate
);
if
(
$short
)
$type
=
'short'
;
else
$type
=
'long'
;
if
(
$startYear
<=
"2000"
)
return
get_string
(
'morethanone'
,
'local_hsh'
);
if
(
$startMonth
<=
"2"
)
{
$startYear
=
$startYear
-
1
;
$startMonth
=
9
;
}
if
(
$startMonth
>=
"9"
)
{
$startSem
=
$coc_config
->
term2name
.
' '
;
$startSem
.
=
$startYear
;
$startSem
.
=
"/"
;
$startSem
.
=
substr
(
$startYear
+
1
,
2
,
2
);
}
else
{
$startSem
=
$coc_config
->
term1name
.
' '
.
$startYear
;
}
return
$startSem
;
}
// This function gives the first day of a semester
function
getFirstDayOfSem
(
$startDate
)
{
$startYear
=
date
(
"Y"
,
$startDate
);
$startMonth
=
date
(
"n"
,
$startDate
);
if
(
$startYear
<=
"2000"
)
return
"0"
;
// #### Start - Change from Beuth-Hochschule M.E. ID=07_05 ####
// Start Month is March and not April. March is summerterm.
// if($startMonth <= "3") { // original
if
(
$startMonth
<
"2"
)
{
// #### End - Change From Beuth-Hochschule M.E. ID=07_05 ####
$startYear
=
$startYear
-
1
;
$startMonth
=
"9"
;
}
elseif
(
$startMonth
>=
"9"
)
{
$startMonth
=
"9"
;
}
else
{
$startMonth
=
"3"
;
}
return
mktime
(
0
,
0
,
0
,
$startMonth
,
1
,
$startYear
);
}
//returns Parent-Root-Node of the course
function
getSemesterNode
(
$rootNode
,
$course
)
{
global
$PAGE
;
$startday
=
getFirstDayOfSem
(
$course
->
startdate
);
$parent
=
$rootNode
->
find
(
$startday
,
navigation_node
::
TYPE_ROOTNODE
);
if
(
!
$parent
)
{
$text
=
getSem
(
$startday
);
$parent
=
$rootNode
->
add
(
$text
,
null
,
navigation_node
::
TYPE_ROOTNODE
,
$text
,
$startday
);
if
(
$startday
==
getFirstDayOfSem
(
strtotime
(
'first day of this month'
,
time
())))
{
$parent
->
force_open
();
$parent
->
collapse
=
false
;
$parent
->
parent
->
collapse
=
false
;
}
}
// $parent->parent = $rootNode;
return
$parent
;
}
function
courseSort
(
&
$mycourses
,
$sortByShortName
=
true
)
{
if
(
!
function_exists
(
'cmp_course_short'
)
)
{
function
cmp_course_short
(
$a
,
$b
)
{
$startA
=
getFirstDayOfSem
(
$a
->
startdate
);
$startB
=
getFirstDayOfSem
(
$b
->
startdate
);
if
(
$startA
==
$startB
)
{
return
strcmp
(
$a
->
shortname
,
$b
->
shortname
);
}
return
(
$startA
>
$startB
)
?
-
1
:
1
;
}
}
if
(
!
function_exists
(
'cmp_course_lang'
)
)
{
function
cmp_course_lang
(
$a
,
$b
)
{
$startA
=
getFirstDayOfSem
(
$a
->
startdate
);
$startB
=
getFirstDayOfSem
(
$b
->
startdate
);
if
(
$startA
==
$startB
)
{
return
strcmp
(
$a
->
fullname
,
$b
->
fullname
);
}
return
(
$startA
>
$startB
)
?
-
1
:
1
;
}
}
if
(
$sortByShortName
)
usort
(
$mycourses
,
"cmp_course_short"
);
else
usort
(
$mycourses
,
"cmp_course_lang"
);
}
//end HsH
class
SemesterTitle
{
public
$correct_title
;
public
$startDate
;
public
$coc_config
;
// This function returns the semester to a given date.
function
getSem
()
{
global
$coc_config
;
$coc_config
=
get_config
(
'block_course_overview_campus'
);
#echo "StartDate: ".$this->startDate."\n";
$startYear
=
date
(
"Y"
,
$this
->
startDate
);
$startMonth
=
date
(
"n"
,
$this
->
startDate
);
if
(
$startMonth
<=
"2"
)
{
$startYear
=
$startYear
-
1
;
$startMonth
=
9
;
}
if
(
$startMonth
>=
"9"
)
{
$startSem
=
$coc_config
->
term2name
.
" "
;
$startSem
.
=
$startYear
;
$startSem
.
=
"/"
;
$startSem
.
=
substr
(
$startYear
+
1
,
2
,
2
);
}
else
{
$startSem
=
$coc_config
->
term1name
.
" "
.
$startYear
;
}
return
$startSem
;
}
/**
* @param $short switch between only the number "14" or "14/15" for the shortcut or
/* the long version "WiSe 2014/15" or "SoSe 14"
* @return array with 3 parts
*/
function
run
(
$short
)
{
$this
->
startDate
=
strtotime
(
'first day of this month'
,
time
());
$array
=
array
();
//switch between only the number "14" or "14/15" for the shortcut or
//the long version "WiSe 2014/15" or "SoSe 14"
$tmp_part
=
$this
->
getSem
();
$this
->
startDate
=
strtotime
(
'first day of +6 months'
);
$tmp_part2
=
$this
->
getSem
();
$this
->
startDate
=
strtotime
(
'first day of +12 months'
);
$tmp_part3
=
$this
->
getSem
();
if
(
$short
)
{
$tmp_part
=
preg_split
(
"/[\s]/"
,
$tmp_part
);
$tmp_part2
=
preg_split
(
"/[\s]/"
,
$tmp_part2
);
$tmp_part3
=
preg_split
(
"/[\s]/"
,
$tmp_part3
);
$array
=
array
(
substr
(
$tmp_part
[
1
],
2
),
substr
(
$tmp_part2
[
1
],
2
),
substr
(
$tmp_part3
[
1
],
2
));
}
else
{
$array
=
array
(
$tmp_part
,
$tmp_part2
,
$tmp_part3
);
}
return
$array
;
}
function
getShortened
(
$long
){
$long
=
preg_split
(
"/[\s]/"
,
$long
);
return
substr
(
$long
[
0
],
2
);
}
}
?>
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