Coder Social home page Coder Social logo

piersharding / moodle-tool_uploadcourse Goto Github PK

View Code? Open in Web Editor NEW
23.0 14.0 12.0 173 KB

** Note** this is now in Moodle core as of 2.6. Moodle Admin Tools plugin for basic upload of course outlines, and applying templates using Moodle course backup files

PHP 100.00%

moodle-tool_uploadcourse's Introduction

moodle-tool_uploadcourse
========================

**NOTE**

This plugin is now available in Moodle core as of 2.6, so this repository is nolonger maintained.  Please refer to https://tracker.moodle.org/browse/MDL-13114 .




Is a Moodle admin/tools plugin for uploading course outlines
in much the same way that admin/tools/uploaduser works for users.
These plugins became available from Moodle 2.2x and onwards, as
this is when the admin/tools framework first appeared.

https://gitorious.org/moodle-tool_uploadcourse

There is also a bulk course category upload function available at https://gitorious.org/moodle-tool_uploadcoursecategory

If you need to manage course enrolments via bulk upload then you should look at 
the core user upload facility - http://docs.moodle.org/22/en/Upload_users

This takes CSV files as input and enables override or augmentation
with default parameter values.

All the usual add,updated,rename, and delete functions.


Thanks to Moshe Golden for help with getting the command line interface going.


!!!! NOTE !!!!
===============

This plugin used to come with the full directory structure
admin/tool/uploadcourse - this is nolonger the case so the
installation proceedure has changed!

General installation proceedures are here:
http://docs.moodle.org/20/en/Installing_contributed_modules_or_plugins

The basic process is:
Download https://gitorious.org/moodle-tool_uploadcourse/moodle-tool_uploadcourse/archive-tarball/master
unpack the file (probably called master) with tar -xzvf master
This will give you a directory called moodle-tool_uploadcourse-moodle-tool_uploadcourse
Move this directory and rename it into its final position:
mv moodle-tool_uploadcourse-moodle-tool_uploadcourse <Moodle dirroot>/admin/tool/uploadcourse

Alternatively you can use git:
cd <Moodle dirroot>/admin/tool
git clone [email protected]:moodle-tool_uploadcourse/moodle-tool_uploadcourse.git uploadcourse

Be careful about leaving the .git directory in your live environment.


CSV File format
===============

Possible column names are:
fullname, shortname, category, idnumber, summary,
format, showgrades, newsitems, teacher, editingteacher, student, modinfo,
manager, coursecreator, guest, user, startdate, numsections, maxbytes, visible, groupmode, restrictmodules,
enablecompletion, completionstartonenrol, completionnotify, hiddensections, groupmodeforce, lang, theme,
cost, showreports, notifystudents, expirynotify, expirythreshold, requested,
deleted,     // 1 means delete course
oldshortname, // for renaming
backupfile, // for restoring a course template after creation
templatename, // course to use as a template - the shortname
reset, // reset the course contents after upload - this resets everything
          - so you loose groups, roles, logs, grades etc. Be Careful!!!

An example file is:

fullname,shortname,category,idnumber,summary,backupfile
Computer Science 101,CS101,Cat1,CS101,The first thing you will ever know,/path/to/backup-moodle2-course-cs101-20120213-0748-nu.mbz

As a general rule, the input values for fields are what you find on the data entry form if you inspect the HTML element.

Format
======
The options for the format value are 'scorm', 'social', weeks', and 'topics'.

Role Names
===========
 'teacher', 'editingteacher', 'student', 'manager',
'coursecreator', 'guest', 'user' are - where config permitting - you can
substitute your own name for these roles (string value).

Category
========
For category you must supply the category name as it is in Moodle and this
field is case sensitive.  If Sub Categories are involved then the full
category hierarchy needs to be specified as a '/' delimited string eg:
'Miscellaneous / Sub Cat / Sub Sub Cat'.  The delimiter can be escaped with
a back slash eg:  'some\/category'.

Course Templating
=================
add column backupfile which has the fully qualified path name to a file on
the server that has a a Moodle course backup in it. 

Add a column templatename which is the shortname of an existing course that 
will be copied over the top of the new course.

Course Enrolment Methods
=========================

