Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-block_course_overview_uwmoodle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
uw-moodle
moodle-block_course_overview_uwmoodle
Commits
91f1f33f
Commit
91f1f33f
authored
9 years ago
by
Matt Petro
Browse files
Options
Downloads
Patches
Plain Diff
UWMOODLE-875: Convert all crons requiring middleware services to task interface
Task-Url:
https://jira.doit.wisc.edu/jira/browse/UWMOODLE-875
parent
319337a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
block_course_overview_uwmoodle.php
+1
-68
1 addition, 68 deletions
block_course_overview_uwmoodle.php
getcourses.php
+1
-1
1 addition, 1 deletion
getcourses.php
locallib.php
+0
-13
0 additions, 13 deletions
locallib.php
version.php
+1
-2
1 addition, 2 deletions
version.php
with
3 additions
and
84 deletions
block_course_overview_uwmoodle.php
+
1
−
68
View file @
91f1f33f
...
@@ -120,7 +120,7 @@ class block_course_overview_uwmoodle extends block_base {
...
@@ -120,7 +120,7 @@ class block_course_overview_uwmoodle extends block_base {
list
(
$courses
,
$errors
)
=
block_course_overview_uwmoodle_get_sorted_courses
();
list
(
$courses
,
$errors
)
=
block_course_overview_uwmoodle_get_sorted_courses
();
$terms
=
block_course_overview_uwmoodle_group_courses_by_term
(
$courses
);
$terms
=
block_course_overview_uwmoodle_group_courses_by_term
(
$courses
);
$currentterm
=
block_course_overview_uwmoodle_
get_current_term
();
$currentterm
=
\enrol_wisc\local\chub\timetable_util
::
get_current_term
code
();
$selectedterm
=
optional_param
(
'term'
,
$currentterm
,
PARAM_INT
);
$selectedterm
=
optional_param
(
'term'
,
$currentterm
,
PARAM_INT
);
if
(
!
isset
(
$terms
[
$currentterm
]))
{
if
(
!
isset
(
$terms
[
$currentterm
]))
{
...
@@ -166,64 +166,6 @@ class block_course_overview_uwmoodle extends block_base {
...
@@ -166,64 +166,6 @@ class block_course_overview_uwmoodle extends block_base {
return
$this
->
content
;
return
$this
->
content
;
}
}
/**
* Get the current term from the datastore, and update user show/hide preferences when it changes.
*
* @return boolean true on success
*/
public
function
update_current_term
()
{
global
$CFG
,
$DB
;
$oldcurrentterm
=
get_config
(
'block_course_overview_uwmoodle'
,
'currentterm'
);
try
{
$currentterm
=
$this
->
get_current_term
();
}
catch
(
Exception
$e
)
{
// Suppress errors to the log. This can get noisy quickly when CHUB is down.
//mtrace("Error fetching current term: ".$e->getMessage());
return
false
;
}
if
(
$currentterm
===
false
)
{
mtrace
(
"No current term found"
);
return
false
;
}
if
(
$currentterm
&&
$currentterm
!=
$oldcurrentterm
)
{
// store new term
mtrace
(
'new current term: '
.
$currentterm
);
set_config
(
'currentterm'
,
$currentterm
,
'block_course_overview_uwmoodle'
);
}
return
true
;
}
/**
* Fetch current term from CHUB. Throw exception on CHUB error.
*
* @return string|false term_code or false if none found.
*/
public
function
get_current_term
()
{
global
$CFG
;
require_once
(
$CFG
->
dirroot
.
'/enrol/wisc/lib/datastore.php'
);
$datastore
=
wisc_timetable_datastore
::
get_timetable_datastore
();
$terms
=
$datastore
->
getAvailableTerms
();
$now
=
time
();
$futureterms
=
array
();
foreach
(
$terms
as
$term
)
{
// check that term hasn't ended and doesn't have an odd termCode
// odd term codes (e.g. Winter) are never considered the current term
if
(
$term
->
endDate
>
$now
&&
(
$term
->
termCode
%
2
!=
1
))
{
$futureterms
[]
=
$term
->
termCode
;
}
}
if
(
!
empty
(
$futureterms
))
{
$currentterm
=
min
(
$futureterms
);
}
else
{
$currentterm
=
false
;
}
return
$currentterm
;
}
/**
/**
* allow the block to have a configuration page
* allow the block to have a configuration page
*
*
...
@@ -242,15 +184,6 @@ class block_course_overview_uwmoodle extends block_base {
...
@@ -242,15 +184,6 @@ class block_course_overview_uwmoodle extends block_base {
return
array
(
'my-index'
=>
true
);
return
array
(
'my-index'
=>
true
);
}
}
/**
* Block cron to update currentterm
*
* @return boolean true on success
*/
public
function
cron
()
{
return
$this
->
update_current_term
();
}
/**
/**
* Sets block header to be hidden or visible
* Sets block header to be hidden or visible
*
*
...
...
This diff is collapsed.
Click to expand it.
getcourses.php
+
1
−
1
View file @
91f1f33f
...
@@ -66,7 +66,7 @@ if(confirm_sesskey()) {
...
@@ -66,7 +66,7 @@ if(confirm_sesskey()) {
$terms
=
block_course_overview_uwmoodle_group_courses_by_term
(
$courses
);
$terms
=
block_course_overview_uwmoodle_group_courses_by_term
(
$courses
);
$currentterm
=
block_course_overview_uwmoodle_
get_current_term
();
$currentterm
=
\enrol_wisc\local\chub\timetable_util
::
get_current_term
code
();
$selectedterm
=
optional_param
(
'term'
,
$currentterm
,
PARAM_INT
);
$selectedterm
=
optional_param
(
'term'
,
$currentterm
,
PARAM_INT
);
if
(
!
isset
(
$terms
[
$currentterm
]))
{
if
(
!
isset
(
$terms
[
$currentterm
]))
{
...
...
This diff is collapsed.
Click to expand it.
locallib.php
+
0
−
13
View file @
91f1f33f
...
@@ -188,19 +188,6 @@ function block_course_overview_uwmoodle_sort_term_array(&$terms) {
...
@@ -188,19 +188,6 @@ function block_course_overview_uwmoodle_sort_term_array(&$terms) {
return
uksort
(
$terms
,
$cmp
);
return
uksort
(
$terms
,
$cmp
);
}
}
/**
* Get the current term from our settings
*
* @return string termcode
*/
function
block_course_overview_uwmoodle_get_current_term
()
{
$currentterm
=
get_config
(
'block_course_overview_uwmoodle'
,
'currentterm'
);
if
(
!
$currentterm
)
{
$currentterm
=
1136
;
// Just set it to something in the past, until cron runs and updates the term.
}
return
$currentterm
;
}
/**
/**
* Return a string representing the term (e.g. "Fall 2010")
* Return a string representing the term (e.g. "Fall 2010")
* This function doesn't make any remote calls.
* This function doesn't make any remote calls.
...
...
This diff is collapsed.
Click to expand it.
version.php
+
1
−
2
View file @
91f1f33f
...
@@ -18,11 +18,10 @@
...
@@ -18,11 +18,10 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
();
defined
(
'MOODLE_INTERNAL'
)
||
die
();
$plugin
->
component
=
'block_course_overview_uwmoodle'
;
$plugin
->
component
=
'block_course_overview_uwmoodle'
;
$plugin
->
version
=
201408260
0
;
$plugin
->
version
=
201408260
1
;
$plugin
->
release
=
'2.0'
;
$plugin
->
release
=
'2.0'
;
$plugin
->
requires
=
2012120300
;
$plugin
->
requires
=
2012120300
;
$plugin
->
maturity
=
MATURITY_STABLE
;
$plugin
->
maturity
=
MATURITY_STABLE
;
$plugin
->
cron
=
43200
;
// Set min time between cron executions to 12 hours
$plugin
->
dependencies
=
array
(
$plugin
->
dependencies
=
array
(
'enrol_wisc'
=>
2013061701
,
'enrol_wisc'
=>
2013061701
,
...
...
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