General developer forum

Course without enrolment methods...

 
Picture of Peter Eliyahu Kornfeld
Course without enrolment methods...
 

Hi,

I have a plugin that reads text file and create courses from the data in it...

I'm using the API create_course like this:

$course->idnumber = $course_id;
$course->fullname = $course_name;
$course->shortname = $course_shortname;
$course->category = $category_code;
$course->startdate = time ();

$course->password = md5 ( $course_psw );

$courseconfig = get_config ( 'moodlecourse' );
foreach ( $courseconfig as $key => $value ) {
	$course->$key = $value;
}

$course = create_course ( $course );

For reasons I can not identify some of the courses (1 out of 100) created without any enrolment methods, so I can not enroll students/teachers to them...

Any ideas for the reason or how to track the problem down would be very appreciated...


Thank you,

Peter

 
Average of ratings: -
Picture of Darko Miletić
Re: Course without enrolment methods...
Core developersParticularly helpful Moodlers

Your code is not entirely correct. 

course table does not have password field. Courses in Moodle in general do not have passwords. It is also incorrect to just glue the configuration values for default course to the record that is supposed to go into course table.

These are the fields in the course table:

id
category
sortorder
fullname
shortname
idnumber
summary
summaryformat
format
showgrades
newsitems
startdate
enddate
marker
maxbytes
legacyfiles
showreports
visible
visibleold
groupmode
groupmodeforce
defaultgroupingid
lang
calendartype
theme
timecreated
timemodified
requested
enablecompletion
completionnotify
cacherev

And these are the values in moodlecourse config area:

'coursedisplay'
'courseduration'
'enablecompletion'
'format'
'groupmode'
'groupmodeforce'
'hiddensections'
'lang'
'maxbytes'
'maxsections'
'newsitems'
'numsections'
'showgrades'
'showreports'
'visible'

As you can see only some names overlap. The rest will be discarded in case of MySQL while on other databases it might even trigger errors.




 
Average of ratings: -
Picture of Peter Eliyahu Kornfeld
Re: Course without enrolment methods...
 

It is a kind of old code (started with moodle 1.9) so probably 'password' is a leftover...

However my problem not there... Courses ARE created (via create_course API call), however sometimes without enrollment methods...

 
Average of ratings: -