Enrolment methods need special CSV columns as there can be many per course, and the fields for each 
method are flexible.  The following is an example with two enrolment methods - manual, and self - firstly you need 
the column identifying the enrolment method enrolmethod_<n>, and then add the corresponding field values subscripted with _<n>.
eg:
fullname,shortname,category,idnumber,summary,enrolmethod_1,status_1,enrolmethod_2,name_2,password_2,customtext1_2
Parent,Parent,,Parent,Parent,manual,1,self,self1,letmein,this is a custom message 1
Students,Students,,Students,Students,manual,0,self,self2,letmein,this is a custom message 2
Teachers,Teachers,,Teachers,Teachers,manual,0,self,self3,letmein,this is a custom message 3

add the special columns for:
 * delete - delete_<n> with value 1
 * disable - disable_<n> with value 1

startdate enrol_startdate enrol_enddate
=======================================
For startdate enrolstartdate, and enrolenddate the values should be supplied in the form like 31.01.2012 or
31/01/2012 that can be consumed by strtotime() (http://php.net/manual/en/function.strtotime.php) - check
your PHP locale settings for the fine tuning eg: m/d/y vs d/m/y.

Enrolment method field 'enrolperiod' must be in seconds.  If this is supplied then enrolenddate will be calculated
as enrolstartdate + enrolperiod.

enrolperiod should be supplied in multiples of enrolment period measurements - 1 hour = 3600, 1 day = 86400
and so on. OR - you can pass a text string that php strtotime() can recognise eg: '2 weeks' or '10 days'

Enrolment Method Role
=====================
Default Role for an enrolment method is supplied by adding the 'role_<n>' column.  The expected value is the
descriptive label for the given role eg: 'Student', or "Teacher'.

Enrolment example:
fullname,shortname,category,idnumber,summary,enrolmethod_1,enrolperiod_1,role_1
a name,short1,Miscellaneous,id1,a summary,manual,864000,Manager

Update Course:
=================
Make sure you have shortname in the csv. After uploading the file, select:
Upload type: one of the update existing related options
Existing course details: Overide with file 
Allow Renames: Yes

Update example:
fullname,shortname
new full name,short1


Run it in batch mode
=====================
Execute Course Upload in batch mode - this must be run as the www-data user (or the equivalent user that the web server runs under).

Options:
-v, --verbose              Print verbose progress information
-h, --help                 Print out this help
-a, --action               Action to perform - addnew, addupdate, update, forceadd
-m, --mode                 Mode of execution - delete, rename, nochange, file, filedefaults, missing
-f, --file                 CSV File
-d, --delimiter            delimiter - colon,semicolon,tab,cfg,comma
-e, --encoding             File encoding - utf8 etc
-c, --category             Course category
-s, --templateshortname    Template course by shortname
-t, --template             Template course by backup file
-g, --format               Course format - weeks,scorm,social,topics
-n, --numsections          Number of sections


Example:
sudo -u www-data /usr/bin/php admin/tool/uploadcourse/cli/uploadcourse.php --action=addupdate \
                 --mode=delete --file=./courses.csv --delimiter=comma



Installation
=================
git clone this repository into <moodle root>/admin/tools/uploadcourse directory.

Point your browser at Moodle, and login as admin.  This should kick off
the upgrade so that Moodle can now recognise the new plugin.

This was inspired in part by a need for a complimentary function for uploading
courses (as for users) for the the NZ MLE tools for Identity and 
Access Managment (synchronising users with the School SMS):
https://gitorious.org/pla-udi
and
https://gitorious.org/pla-udi/mle_ide_tools

Copyright (C) Piers Harding 2011 and beyond, All rights reserved

moodle-tool_uploadcourse free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

moodle-tool_uploadcourse's People

Contributors

afhole avatar gzmask avatar pauln avatar piersharding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-tool_uploadcourse's Issues

updating courses to have guest access

I have a couple of hundred courses that I would like to set to guest access mode. I have a csv with their IDs and use the web interface. I use the following settings:

Upload type -> Update existing courses only
Existing course details -> override with file and defauls

Allow guest access -> Yes

The script runs, says that it has updated the courses, but they remain blocked to guests. Any ideas?

EDIT: you can get around this issue by setting the 'enrolmethod_1' to equal 'guest' in the csv files. The web interface does seem a little broken though

enrolmethod as meta

Hi,

I'm trying to bulk create courses with enrolment method set to meta and linked to different courses, specified by the 'link_1' field. What is the format I should be using? I can't find any documentation at the moment.

+----------+-----------+----------+----------+----------+---------------+--------+
| fullname | shortname | category | idnumber | summary | enrolmethod_1 | id_1 |
+----------+-----------+----------+----------+----------+---------------+--------+
| Parent | Parent | | Parent | Parent | meta | 873 |
| Students | Students | | Students | Students | meta | 862 |
| Teachers | Teachers | | Teachers | Teachers | meta | 128 |
+----------+-----------+----------+----------+----------+---------------+--------+

Trying the above table gives no issues, but doesn't enrol anyone either!

Reset function

Hi,

I create a course template.
Inside the template are database activities with entries.

After creating a new course by backupfile or with template shortname the database entries are resetted.
I set "reset" = 0 in the csv.

What's wrong?

Ishan

Do I need to include the summary to create a course?

Hello,

Thanks for this tool. It works great!

One question. I cannot seem to create a new course unless I include a course summary in the "summary" field. Is there a way to create a course without a summary? When I try, I get the error "Field 'summary' is missing"

option to import just blocks / activities

Hi, thanks Piers, this is a great plugin for us but we're having some issues.

The first of these is we have old backup zips from M1.9. If we import these manually using frontend restore we get option to include/exclude blocks/activities. This would be really useful added to the interface for your tool and as an option in the csv file. I had a brief poke around in docs, looks like there is a settings array for the controller https://moodle.org/mod/forum/discuss.php?d=194308

templatename in file upload not working

Hi, perhaps I have misunderstood use of this but ... if you use templatename on creation of courses using file upload then it all works as expected. However, I wanted to apply a template (just containing some blocks) after the courses have been created. I have prepared file upload with templatename field and shortname of my template course, using update existing courses option ... nothing happens. Have I got this right?

Updating Course

Hi

I love this tool, it has made creating a course really unbelievably simple in moodle.

I wanted to change few things in the courses and I was not able to find the way to update a course. Can you please guide how to update the courses.

This info in the Readme.txt would be great. So, once you give me a slight hint on how to update courses. I would be able to update and send an updated Readme for you to commit if that helps everyone.

Regards,

  • Pankaj

Very minor: After upload courses result I'm expecting a notification that says something like "Courses successfully uploaded".

After the "upload courses result" page I'm expecting a notification that says something like "Hooray! Courses successfully uploaded". But there appears to be no notification. It just goes back to the upload page. Issuing a notification is the way moodle does it and I got used to that. Without it, every time I upload courses I sit here and get anxious that something went wrong :).

error/admin/sectionerror

I try to run it after extract this to folder /moodle/admin/uploadcourse.

 Error - 10_8_151_114_goals-dev_moodle_admin_uploadcourse

Debug info:
Error code: sectionerror
Stack trace:

line 467 of /lib/setuplib.php: moodle_exception thrown
line 5819 of /lib/adminlib.php: call to print_error()
line 39 of /admin/uploadcourse/index.php: call to admin_externalpage_setup()

http://docs.moodle.org/23/en/error/admin/sectionerror

Course Default Settings

Hi,

Thank you for this excellent tool!

I think I am experiencing a problem with moodle-tool_uploadcourse when importing new courses. Basically, it does not seem to respect the "Course Default Settings" I have in place on my site. For example, when I back up a course with completion tracking enabled, and then restore from that course as a template (either from backup file or directly from the course), the restored course does not have completion tracking enabled and the completion settings I had in place on the original course do not exist in the restored course. Wondering if maybe other "Course Default Settings" are ignored too, or if this could just be a problem with completion settings.

If I restore the same course manually via the user interface, it does restore correctly with the completion setting enabled and related completion settings in tact.

If it helps, I would be interested in compensating you to resolve this issue more quickly than might otherwise be possible.

Thanks again for such a great addition to Moodle!

Jamie

Moodle 2.3.3+ (Build: 20121130) startdate format is interpreted as month/day/year that is different from that stated in readme

Moodle 2.3.3+ (Build: 20121130)
tool_uploadcourse version = 2012112300

The readme.txt states:

For startdate enrolstartdate, and enrolenddate the values should be supplied in the form of
31.01.2012 or 31/01/2012.

That is day/month/year or 05/01/2013 should be January 1, 2013. But in this version of moodle this is interpreted as May 01, 2013. The form appropriate is 01/31/2012 i.e month/day/year.

Maybe the readme instruction is wrong or something changed in the moodle code.

Please make compatible with 2.4

It doesn't work with 2.4 - at a glance the changes in course formats seem to be the main problem. I intend to have a look at it and will let you know how I get on but I thought it was worth mentioning in case you have a solution nearly ready or similar.

Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.