How To Make Individual Course Policies (vs. Site Policies)

How To Make Individual Course Policies (vs. Site Policies)

por N Hansen -
Número de respostas: 7
My site is not of the nature that a one-size fits all site policy would work, and I don't want to scare people away who just want to sign up for my mailing list and not participate in a course. So I've come up with a way to make individual course policies that students must agree to before enrolling in that particular course. To do this, you need to have a separate "language" pack for each course you want to have a different policy-then include in the moodle.php file in that language pack the text of the agreement under the enrolmentconfirmation variable. Make sure it ends with a question like "Do you agree to abide by this policy?" because it will come before the yes or no buttons where the message "Are you sure you want to enrol in this course?" normally appears. You also may wish to add tags to align the text of the policy to the left, as by default it will be center aligned. I've done this on my site now myself.
Média das avaliações:  -
Em resposta à N Hansen

Re: How To Make Individual Course Policies (vs. Site Policies)

por Nathaniel Bird -
I've created a way to allow individual Course Policies also. I came up with this before reading the post by N Hansen, but even after reading N Hansen's post I believe that my method may be preferable if students do not always enroll themselves into courses. Using the method described above, if a student is enrolled by an instructor they will by-pass the Course Policies, but it sounds much easier to put in place.

My method involves adding a new field to the mdl_user database table and some modifications to lib/moodlelib.php are required. I've created a new php file called coursepolicy.php which needs to be placed in the moodle/user directory which is based on the policy.php for Moodle 1.8. You should see a zip file attached here which contains the coursepolicy.php file along with a text file (instructions).
Em resposta à Nathaniel Bird

Re: How To Make Individual Course Policies (vs. Site Policies)

por Jon Bolton -
Imagem de Particularly helpful Moodlers Imagem de Testers
Looks good. I've added a feature request for this to be added to core - see MDL-9699. Vote for it!
Em resposta à Nathaniel Bird

Re: How To Make Individual Course Policies (vs. Site Policies)

por tommy wonkium -

// If an html file named coursepolicy#.php (# symbol replaced by an actual course id), then the page will be displayed
//    with a requirement to click "Yes" before being able to continue with the course.

So to use this we have to make a moddledata/1/coursepolicy#.php for every course we will make in the future? Please explain a little better how that works.

Em resposta à Nathaniel Bird

Re: How To Make Individual Course Policies (vs. Site Policies)

por Rob Emery -

Hi,

Whilst I realise I'm resurrecting an ancient thread here, I've recently had to hack some stuff apart a bit to get this working on Moodle 2.3.1 (recent upgrade). So anyone using this may wish to use the following method:

The changes to moodlelib.php I've made are now like this:

//hack to support course policies
    if (file_exists($CFG->dataroot.'/1/coursepolicy'.$course->id.'.html')) {
        $coursepoliciesagreed = split(',',$USER->coursepoliciesagreed);
        // If the course id is not in coursepoliciesagreed, display the course policy
        if(!in_array($course->id,$coursepoliciesagreed)) {

            $SESSION->wantsurl = qualified_me();
            redirect($coursepolicypath = $CFG->wwwroot.'/user/coursepolicy.php?id='.$course->id);
        }
    }

and I've had to unfortunately embed the content of the policy in the page through get_file_contents rather than an iframe, so coursepolicy.php is now like so:

Before echo '<div class="noticebox" align="center">';add:

$urlContent = file_get_contents($CFG->dataroot.'/1/coursepolicy'.$id.'.html');
$urlContent = trim($urlContent);

and replace

echo '<iframe src ="'.$coursepolicypage.'" width="70%"></iframe>';

with:

echo '<div style="width: 70%;" >'.$urlContent.'</div>';

This obviously injects the html directly into the page (not at all ideal), so it's important to ensure that it's well formed!

Rob

Em resposta à Rob Emery

Re: How To Make Individual Course Policies (vs. Site Policies)

por Ellio Mourinho -

Hi Rob,

I can't seem to get this working. I've got it displaying the course policy .html page, however when clicking yes it redirects to user/coursepolicy.php, but doesn't include the applicable info (course id, accepted, sess key, etc.). Just a blank .php page being loaded.

Any idea what might be wrong here? Apache logs aren't saying there's any PHP issues.

Attached screenshot just shows that it's displaying the .html file (which says "This is a static HTML page being fed from moodledata as the course policy."

Regards,

Ellio

Anexo Screen Shot 2013-07-04 at 1.59.41 PM.png
Em resposta à Ellio Mourinho

Re: How To Make Individual Course Policies (vs. Site Policies)

por Ellio Mourinho -

We're using 2.4 currently and managed to resolve the issue. Turns out that there were a few old functions being used that were no longer functional in 2.4.

I intend to implement a UI for admins to be able to add and upload course policies without needing access to moodledata directly. Once I've finished I'll post the updated files here, in case anyone else wants them.

Média das avaliações: Useful (1)