-- Art
Re: How To Make Individual Course Policies (vs. Site Policies)
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).
Re: How To Make Individual Course Policies (vs. Site Policies)
Re: How To Make Individual Course Policies (vs. Site Policies)
// 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.
Re: How To Make Individual Course Policies (vs. Site Policies)
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
Re: How To Make Individual Course Policies (vs. Site Policies)
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

Re: How To Make Individual Course Policies (vs. Site Policies)
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.