updating the number of sections of course page in Bulk

updating the number of sections of course page in Bulk

by m question -
Number of replies: 6

Hi,


how to update the number of sections of all courses in Moodle which are already created?

I tried SA>Courses>Course default settings> number of sections

but that didn't affect the courses.


I tried to change it from database by executing the following 

UPDATE `mdl_course_format_options` SET `value`=15 WHERE `name`='numsetions' AND `courseid`=196 

the result was "0 rows affected"

I am sure there is course with course id 196, I want to try it in one course first before executing the following

UPDATE `mdl_course_format_options` SET `value`=15 WHERE `name`='numsetions' 

but it didn't work

how to change the sections?


Average of ratings: -
In reply to m question

Re: updating the number of sections of course page in Bulk

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What version of Moodle is this? This has changed in the latest (recent?) versions - topics are now added/deleted rather than there being a number

I definitely wouldn't access the database directly. 

In reply to Howard Miller

Re: updating the number of sections of course page in Bulk

by m question -

Moodle 3.1.7

I have more than 200 courses that defualt format is Weeks and number of sections/Weeks 10

I want to change it to 15 for the courses

In reply to m question

Re: updating the number of sections of course page in Bulk

by Edward Burke -

From the nAdministration Block choose Courses>Default course settings>Change sections to your desired number.  hope this helps

In reply to Edward Burke

Re: updating the number of sections of course page in Bulk

by m question -

Thank you,

but this didn't affect the courses


the default course settings

In reply to Edward Burke

Re: updating the number of sections of course page in Bulk

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Clue is in the name - 'default' - won't change existing ones. 

In reply to m question

Re: updating the number of sections of course page in Bulk

by m question -

there was a small error in the sql in WHERE `name`='numsections' 

the correct one as follows:


to update the number of course sections for all courses to a specific value (15 in my case):

UPDATE `mdl_course_format_options` SET `value`=15 WHERE `name`='numsections' AND `courseid`<>1 and `format`='weeks'


I agree with Howard I don't recommend updating the database too, however, I needed fast solution