Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
71a56e08
Commit
71a56e08
authored
Sep 13, 2012
by
Marina Glancy
Browse files
MDL-35339 avoid using get_all_sections(), get_all_mods() and field section.sequence directly
parent
ecfe814e
Changes
31
Hide whitespace changes
Inline
Side-by-side
blocks/site_main_menu/block_site_main_menu.php
View file @
71a56e08
...
...
@@ -29,10 +29,10 @@ class block_site_main_menu extends block_list {
require_once
(
$CFG
->
dirroot
.
'/course/lib.php'
);
$context
=
context_course
::
instance
(
$course
->
id
);
$isediting
=
$this
->
page
->
user_is_editing
()
&&
has_capability
(
'moodle/course:manageactivities'
,
$context
);
$modinfo
=
get_fast_modinfo
(
$course
);
/// extra fast view mode
if
(
!
$isediting
)
{
$modinfo
=
get_fast_modinfo
(
$course
);
if
(
!
empty
(
$modinfo
->
sections
[
0
]))
{
$options
=
array
(
'overflowdiv'
=>
true
);
foreach
(
$modinfo
->
sections
[
0
]
as
$cmid
)
{
...
...
@@ -62,7 +62,7 @@ class block_site_main_menu extends block_list {
/// slow & hacky editing mode
$ismoving
=
ismoving
(
$course
->
id
);
$section
=
get_course_section
(
0
,
$course
->
id
);
$modinfo
=
get_fast_modinfo
(
$course
);
get_all_mods
(
$course
->
id
,
$mods
,
$modnames
,
$modnamesplural
,
$modnamesused
);
$groupbuttons
=
$course
->
groupmode
;
...
...
@@ -82,14 +82,13 @@ class block_site_main_menu extends block_list {
$this
->
content
->
items
[]
=
$USER
->
activitycopyname
.
' (<a href="'
.
$CFG
->
wwwroot
.
'/course/mod.php?cancelcopy=true&sesskey='
.
sesskey
()
.
'">'
.
$strcancel
.
'</a>)'
;
}
if
(
!
empty
(
$section
->
sequence
))
{
$sectionmods
=
explode
(
','
,
$section
->
sequence
);
if
(
!
empty
(
$modinfo
->
sections
[
0
]))
{
$options
=
array
(
'overflowdiv'
=>
true
);
foreach
(
$sectionmods
as
$modnumber
)
{
if
(
empty
(
$mods
[
$modnumber
]))
{
foreach
(
$modinfo
->
sections
[
0
]
as
$modnumber
)
{
$mod
=
$modinfo
->
cms
[
$modnumber
];
if
(
!
$mod
->
uservisible
)
{
continue
;
}
$mod
=
$mods
[
$modnumber
];
if
(
!
$ismoving
)
{
if
(
$groupbuttons
)
{
if
(
!
$mod
->
groupmodelink
=
$groupbuttonslink
)
{
...
...
blocks/social_activities/block_social_activities.php
View file @
71a56e08
...
...
@@ -64,11 +64,8 @@ class block_social_activities extends block_list {
/// slow & hacky editing mode
$ismoving
=
ismoving
(
$course
->
id
);
$sections
=
get_all_sections
(
$course
->
id
);
if
(
!
empty
(
$sections
)
&&
isset
(
$sections
[
0
]))
{
$section
=
$sections
[
0
];
}
$modinfo
=
get_fast_modinfo
(
$course
);
$section
=
$modinfo
->
get_section_info
(
0
);
if
(
!
empty
(
$section
))
{
get_all_mods
(
$course
->
id
,
$mods
,
$modnames
,
$modnamesplural
,
$modnamesused
);
...
...
@@ -91,14 +88,13 @@ class block_social_activities extends block_list {
$this
->
content
->
items
[]
=
$USER
->
activitycopyname
.
' (<a href="'
.
$CFG
->
wwwroot
.
'/course/mod.php?cancelcopy=true&sesskey='
.
sesskey
()
.
'">'
.
$strcancel
.
'</a>)'
;
}
if
(
!
empty
(
$section
)
&&
!
empty
(
$section
->
sequence
))
{
$sectionmods
=
explode
(
','
,
$section
->
sequence
);
if
(
!
empty
(
$modinfo
->
sections
[
0
]))
{
$options
=
array
(
'overflowdiv'
=>
true
);
foreach
(
$sectionmods
as
$modnumber
)
{
if
(
empty
(
$mods
[
$modnumber
]))
{
foreach
(
$modinfo
->
sections
[
0
]
as
$modnumber
)
{
$mod
=
$modinfo
->
cms
[
$modnumber
];
if
(
!
$mod
->
uservisible
)
{
continue
;
}
$mod
=
$mods
[
$modnumber
];
if
(
!
$ismoving
)
{
if
(
$groupbuttons
)
{
if
(
!
$mod
->
groupmodelink
=
$groupbuttonslink
)
{
...
...
course/externallib.php
View file @
71a56e08
...
...
@@ -105,13 +105,12 @@ class core_course_external extends external_api {
//retrieve sections
$modinfo
=
get_fast_modinfo
(
$course
);
$sections
=
get_all_sections
(
$course
->
id
);
$sections
=
$modinfo
->
get_section_info_all
(
);
//for each sections (first displayed to last displayed)
foreach
(
$sections
as
$key
=>
$section
)
{
$showsection
=
(
has_capability
(
'moodle/course:viewhiddensections'
,
$context
)
or
$section
->
visible
or
!
$course
->
hiddensections
);
if
(
!
$showsection
)
{
if
(
!
$section
->
uservisible
)
{
continue
;
}
...
...
course/recent.php
View file @
71a56e08
...
...
@@ -91,11 +91,9 @@ if (has_capability('moodle/course:viewhiddensections', $context)) {
$hiddenfilter
=
"AND cs.visible = 1"
;
}
$sections
=
array
();
$rawsections
=
array_slice
(
get_all_sections
(
$course
->
id
),
0
,
$course
->
numsections
+
1
,
true
);
$canviewhidden
=
has_capability
(
'moodle/course:viewhiddensections'
,
$context
);
foreach
(
$rawsections
as
$section
)
{
if
(
$canviewhidden
||
!
empty
(
$section
->
visible
))
{
$sections
[
$section
->
section
]
=
$section
;
foreach
(
$modinfo
->
get_section_info_all
()
as
$i
=>
$section
)
{
if
(
!
empty
(
$section
->
uservisible
))
{
$sections
[
$i
]
=
$section
;
}
}
...
...
@@ -115,20 +113,18 @@ if ($param->modid === 'all') {
}
}
else
if
(
is_numeric
(
$param
->
modid
))
{
$section
=
$sections
[
$modinfo
->
cms
[
$param
->
modid
]
->
sectionnum
]
;
$
section
->
sequence
=
$param
->
modid
;
$sections
=
array
(
$section
->
sequence
=>
$section
);
$section
num
=
$modinfo
->
cms
[
$param
->
modid
]
->
sectionnum
;
$
filter_modid
=
$param
->
modid
;
$sections
=
array
(
$section
num
=>
$sections
[
$section
num
]
);
}
if
(
is_null
(
$modinfo
->
groups
))
{
$modinfo
->
groups
=
groups_get_user_groups
(
$course
->
id
);
// load all my groups and cache it in modinfo
}
$modinfo
->
get_groups
();
// load all my groups and cache it in modinfo
$activities
=
array
();
$index
=
0
;
foreach
(
$sections
as
$section
)
{
foreach
(
$sections
as
$sectionnum
=>
$section
)
{
$activity
=
new
stdClass
();
$activity
->
type
=
'section'
;
...
...
@@ -141,17 +137,11 @@ foreach ($sections as $section) {
$activity
->
visible
=
$section
->
visible
;
$activities
[
$index
++
]
=
$activity
;
if
(
empty
(
$
section
->
sequence
))
{
if
(
empty
(
$
modinfo
->
sections
[
$sectionnum
]
))
{
continue
;
}
$sectionmods
=
explode
(
","
,
$section
->
sequence
);
foreach
(
$sectionmods
as
$cmid
)
{
if
(
!
isset
(
$mods
[
$cmid
])
or
!
isset
(
$modinfo
->
cms
[
$cmid
]))
{
continue
;
}
foreach
(
$modinfo
->
sections
[
$sectionnum
]
as
$cmid
)
{
$cm
=
$modinfo
->
cms
[
$cmid
];
if
(
!
$cm
->
uservisible
)
{
...
...
@@ -162,6 +152,10 @@ foreach ($sections as $section) {
continue
;
}
if
(
!
empty
(
$filter_modid
)
and
$cmid
!=
$filter_modid
)
{
continue
;
}
$libfile
=
"
$CFG->dirroot
/mod/
$cm->modname
/lib.php"
;
if
(
file_exists
(
$libfile
))
{
...
...
course/recent_form.php
View file @
71a56e08
...
...
@@ -36,7 +36,6 @@ class recent_form extends moodleform {
$mform
=&
$this
->
_form
;
$context
=
context_course
::
instance
(
$COURSE
->
id
);
$modinfo
=
get_fast_modinfo
(
$COURSE
);
$sections
=
get_all_sections
(
$COURSE
->
id
);
$mform
->
addElement
(
'header'
,
'filters'
,
get_string
(
'managefilters'
));
//TODO: add better string
...
...
@@ -127,7 +126,7 @@ class recent_form extends moodleform {
}
foreach
(
$modinfo
->
sections
as
$section
=>
$cmids
)
{
$options
[
"section/
$section
"
]
=
"-- "
.
get_section_name
(
$COURSE
,
$section
s
[
$section
]
)
.
" --"
;
$options
[
"section/
$section
"
]
=
"-- "
.
get_section_name
(
$COURSE
,
$section
)
.
" --"
;
foreach
(
$cmids
as
$cmid
)
{
$cm
=
$modinfo
->
cms
[
$cmid
];
if
(
empty
(
$modsused
[
$cm
->
modname
])
or
!
$cm
->
uservisible
)
{
...
...
course/resources.php
View file @
71a56e08
...
...
@@ -65,9 +65,6 @@ echo $OUTPUT->header();
$modinfo
=
get_fast_modinfo
(
$course
);
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$cms
=
array
();
$resources
=
array
();
foreach
(
$modinfo
->
cms
as
$cm
)
{
...
...
@@ -116,7 +113,7 @@ foreach ($cms as $cm) {
$printsection
=
''
;
if
(
$cm
->
sectionnum
!==
$currentsection
)
{
if
(
$cm
->
sectionnum
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$cm
->
sectionnum
]
);
$printsection
=
get_section_name
(
$course
,
$cm
->
sectionnum
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/assignment/index.php
View file @
71a56e08
...
...
@@ -37,9 +37,6 @@ if (!$cms = get_coursemodules_in_course('assignment', $course->id, 'cm.idnumber,
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$timenow
=
time
();
...
...
@@ -74,7 +71,7 @@ foreach ($modinfo->instances['assignment'] as $cm) {
if
(
$usesections
)
{
if
(
$cm
->
sectionnum
!==
$currentsection
)
{
if
(
$cm
->
sectionnum
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$cm
->
sectionnum
]
);
$printsection
=
get_section_name
(
$course
,
$cm
->
sectionnum
);
}
if
(
$currentsection
!==
""
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/assignment/type/online/all.php
View file @
71a56e08
...
...
@@ -47,8 +47,6 @@ $PAGE->navbar->add($str->onlinetext);
// get all the assignments in the course
$assignments
=
get_all_instances_in_course
(
'assignment'
,
$course
,
$USER
->
id
);
$sections
=
get_all_sections
(
$course
->
id
);
// array to hold display data
$views
=
array
();
...
...
@@ -98,7 +96,7 @@ foreach( $assignments as $assignment ) {
$view
=
new
stdClass
;
// start to build view object
$view
->
section
=
get_section_name
(
$course
,
$sections
[
$assignment
->
section
]
);
$view
->
section
=
get_section_name
(
$course
,
$assignment
->
section
);
$view
->
name
=
$assignment
->
name
;
$view
->
submitted
=
$submitted
;
...
...
mod/book/index.php
View file @
71a56e08
...
...
@@ -57,9 +57,6 @@ if (!$books = get_all_instances_in_course('book', $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$table
=
new
html_table
();
$table
->
attributes
[
'class'
]
=
'generaltable mod_index'
;
...
...
@@ -80,7 +77,7 @@ foreach ($books as $book) {
$printsection
=
''
;
if
(
$book
->
section
!==
$currentsection
)
{
if
(
$book
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$book
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$book
->
section
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/chat/index.php
View file @
71a56e08
...
...
@@ -38,9 +38,6 @@ if (! $chats = get_all_instances_in_course('chat', $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
/// Print the list of instances (your module will probably extend this)
...
...
@@ -69,7 +66,7 @@ foreach ($chats as $chat) {
$printsection
=
''
;
if
(
$chat
->
section
!==
$currentsection
)
{
if
(
$chat
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$chat
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$chat
->
section
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/choice/index.php
View file @
71a56e08
...
...
@@ -29,9 +29,6 @@
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$sql
=
"SELECT cha.*
FROM
{
choice
}
ch,
{
choice_answers
}
cha
...
...
@@ -76,7 +73,7 @@
$printsection
=
""
;
if
(
$choice
->
section
!==
$currentsection
)
{
if
(
$choice
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$choice
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$choice
->
section
);
}
if
(
$currentsection
!==
""
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/data/index.php
View file @
71a56e08
...
...
@@ -56,9 +56,6 @@ if (! $datas = get_all_instances_in_course("data", $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$timenow
=
time
();
$strname
=
get_string
(
'name'
);
...
...
@@ -120,7 +117,7 @@ foreach ($datas as $data) {
if
(
$usesections
)
{
if
(
$data
->
section
!==
$currentsection
)
{
if
(
$data
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$data
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$data
->
section
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/feedback/index.php
View file @
71a56e08
...
...
@@ -61,9 +61,6 @@ if (! $feedbacks = get_all_instances_in_course("feedback", $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
/// Print the list of instances (your module will probably extend this)
...
...
@@ -105,7 +102,7 @@ foreach ($feedbacks as $feedback) {
$link
=
'<a '
.
$dimmedclass
.
' href="'
.
$viewurl
->
out
()
.
'">'
.
$feedback
->
name
.
'</a>'
;
if
(
$usesections
)
{
$tabledata
=
array
(
get_section_name
(
$course
,
$sections
[
$feedback
->
section
]
),
$link
);
$tabledata
=
array
(
get_section_name
(
$course
,
$feedback
->
section
),
$link
);
}
else
{
$tabledata
=
array
(
$link
);
}
...
...
mod/folder/index.php
View file @
71a56e08
...
...
@@ -54,9 +54,6 @@ if (!$folders = get_all_instances_in_course('folder', $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$table
=
new
html_table
();
$table
->
attributes
[
'class'
]
=
'generaltable mod_index'
;
...
...
@@ -77,7 +74,7 @@ foreach ($folders as $folder) {
$printsection
=
''
;
if
(
$folder
->
section
!==
$currentsection
)
{
if
(
$folder
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$folder
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$folder
->
section
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/forum/discuss.php
View file @
71a56e08
...
...
@@ -219,7 +219,6 @@
$modinfo
=
get_fast_modinfo
(
$course
);
if
(
isset
(
$modinfo
->
instances
[
'forum'
]))
{
$forummenu
=
array
();
$sections
=
get_all_sections
(
$course
->
id
);
// Check forum types and eliminate simple discussions.
$forumcheck
=
$DB
->
get_records
(
'forum'
,
array
(
'course'
=>
$course
->
id
),
''
,
'id, type'
);
foreach
(
$modinfo
->
instances
[
'forum'
]
as
$forumcm
)
{
...
...
@@ -228,7 +227,7 @@
continue
;
}
$section
=
$forumcm
->
sectionnum
;
$sectionname
=
get_section_name
(
$course
,
$section
s
[
$section
]
);
$sectionname
=
get_section_name
(
$course
,
$section
);
if
(
empty
(
$forummenu
[
$section
]))
{
$forummenu
[
$section
]
=
array
(
$sectionname
=>
array
());
}
...
...
mod/forum/index.php
View file @
71a56e08
...
...
@@ -104,7 +104,6 @@ if ($show_rss = (($can_subscribe || $course->id == SITEID) &&
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
$sections
=
get_all_sections
(
$course
->
id
);
$table
=
new
html_table
();
...
...
@@ -358,7 +357,7 @@ if ($course->id != SITEID) { // Only real courses have learning forums
$forum
->
intro
=
shorten_text
(
format_module_intro
(
'forum'
,
$forum
,
$cm
->
id
),
$CFG
->
forum_shortpost
);
if
(
$cm
->
sectionnum
!=
$currentsection
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$cm
->
sectionnum
]
);
$printsection
=
get_section_name
(
$course
,
$cm
->
sectionnum
);
if
(
$currentsection
)
{
$learningtable
->
data
[]
=
'hr'
;
}
...
...
mod/glossary/index.php
View file @
71a56e08
...
...
@@ -44,9 +44,6 @@ if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
/// Print the list of instances (your module will probably extend this)
...
...
@@ -88,7 +85,7 @@ foreach ($glossarys as $glossary) {
if
(
$usesections
)
{
if
(
$glossary
->
section
!==
$currentsection
)
{
if
(
$glossary
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$glossary
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$glossary
->
section
);
}
if
(
$currentsection
!==
""
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/imscp/index.php
View file @
71a56e08
...
...
@@ -54,9 +54,6 @@ if (!$imscps = get_all_instances_in_course('imscp', $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$table
=
new
html_table
();
$table
->
attributes
[
'class'
]
=
'generaltable mod_index'
;
...
...
@@ -77,7 +74,7 @@ foreach ($imscps as $imscp) {
$printsection
=
''
;
if
(
$imscp
->
section
!==
$currentsection
)
{
if
(
$imscp
->
section
)
{
$printsection
=
get_section_name
(
$course
,
$sections
[
$imscp
->
section
]
);
$printsection
=
get_section_name
(
$course
,
$imscp
->
section
);
}
if
(
$currentsection
!==
''
)
{
$table
->
data
[]
=
'hr'
;
...
...
mod/lesson/index.php
View file @
71a56e08
...
...
@@ -62,9 +62,6 @@ if (! $lessons = get_all_instances_in_course("lesson", $course)) {
}
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
/// Print the list of instances (your module will probably extend this)
...
...
@@ -113,7 +110,7 @@ foreach ($lessons as $lesson) {
$grade_value
=
$return
[
$USER
->
id
]
->
rawgrade
;
}
}
$table
->
data
[]
=
array
(
get_section_name
(
$course
,
$sections
[
$lesson
->
section
]
),
$link
,
$grade_value
,
$due
);
$table
->
data
[]
=
array
(
get_section_name
(
$course
,
$lesson
->
section
),
$link
,
$grade_value
,
$due
);
}
else
{
$table
->
data
[]
=
array
(
$link
,
$lesson
->
grade
,
$due
);
}
...
...
mod/lti/index.php
View file @
71a56e08
...
...
@@ -79,9 +79,6 @@ $timenow = time();
$strname
=
get_string
(
"name"
);
$strsectionname
=
get_string
(
'sectionname'
,
'format_'
.
$course
->
format
);
$usesections
=
course_format_uses_sections
(
$course
->
format
);
if
(
$usesections
)
{
$sections
=
get_all_sections
(
$course
->
id
);
}
$table
=
new
html_table
();
$table
->
attributes
[
'class'
]
=
'generaltable mod_index'
;
...
...
@@ -102,8 +99,8 @@ foreach ($basicltis as $basiclti) {
$link
=
"<a href=
\"
view.php?id=
$basiclti->coursemodule
\"
>
$basiclti->name
</a>"
;
}
if
(
$
course
->
format
==
"weeks"
or
$course
->
format
==
"topics"
)
{
$table
->
data
[]
=
array
(
$basiclti
->
section
,
$link
);
if
(
$
usesections
)
{
$table
->
data
[]
=
array
(
get_section_name
(
$course
,
$basiclti
->
section
)
,
$link
);
}
else
{
$table
->
data
[]
=
array
(
$link
);
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment