Set enrolment startdate using CSV upload

Re: Set enrolment startdate using CSV upload

by Todd Roth -
Number of replies: 19
If you are trying to set up a course with a start date with a duration consider the format listed below
enrolment1 is the start date
enrolperiod1 is 3 of days the course is available
group1 is designed to utilize the same course. Why? if you are wanting to look at long term summative assessments results this is critical for evaluation

username password firstname lastname email course1 role1 enrolment_1_startdate enrolperiod1 group1 course2 role2 enrolment_2_startdate enrolperiod2 group2 course3 role3 enrolment_3_startdate enrolperiod3 group3
first.last@email.com Mickey Mouse Prework_ZEUS student 2020-10-01 1 day wk 35_39 Learn_Triton student 2020-10-02 1 day wk 35_39 Learn_Apollo D9 student 2020-10-03 1 day wk 35_39
In reply to Todd Roth

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
So, hope to have understood clearly all the above thread, have a student (id number is 000002x) and course involved is CPASTC. Student is already uploaded into this course via the normal bulk user upload CSV. Now I need this student to be able to have an effective start date to this course on the 25th December, 2020.

CSV file should have the following date

add, student, 000002x, CPASTC, 2020-12-25 08:00

Correct?

Second query, moodle is installed on Ubuntu. I do not have access to the operating system and can administer only from inside moodle. As the plugin needs an absolute path inside moodle is there a way I can circumvent this issue?
Any ideas??
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
What issue exactly are you trying to circumvent? I am confused by your plugin question...
In reply to Emma Richardson

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
Hi Emma,

quote moodle documentation regarding flat file uploading "You should specify an absolute path for the upload file (eg /var/moodledata/enrolments.txt) where it can be read and modified by the web server process. "

My issue is I cannot upload into moodledata on the software installation as do not have backend access to ubuntu. Hope am clearer in explaining now.

Thanks 

Aaron
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Thanks! That makes sense now. I wonder if you could use a repository somehow...who does have access to the backend? Can you have them create a folder for you that you could then reference?
In reply to Emma Richardson

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
System administrator, my colleague in the IT Department. In fact we discussed this and came to same conclusion. He in fact suggested I forward him the csv file, he gives me the path and I just paste it in the flat file plugin. I was pushing a bit to have direct access to a folder as this is going to be a weekly thing and wanted to avoid pesting him.

with regards to the flat file, was I correct in writing it as follows? add, student, 000002x, CPASTC, 2020-12-25 08:00

the users upload csv had titles for each column. for this purpose is there need of titles?

Thanks for support Emma
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Yes, Moodle needs to know what column relates to what data...
In reply to Emma Richardson

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -

So, will I be asking too much if you guide me as to which field names I have to use as the instructions i found are a bit confusing.

operation, role, user idnumber, course idnumber [, starttime [, endtime]]
According to the above format the fields are
operation
role
user idnumber
courseidnumber[
starttime[ endtime]]

am confused because of the square brackets. Is this correct?


Aa

In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hopefully Sara will respond. I have never actually used the flat file method. Try it with a test user and see...
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Randy Thornton -
Picture of Documentation writers
The brackets mean that the field is optional, you can leave it off, while the first four are required. But if you do include endtime, then you must include starttime as well, which is why it is in sub-brackets.

The brackets are not part of the upload file format. Just use the commas between the fields with their names as usual as the column headers.
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
Thanks Randy, so inserting just the starttime only I can, if understanding correctly. It is the end time the issue, you have to insert the starttime for it to work.

Right?
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Randy Thornton -
Picture of Documentation writers
Yes. This is the same as how it works in the settings too if you do them by hand: you have to set a start time if you want to set an end time.

Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
did that and now see what happened (tread below). It is not accepting a start time in the future. Feeling confused
In reply to Emma Richardson

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
So, after a lot of testing managed to go a step forward but cannot see the finish line yet.

Moodle is hosted on Ubuntu. As I do not have direct access into the system, the system administrator shared with me an inside folder and I can access it using WinSCP (practically have an ftp folder where I can put the CSV file). One issue solved.

Did a test using a test csv file with the parameters stated in the Flat file CSV enrolment method. Worked. Second issue solved

Another issue was the starttime and endtime. Used epoch converter and could manipulate dates, update dates. Another issue solved.

Now found out that the flat file enrolment plugin seems to not want to accept enrolment startime to be greater that today (now) date. I can make the endtime in year 2025 but I cannot make the starttime starting even one minute from now. This is very important for us as the whole issue is we need to upload start dates for specific students in a year time (probation period to expire first).

Any solution Emma? or Sara?? or Randy Thornton?
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Randy Thornton -
Picture of Documentation writers
Aaron,

When you say "is not accepting a future start time" what message are you seeing?

Flat file will accept future start times without any issue if the timestamp format is correct and the start time is before the end time.

When the enrolment start time for a user is in the future (as calculated from the exact time that flat file is actually processed), the user will not be enrolled in the course yet. You won't see them on the participants list.

Instead, this upload information is stored in the mdl_enrol_flatfile table in the database and stays there for future processing. When cron runs, it checks this table to see if there are any users there whose start times have arrived, and if so, it will then enrol them in the course. So if the start time is two years from now, then this enrolment information will sit there for two years, and when cron runs two years from now, it will see that user and start time and do the enrolment at that time. They won't be enroled until then.

You can test this for yourself by setting up an enrolment for a test user that is an hour or two in the future from when the file is processed, and the user will be enrolled at that future time by cron.

You can verify this for yourself if you have access to view the database and see that table. See attachment for what this looks like for a user in the database, where the start time for this user is 1669896000 which is Dec 1, 2022.





Attachment screenshot_8988.jpg
In reply to Randy Thornton

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
so that's what was happening. When I said "not accepting" I meant the student details did not change. In my experiment I enrolled a user using flat file method with a past date, example Sunday, 1 November 2020 00:00:00. I could see the registered user and I could reuse the method to change the start date again, example changed it to Tuesday, 1 December 2020 00:00:00. When I changed the date to Friday, 1 January 2021 00:00:00 and uploaded again the flat file, nothing changed. The student was still there and the 1st December 2020 start date was still there.

So according to what you are suggesting I do not first enrol the student (by uploading users method, or manually) but using the flat file method directly?

If this is the case, I might have issues to view the file as the application is hosted on Ubuntu. Also, if I have to upload student directly via flat file method for future date enrolment, and I need to enrol him now, what do I do?

(meanwhile tried uploading a student with a future date of only a few minutes from now but nothing happened. Student did not appear after the set time)

Thanks for the time and support
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Aaron Cauchi -
Apologies, student appeared after set time, seems the set time is not my time but the system time which might have offset of an hour but it worked.

So to conclude, seems that ideally the flat file should be prepared and uploaded, cron job to process it ideally be during the night. The DEL function did not see it work. Will it delete already active students or not as in my case added students where not deleted.

Aaron
In reply to Aaron Cauchi

Re: Set enrolment startdate using CSV upload

by Randy Thornton -
Picture of Documentation writers
Aaron,

Good - usually I forget to change the timestamp so it is in my own time zone instead of UTC, so the processing can be off by a few hours ;)

Which which to use, Flatfile enrolment or User upload?

Use one or the other but not both for the same enrolments. Both are just ways of adding manual users in bulk. They do the same thing in the end: enrol a user with a manual enrolment in the course.

Flat file was really designed to be used when you are pushing the enrolment data from another system and putting it on your server.. You can put the file there by hand of course, but the original idea was it would be automated. (This is why it uses the idnumbers for its users and courses, since the original purpose was to match up some external system id that users may have.)

With Flatfile, there's minimal error handling at the server level and no reports inside Moodle, so it's hard to know what is going on unless you can spend time on the server and in the database. Especially in the case of future enrolment start dates.


The User upload tool on the other hand handles many other user tasks than just enrolments, unlike the Flat file enrolment tool. You will probably be using it for other user related tasks, anyway. Upload users has lots of error checking when you use it, so you can spot bad data and fix it easily.

For future enrolment start dates, Upload user does immediately enrol such users in the course: it marks those users it as "Not current" in the Participants list. Cron will run and then check the date set for the enrolment to start and then turn it on at that date and make the user Active.

That could be a real advantage for future enrolments, as you can see the users already in the course waiting to be enabled. A teacher, for instance, can see all the future users that will one day be active in the course. And if you need to manually intervene and change the enrolment start time in a course for a specific user, or make them Active immediately, you can easily do that in the Participants list.

Each tool has its purpose. Which is better depends on your situation.

Randy
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Set enrolment startdate using CSV upload

by Randy Thornton -
Picture of Documentation writers
To summarize:

Both Flat-file enrolment and the User upload tool can enrol users with a future enrolment start date and time.

The enrolment happens at a different time:

- User upload enrols the user immediately in the course with a status of "Not current." Cron sets the user enrolment status to Active when the user's enrolment start date and time arrive.

- The Flat-file enrolment does _not_ enroll the user immediately, but instead stores their enrolment information for the future. Cron enrols the user with an Active status when their enrolment start date and time arrive.
Average of ratings: Useful (1)